babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927
  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. * Gets the list of observers
  4360. */
  4361. readonly observers: Array<Observer<T>>;
  4362. /**
  4363. * Creates a new observable
  4364. * @param onObserverAdded defines a callback to call when a new observer is added
  4365. */
  4366. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4367. /**
  4368. * Create a new Observer with the specified callback
  4369. * @param callback the callback that will be executed for that Observer
  4370. * @param mask the mask used to filter observers
  4371. * @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.
  4372. * @param scope optional scope for the callback to be called from
  4373. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4374. * @returns the new observer created for the callback
  4375. */
  4376. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4377. /**
  4378. * Create a new Observer with the specified callback and unregisters after the next notification
  4379. * @param callback the callback that will be executed for that Observer
  4380. * @returns the new observer created for the callback
  4381. */
  4382. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4383. /**
  4384. * Remove an Observer from the Observable object
  4385. * @param observer the instance of the Observer to remove
  4386. * @returns false if it doesn't belong to this Observable
  4387. */
  4388. remove(observer: Nullable<Observer<T>>): boolean;
  4389. /**
  4390. * Remove a callback from the Observable object
  4391. * @param callback the callback to remove
  4392. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4393. * @returns false if it doesn't belong to this Observable
  4394. */
  4395. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4396. private _deferUnregister;
  4397. private _remove;
  4398. /**
  4399. * Moves the observable to the top of the observer list making it get called first when notified
  4400. * @param observer the observer to move
  4401. */
  4402. makeObserverTopPriority(observer: Observer<T>): void;
  4403. /**
  4404. * Moves the observable to the bottom of the observer list making it get called last when notified
  4405. * @param observer the observer to move
  4406. */
  4407. makeObserverBottomPriority(observer: Observer<T>): void;
  4408. /**
  4409. * Notify all Observers by calling their respective callback with the given data
  4410. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4411. * @param eventData defines the data to send to all observers
  4412. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4413. * @param target defines the original target of the state
  4414. * @param currentTarget defines the current target of the state
  4415. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4416. */
  4417. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4418. /**
  4419. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4420. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4421. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4422. * and it is crucial that all callbacks will be executed.
  4423. * The order of the callbacks is kept, callbacks are not executed parallel.
  4424. *
  4425. * @param eventData The data to be sent to each callback
  4426. * @param mask is used to filter observers defaults to -1
  4427. * @param target defines the callback target (see EventState)
  4428. * @param currentTarget defines he current object in the bubbling phase
  4429. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4430. */
  4431. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4432. /**
  4433. * Notify a specific observer
  4434. * @param observer defines the observer to notify
  4435. * @param eventData defines the data to be sent to each callback
  4436. * @param mask is used to filter observers defaults to -1
  4437. */
  4438. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4439. /**
  4440. * Gets a boolean indicating if the observable has at least one observer
  4441. * @returns true is the Observable has at least one Observer registered
  4442. */
  4443. hasObservers(): boolean;
  4444. /**
  4445. * Clear the list of observers
  4446. */
  4447. clear(): void;
  4448. /**
  4449. * Clone the current observable
  4450. * @returns a new observable
  4451. */
  4452. clone(): Observable<T>;
  4453. /**
  4454. * Does this observable handles observer registered with a given mask
  4455. * @param mask defines the mask to be tested
  4456. * @return whether or not one observer registered with the given mask is handeled
  4457. **/
  4458. hasSpecificMask(mask?: number): boolean;
  4459. }
  4460. }
  4461. declare module "babylonjs/Misc/filesInputStore" {
  4462. /**
  4463. * Class used to help managing file picking and drag'n'drop
  4464. * File Storage
  4465. */
  4466. export class FilesInputStore {
  4467. /**
  4468. * List of files ready to be loaded
  4469. */
  4470. static FilesToLoad: {
  4471. [key: string]: File;
  4472. };
  4473. }
  4474. }
  4475. declare module "babylonjs/Engines/constants" {
  4476. /** Defines the cross module used constants to avoid circular dependncies */
  4477. export class Constants {
  4478. /** Defines that alpha blending is disabled */
  4479. static readonly ALPHA_DISABLE: number;
  4480. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4481. static readonly ALPHA_ADD: number;
  4482. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4483. static readonly ALPHA_COMBINE: number;
  4484. /** Defines that alpha blending to DEST - SRC * DEST */
  4485. static readonly ALPHA_SUBTRACT: number;
  4486. /** Defines that alpha blending to SRC * DEST */
  4487. static readonly ALPHA_MULTIPLY: number;
  4488. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4489. static readonly ALPHA_MAXIMIZED: number;
  4490. /** Defines that alpha blending to SRC + DEST */
  4491. static readonly ALPHA_ONEONE: number;
  4492. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4493. static readonly ALPHA_PREMULTIPLIED: number;
  4494. /**
  4495. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4496. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4497. */
  4498. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4499. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4500. static readonly ALPHA_INTERPOLATE: number;
  4501. /**
  4502. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4503. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4504. */
  4505. static readonly ALPHA_SCREENMODE: number;
  4506. /** Defines that the ressource is not delayed*/
  4507. static readonly DELAYLOADSTATE_NONE: number;
  4508. /** Defines that the ressource was successfully delay loaded */
  4509. static readonly DELAYLOADSTATE_LOADED: number;
  4510. /** Defines that the ressource is currently delay loading */
  4511. static readonly DELAYLOADSTATE_LOADING: number;
  4512. /** Defines that the ressource is delayed and has not started loading */
  4513. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4515. static readonly NEVER: number;
  4516. /** 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 */
  4517. static readonly ALWAYS: number;
  4518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4519. static readonly LESS: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4521. static readonly EQUAL: number;
  4522. /** 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 */
  4523. static readonly LEQUAL: number;
  4524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4525. static readonly GREATER: number;
  4526. /** 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 */
  4527. static readonly GEQUAL: number;
  4528. /** 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 */
  4529. static readonly NOTEQUAL: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be kept */
  4531. static readonly KEEP: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4533. static readonly REPLACE: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4535. static readonly INCR: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4537. static readonly DECR: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4539. static readonly INVERT: number;
  4540. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4541. static readonly INCR_WRAP: number;
  4542. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4543. static readonly DECR_WRAP: number;
  4544. /** Texture is not repeating outside of 0..1 UVs */
  4545. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4546. /** Texture is repeating outside of 0..1 UVs */
  4547. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4548. /** Texture is repeating and mirrored */
  4549. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4550. /** ALPHA */
  4551. static readonly TEXTUREFORMAT_ALPHA: number;
  4552. /** LUMINANCE */
  4553. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4554. /** LUMINANCE_ALPHA */
  4555. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4556. /** RGB */
  4557. static readonly TEXTUREFORMAT_RGB: number;
  4558. /** RGBA */
  4559. static readonly TEXTUREFORMAT_RGBA: number;
  4560. /** RED */
  4561. static readonly TEXTUREFORMAT_RED: number;
  4562. /** RED (2nd reference) */
  4563. static readonly TEXTUREFORMAT_R: number;
  4564. /** RG */
  4565. static readonly TEXTUREFORMAT_RG: number;
  4566. /** RED_INTEGER */
  4567. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4568. /** RED_INTEGER (2nd reference) */
  4569. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4570. /** RG_INTEGER */
  4571. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4572. /** RGB_INTEGER */
  4573. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4574. /** RGBA_INTEGER */
  4575. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4576. /** UNSIGNED_BYTE */
  4577. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4578. /** UNSIGNED_BYTE (2nd reference) */
  4579. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4580. /** FLOAT */
  4581. static readonly TEXTURETYPE_FLOAT: number;
  4582. /** HALF_FLOAT */
  4583. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4584. /** BYTE */
  4585. static readonly TEXTURETYPE_BYTE: number;
  4586. /** SHORT */
  4587. static readonly TEXTURETYPE_SHORT: number;
  4588. /** UNSIGNED_SHORT */
  4589. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4590. /** INT */
  4591. static readonly TEXTURETYPE_INT: number;
  4592. /** UNSIGNED_INT */
  4593. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4594. /** UNSIGNED_SHORT_4_4_4_4 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4596. /** UNSIGNED_SHORT_5_5_5_1 */
  4597. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4598. /** UNSIGNED_SHORT_5_6_5 */
  4599. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4600. /** UNSIGNED_INT_2_10_10_10_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4602. /** UNSIGNED_INT_24_8 */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4604. /** UNSIGNED_INT_10F_11F_11F_REV */
  4605. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4606. /** UNSIGNED_INT_5_9_9_9_REV */
  4607. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4608. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4609. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4610. /** nearest is mag = nearest and min = nearest and mip = linear */
  4611. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4612. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4613. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4614. /** Trilinear is mag = linear and min = linear and mip = linear */
  4615. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4616. /** nearest is mag = nearest and min = nearest and mip = linear */
  4617. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4618. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4619. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4620. /** Trilinear is mag = linear and min = linear and mip = linear */
  4621. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4622. /** mag = nearest and min = nearest and mip = nearest */
  4623. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4624. /** mag = nearest and min = linear and mip = nearest */
  4625. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4626. /** mag = nearest and min = linear and mip = linear */
  4627. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4628. /** mag = nearest and min = linear and mip = none */
  4629. static readonly TEXTURE_NEAREST_LINEAR: number;
  4630. /** mag = nearest and min = nearest and mip = none */
  4631. static readonly TEXTURE_NEAREST_NEAREST: number;
  4632. /** mag = linear and min = nearest and mip = nearest */
  4633. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4634. /** mag = linear and min = nearest and mip = linear */
  4635. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4636. /** mag = linear and min = linear and mip = none */
  4637. static readonly TEXTURE_LINEAR_LINEAR: number;
  4638. /** mag = linear and min = nearest and mip = none */
  4639. static readonly TEXTURE_LINEAR_NEAREST: number;
  4640. /** Explicit coordinates mode */
  4641. static readonly TEXTURE_EXPLICIT_MODE: number;
  4642. /** Spherical coordinates mode */
  4643. static readonly TEXTURE_SPHERICAL_MODE: number;
  4644. /** Planar coordinates mode */
  4645. static readonly TEXTURE_PLANAR_MODE: number;
  4646. /** Cubic coordinates mode */
  4647. static readonly TEXTURE_CUBIC_MODE: number;
  4648. /** Projection coordinates mode */
  4649. static readonly TEXTURE_PROJECTION_MODE: number;
  4650. /** Skybox coordinates mode */
  4651. static readonly TEXTURE_SKYBOX_MODE: number;
  4652. /** Inverse Cubic coordinates mode */
  4653. static readonly TEXTURE_INVCUBIC_MODE: number;
  4654. /** Equirectangular coordinates mode */
  4655. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4656. /** Equirectangular Fixed coordinates mode */
  4657. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4658. /** Equirectangular Fixed Mirrored coordinates mode */
  4659. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4660. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4661. static readonly SCALEMODE_FLOOR: number;
  4662. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4663. static readonly SCALEMODE_NEAREST: number;
  4664. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4665. static readonly SCALEMODE_CEILING: number;
  4666. /**
  4667. * The dirty texture flag value
  4668. */
  4669. static readonly MATERIAL_TextureDirtyFlag: number;
  4670. /**
  4671. * The dirty light flag value
  4672. */
  4673. static readonly MATERIAL_LightDirtyFlag: number;
  4674. /**
  4675. * The dirty fresnel flag value
  4676. */
  4677. static readonly MATERIAL_FresnelDirtyFlag: number;
  4678. /**
  4679. * The dirty attribute flag value
  4680. */
  4681. static readonly MATERIAL_AttributesDirtyFlag: number;
  4682. /**
  4683. * The dirty misc flag value
  4684. */
  4685. static readonly MATERIAL_MiscDirtyFlag: number;
  4686. /**
  4687. * The all dirty flag value
  4688. */
  4689. static readonly MATERIAL_AllDirtyFlag: number;
  4690. /**
  4691. * Returns the triangle fill mode
  4692. */
  4693. static readonly MATERIAL_TriangleFillMode: number;
  4694. /**
  4695. * Returns the wireframe mode
  4696. */
  4697. static readonly MATERIAL_WireFrameFillMode: number;
  4698. /**
  4699. * Returns the point fill mode
  4700. */
  4701. static readonly MATERIAL_PointFillMode: number;
  4702. /**
  4703. * Returns the point list draw mode
  4704. */
  4705. static readonly MATERIAL_PointListDrawMode: number;
  4706. /**
  4707. * Returns the line list draw mode
  4708. */
  4709. static readonly MATERIAL_LineListDrawMode: number;
  4710. /**
  4711. * Returns the line loop draw mode
  4712. */
  4713. static readonly MATERIAL_LineLoopDrawMode: number;
  4714. /**
  4715. * Returns the line strip draw mode
  4716. */
  4717. static readonly MATERIAL_LineStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle strip draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleStripDrawMode: number;
  4722. /**
  4723. * Returns the triangle fan draw mode
  4724. */
  4725. static readonly MATERIAL_TriangleFanDrawMode: number;
  4726. /**
  4727. * Stores the clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4730. /**
  4731. * Stores the counter clock-wise side orientation
  4732. */
  4733. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4734. /**
  4735. * Nothing
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_NothingTrigger: number;
  4739. /**
  4740. * On pick
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPickTrigger: number;
  4744. /**
  4745. * On left pick
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnLeftPickTrigger: number;
  4749. /**
  4750. * On right pick
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnRightPickTrigger: number;
  4754. /**
  4755. * On center pick
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnCenterPickTrigger: number;
  4759. /**
  4760. * On pick down
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnPickDownTrigger: number;
  4764. /**
  4765. * On double pick
  4766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4767. */
  4768. static readonly ACTION_OnDoublePickTrigger: number;
  4769. /**
  4770. * On pick up
  4771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4772. */
  4773. static readonly ACTION_OnPickUpTrigger: number;
  4774. /**
  4775. * On pick out.
  4776. * This trigger will only be raised if you also declared a OnPickDown
  4777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4778. */
  4779. static readonly ACTION_OnPickOutTrigger: number;
  4780. /**
  4781. * On long press
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4783. */
  4784. static readonly ACTION_OnLongPressTrigger: number;
  4785. /**
  4786. * On pointer over
  4787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4788. */
  4789. static readonly ACTION_OnPointerOverTrigger: number;
  4790. /**
  4791. * On pointer out
  4792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4793. */
  4794. static readonly ACTION_OnPointerOutTrigger: number;
  4795. /**
  4796. * On every frame
  4797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4798. */
  4799. static readonly ACTION_OnEveryFrameTrigger: number;
  4800. /**
  4801. * On intersection enter
  4802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4803. */
  4804. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4805. /**
  4806. * On intersection exit
  4807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4808. */
  4809. static readonly ACTION_OnIntersectionExitTrigger: number;
  4810. /**
  4811. * On key down
  4812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4813. */
  4814. static readonly ACTION_OnKeyDownTrigger: number;
  4815. /**
  4816. * On key up
  4817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4818. */
  4819. static readonly ACTION_OnKeyUpTrigger: number;
  4820. /**
  4821. * Billboard mode will only apply to Y axis
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4824. /**
  4825. * Billboard mode will apply to all axes
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4828. /**
  4829. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4830. */
  4831. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4832. /**
  4833. * Gets or sets base Assets URL
  4834. */
  4835. static PARTICLES_BaseAssetsUrl: string;
  4836. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4837. * Test order :
  4838. * Is the bounding sphere outside the frustum ?
  4839. * If not, are the bounding box vertices outside the frustum ?
  4840. * It not, then the cullable object is in the frustum.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4843. /** Culling strategy : Bounding Sphere Only.
  4844. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4845. * It's also less accurate than the standard because some not visible objects can still be selected.
  4846. * Test : is the bounding sphere outside the frustum ?
  4847. * If not, then the cullable object is in the frustum.
  4848. */
  4849. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4850. /** Culling strategy : Optimistic Inclusion.
  4851. * This in an inclusion test first, then the standard exclusion test.
  4852. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4853. * 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.
  4854. * Anyway, it's as accurate as the standard strategy.
  4855. * Test :
  4856. * Is the cullable object bounding sphere center in the frustum ?
  4857. * If not, apply the default culling strategy.
  4858. */
  4859. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4860. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4861. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4862. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4863. * 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.
  4864. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4865. * Test :
  4866. * Is the cullable object bounding sphere center in the frustum ?
  4867. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4868. */
  4869. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4870. /**
  4871. * No logging while loading
  4872. */
  4873. static readonly SCENELOADER_NO_LOGGING: number;
  4874. /**
  4875. * Minimal logging while loading
  4876. */
  4877. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4878. /**
  4879. * Summary logging while loading
  4880. */
  4881. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4882. /**
  4883. * Detailled logging while loading
  4884. */
  4885. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4886. }
  4887. }
  4888. declare module "babylonjs/Misc/domManagement" {
  4889. /**
  4890. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4891. * Babylon.js
  4892. */
  4893. export class DomManagement {
  4894. /**
  4895. * Checks if the window object exists
  4896. * @returns true if the window object exists
  4897. */
  4898. static IsWindowObjectExist(): boolean;
  4899. /**
  4900. * Extracts text content from a DOM element hierarchy
  4901. * @param element defines the root element
  4902. * @returns a string
  4903. */
  4904. static GetDOMTextContent(element: HTMLElement): string;
  4905. }
  4906. }
  4907. declare module "babylonjs/Misc/logger" {
  4908. /**
  4909. * Logger used througouht the application to allow configuration of
  4910. * the log level required for the messages.
  4911. */
  4912. export class Logger {
  4913. /**
  4914. * No log
  4915. */
  4916. static readonly NoneLogLevel: number;
  4917. /**
  4918. * Only message logs
  4919. */
  4920. static readonly MessageLogLevel: number;
  4921. /**
  4922. * Only warning logs
  4923. */
  4924. static readonly WarningLogLevel: number;
  4925. /**
  4926. * Only error logs
  4927. */
  4928. static readonly ErrorLogLevel: number;
  4929. /**
  4930. * All logs
  4931. */
  4932. static readonly AllLogLevel: number;
  4933. private static _LogCache;
  4934. /**
  4935. * Gets a value indicating the number of loading errors
  4936. * @ignorenaming
  4937. */
  4938. static errorsCount: number;
  4939. /**
  4940. * Callback called when a new log is added
  4941. */
  4942. static OnNewCacheEntry: (entry: string) => void;
  4943. private static _AddLogEntry;
  4944. private static _FormatMessage;
  4945. private static _LogDisabled;
  4946. private static _LogEnabled;
  4947. private static _WarnDisabled;
  4948. private static _WarnEnabled;
  4949. private static _ErrorDisabled;
  4950. private static _ErrorEnabled;
  4951. /**
  4952. * Log a message to the console
  4953. */
  4954. static Log: (message: string) => void;
  4955. /**
  4956. * Write a warning message to the console
  4957. */
  4958. static Warn: (message: string) => void;
  4959. /**
  4960. * Write an error message to the console
  4961. */
  4962. static Error: (message: string) => void;
  4963. /**
  4964. * Gets current log cache (list of logs)
  4965. */
  4966. static readonly LogCache: string;
  4967. /**
  4968. * Clears the log cache
  4969. */
  4970. static ClearLogCache(): void;
  4971. /**
  4972. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4973. */
  4974. static LogLevels: number;
  4975. }
  4976. }
  4977. declare module "babylonjs/Misc/typeStore" {
  4978. /** @hidden */
  4979. export class _TypeStore {
  4980. /** @hidden */
  4981. static RegisteredTypes: {
  4982. [key: string]: Object;
  4983. };
  4984. /** @hidden */
  4985. static GetClass(fqdn: string): any;
  4986. }
  4987. }
  4988. declare module "babylonjs/Misc/deepCopier" {
  4989. /**
  4990. * Class containing a set of static utilities functions for deep copy.
  4991. */
  4992. export class DeepCopier {
  4993. /**
  4994. * Tries to copy an object by duplicating every property
  4995. * @param source defines the source object
  4996. * @param destination defines the target object
  4997. * @param doNotCopyList defines a list of properties to avoid
  4998. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4999. */
  5000. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  5001. }
  5002. }
  5003. declare module "babylonjs/Misc/precisionDate" {
  5004. /**
  5005. * Class containing a set of static utilities functions for precision date
  5006. */
  5007. export class PrecisionDate {
  5008. /**
  5009. * Gets either window.performance.now() if supported or Date.now() else
  5010. */
  5011. static readonly Now: number;
  5012. }
  5013. }
  5014. declare module "babylonjs/Misc/devTools" {
  5015. /** @hidden */
  5016. export class _DevTools {
  5017. static WarnImport(name: string): string;
  5018. }
  5019. }
  5020. declare module "babylonjs/Misc/webRequest" {
  5021. /**
  5022. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5023. */
  5024. export class WebRequest {
  5025. private _xhr;
  5026. /**
  5027. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5028. * i.e. when loading files, where the server/service expects an Authorization header
  5029. */
  5030. static CustomRequestHeaders: {
  5031. [key: string]: string;
  5032. };
  5033. /**
  5034. * Add callback functions in this array to update all the requests before they get sent to the network
  5035. */
  5036. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  5037. private _injectCustomRequestHeaders;
  5038. /**
  5039. * Gets or sets a function to be called when loading progress changes
  5040. */
  5041. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5042. /**
  5043. * Returns client's state
  5044. */
  5045. readonly readyState: number;
  5046. /**
  5047. * Returns client's status
  5048. */
  5049. readonly status: number;
  5050. /**
  5051. * Returns client's status as a text
  5052. */
  5053. readonly statusText: string;
  5054. /**
  5055. * Returns client's response
  5056. */
  5057. readonly response: any;
  5058. /**
  5059. * Returns client's response url
  5060. */
  5061. readonly responseURL: string;
  5062. /**
  5063. * Returns client's response as text
  5064. */
  5065. readonly responseText: string;
  5066. /**
  5067. * Gets or sets the expected response type
  5068. */
  5069. responseType: XMLHttpRequestResponseType;
  5070. /** @hidden */
  5071. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5072. /** @hidden */
  5073. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5074. /**
  5075. * Cancels any network activity
  5076. */
  5077. abort(): void;
  5078. /**
  5079. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5080. * @param body defines an optional request body
  5081. */
  5082. send(body?: Document | BodyInit | null): void;
  5083. /**
  5084. * Sets the request method, request URL
  5085. * @param method defines the method to use (GET, POST, etc..)
  5086. * @param url defines the url to connect with
  5087. */
  5088. open(method: string, url: string): void;
  5089. }
  5090. }
  5091. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5092. /**
  5093. * Class used to evalaute queries containing `and` and `or` operators
  5094. */
  5095. export class AndOrNotEvaluator {
  5096. /**
  5097. * Evaluate a query
  5098. * @param query defines the query to evaluate
  5099. * @param evaluateCallback defines the callback used to filter result
  5100. * @returns true if the query matches
  5101. */
  5102. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5103. private static _HandleParenthesisContent;
  5104. private static _SimplifyNegation;
  5105. }
  5106. }
  5107. declare module "babylonjs/Misc/tags" {
  5108. /**
  5109. * Class used to store custom tags
  5110. */
  5111. export class Tags {
  5112. /**
  5113. * Adds support for tags on the given object
  5114. * @param obj defines the object to use
  5115. */
  5116. static EnableFor(obj: any): void;
  5117. /**
  5118. * Removes tags support
  5119. * @param obj defines the object to use
  5120. */
  5121. static DisableFor(obj: any): void;
  5122. /**
  5123. * Gets a boolean indicating if the given object has tags
  5124. * @param obj defines the object to use
  5125. * @returns a boolean
  5126. */
  5127. static HasTags(obj: any): boolean;
  5128. /**
  5129. * Gets the tags available on a given object
  5130. * @param obj defines the object to use
  5131. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5132. * @returns the tags
  5133. */
  5134. static GetTags(obj: any, asString?: boolean): any;
  5135. /**
  5136. * Adds tags to an object
  5137. * @param obj defines the object to use
  5138. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5139. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5140. */
  5141. static AddTagsTo(obj: any, tagsString: string): void;
  5142. /**
  5143. * @hidden
  5144. */
  5145. static _AddTagTo(obj: any, tag: string): void;
  5146. /**
  5147. * Removes specific tags from a specific object
  5148. * @param obj defines the object to use
  5149. * @param tagsString defines the tags to remove
  5150. */
  5151. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5152. /**
  5153. * @hidden
  5154. */
  5155. static _RemoveTagFrom(obj: any, tag: string): void;
  5156. /**
  5157. * Defines if tags hosted on an object match a given query
  5158. * @param obj defines the object to use
  5159. * @param tagsQuery defines the tag query
  5160. * @returns a boolean
  5161. */
  5162. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5163. }
  5164. }
  5165. declare module "babylonjs/Materials/materialDefines" {
  5166. /**
  5167. * Manages the defines for the Material
  5168. */
  5169. export class MaterialDefines {
  5170. /** @hidden */
  5171. protected _keys: string[];
  5172. private _isDirty;
  5173. /** @hidden */
  5174. _renderId: number;
  5175. /** @hidden */
  5176. _areLightsDirty: boolean;
  5177. /** @hidden */
  5178. _areAttributesDirty: boolean;
  5179. /** @hidden */
  5180. _areTexturesDirty: boolean;
  5181. /** @hidden */
  5182. _areFresnelDirty: boolean;
  5183. /** @hidden */
  5184. _areMiscDirty: boolean;
  5185. /** @hidden */
  5186. _areImageProcessingDirty: boolean;
  5187. /** @hidden */
  5188. _normals: boolean;
  5189. /** @hidden */
  5190. _uvs: boolean;
  5191. /** @hidden */
  5192. _needNormals: boolean;
  5193. /** @hidden */
  5194. _needUVs: boolean;
  5195. [id: string]: any;
  5196. /**
  5197. * Specifies if the material needs to be re-calculated
  5198. */
  5199. readonly isDirty: boolean;
  5200. /**
  5201. * Marks the material to indicate that it has been re-calculated
  5202. */
  5203. markAsProcessed(): void;
  5204. /**
  5205. * Marks the material to indicate that it needs to be re-calculated
  5206. */
  5207. markAsUnprocessed(): void;
  5208. /**
  5209. * Marks the material to indicate all of its defines need to be re-calculated
  5210. */
  5211. markAllAsDirty(): void;
  5212. /**
  5213. * Marks the material to indicate that image processing needs to be re-calculated
  5214. */
  5215. markAsImageProcessingDirty(): void;
  5216. /**
  5217. * Marks the material to indicate the lights need to be re-calculated
  5218. */
  5219. markAsLightDirty(): void;
  5220. /**
  5221. * Marks the attribute state as changed
  5222. */
  5223. markAsAttributesDirty(): void;
  5224. /**
  5225. * Marks the texture state as changed
  5226. */
  5227. markAsTexturesDirty(): void;
  5228. /**
  5229. * Marks the fresnel state as changed
  5230. */
  5231. markAsFresnelDirty(): void;
  5232. /**
  5233. * Marks the misc state as changed
  5234. */
  5235. markAsMiscDirty(): void;
  5236. /**
  5237. * Rebuilds the material defines
  5238. */
  5239. rebuild(): void;
  5240. /**
  5241. * Specifies if two material defines are equal
  5242. * @param other - A material define instance to compare to
  5243. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5244. */
  5245. isEqual(other: MaterialDefines): boolean;
  5246. /**
  5247. * Clones this instance's defines to another instance
  5248. * @param other - material defines to clone values to
  5249. */
  5250. cloneTo(other: MaterialDefines): void;
  5251. /**
  5252. * Resets the material define values
  5253. */
  5254. reset(): void;
  5255. /**
  5256. * Converts the material define values to a string
  5257. * @returns - String of material define information
  5258. */
  5259. toString(): string;
  5260. }
  5261. }
  5262. declare module "babylonjs/Engines/IPipelineContext" {
  5263. /**
  5264. * Class used to store and describe the pipeline context associated with an effect
  5265. */
  5266. export interface IPipelineContext {
  5267. /**
  5268. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5269. */
  5270. isAsync: boolean;
  5271. /**
  5272. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5273. */
  5274. isReady: boolean;
  5275. /** @hidden */
  5276. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5277. }
  5278. }
  5279. declare module "babylonjs/Meshes/dataBuffer" {
  5280. /**
  5281. * Class used to store gfx data (like WebGLBuffer)
  5282. */
  5283. export class DataBuffer {
  5284. /**
  5285. * Gets or sets the number of objects referencing this buffer
  5286. */
  5287. references: number;
  5288. /** Gets or sets the size of the underlying buffer */
  5289. capacity: number;
  5290. /**
  5291. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5292. */
  5293. is32Bits: boolean;
  5294. /**
  5295. * Gets the underlying buffer
  5296. */
  5297. readonly underlyingResource: any;
  5298. }
  5299. }
  5300. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5301. /** @hidden */
  5302. export interface IShaderProcessor {
  5303. attributeProcessor?: (attribute: string) => string;
  5304. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5305. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5306. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5307. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5308. lineProcessor?: (line: string, isFragment: boolean) => string;
  5309. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5310. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5311. }
  5312. }
  5313. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5314. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5315. /** @hidden */
  5316. export interface ProcessingOptions {
  5317. defines: string[];
  5318. indexParameters: any;
  5319. isFragment: boolean;
  5320. shouldUseHighPrecisionShader: boolean;
  5321. supportsUniformBuffers: boolean;
  5322. shadersRepository: string;
  5323. includesShadersStore: {
  5324. [key: string]: string;
  5325. };
  5326. processor?: IShaderProcessor;
  5327. version: string;
  5328. platformName: string;
  5329. lookForClosingBracketForUniformBuffer?: boolean;
  5330. }
  5331. }
  5332. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5333. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5334. /** @hidden */
  5335. export class ShaderCodeNode {
  5336. line: string;
  5337. children: ShaderCodeNode[];
  5338. additionalDefineKey?: string;
  5339. additionalDefineValue?: string;
  5340. isValid(preprocessors: {
  5341. [key: string]: string;
  5342. }): boolean;
  5343. process(preprocessors: {
  5344. [key: string]: string;
  5345. }, options: ProcessingOptions): string;
  5346. }
  5347. }
  5348. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5349. /** @hidden */
  5350. export class ShaderCodeCursor {
  5351. private _lines;
  5352. lineIndex: number;
  5353. readonly currentLine: string;
  5354. readonly canRead: boolean;
  5355. lines: string[];
  5356. }
  5357. }
  5358. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5359. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5360. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5361. /** @hidden */
  5362. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5363. process(preprocessors: {
  5364. [key: string]: string;
  5365. }, options: ProcessingOptions): string;
  5366. }
  5367. }
  5368. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5369. /** @hidden */
  5370. export class ShaderDefineExpression {
  5371. isTrue(preprocessors: {
  5372. [key: string]: string;
  5373. }): boolean;
  5374. }
  5375. }
  5376. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5377. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5378. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5379. /** @hidden */
  5380. export class ShaderCodeTestNode extends ShaderCodeNode {
  5381. testExpression: ShaderDefineExpression;
  5382. isValid(preprocessors: {
  5383. [key: string]: string;
  5384. }): boolean;
  5385. }
  5386. }
  5387. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5388. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5389. /** @hidden */
  5390. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5391. define: string;
  5392. not: boolean;
  5393. constructor(define: string, not?: boolean);
  5394. isTrue(preprocessors: {
  5395. [key: string]: string;
  5396. }): boolean;
  5397. }
  5398. }
  5399. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5400. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5401. /** @hidden */
  5402. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5403. leftOperand: ShaderDefineExpression;
  5404. rightOperand: ShaderDefineExpression;
  5405. isTrue(preprocessors: {
  5406. [key: string]: string;
  5407. }): boolean;
  5408. }
  5409. }
  5410. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5411. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5412. /** @hidden */
  5413. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5414. leftOperand: ShaderDefineExpression;
  5415. rightOperand: ShaderDefineExpression;
  5416. isTrue(preprocessors: {
  5417. [key: string]: string;
  5418. }): boolean;
  5419. }
  5420. }
  5421. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5422. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5423. /** @hidden */
  5424. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5425. define: string;
  5426. operand: string;
  5427. testValue: string;
  5428. constructor(define: string, operand: string, testValue: string);
  5429. isTrue(preprocessors: {
  5430. [key: string]: string;
  5431. }): boolean;
  5432. }
  5433. }
  5434. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5435. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5436. /** @hidden */
  5437. export class ShaderProcessor {
  5438. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5439. private static _ProcessPrecision;
  5440. private static _ExtractOperation;
  5441. private static _BuildSubExpression;
  5442. private static _BuildExpression;
  5443. private static _MoveCursorWithinIf;
  5444. private static _MoveCursor;
  5445. private static _EvaluatePreProcessors;
  5446. private static _PreparePreProcessors;
  5447. private static _ProcessShaderConversion;
  5448. private static _ProcessIncludes;
  5449. }
  5450. }
  5451. declare module "babylonjs/Misc/performanceMonitor" {
  5452. /**
  5453. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5454. */
  5455. export class PerformanceMonitor {
  5456. private _enabled;
  5457. private _rollingFrameTime;
  5458. private _lastFrameTimeMs;
  5459. /**
  5460. * constructor
  5461. * @param frameSampleSize The number of samples required to saturate the sliding window
  5462. */
  5463. constructor(frameSampleSize?: number);
  5464. /**
  5465. * Samples current frame
  5466. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5467. */
  5468. sampleFrame(timeMs?: number): void;
  5469. /**
  5470. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5471. */
  5472. readonly averageFrameTime: number;
  5473. /**
  5474. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5475. */
  5476. readonly averageFrameTimeVariance: number;
  5477. /**
  5478. * Returns the frame time of the most recent frame
  5479. */
  5480. readonly instantaneousFrameTime: number;
  5481. /**
  5482. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5483. */
  5484. readonly averageFPS: number;
  5485. /**
  5486. * Returns the average framerate in frames per second using the most recent frame time
  5487. */
  5488. readonly instantaneousFPS: number;
  5489. /**
  5490. * Returns true if enough samples have been taken to completely fill the sliding window
  5491. */
  5492. readonly isSaturated: boolean;
  5493. /**
  5494. * Enables contributions to the sliding window sample set
  5495. */
  5496. enable(): void;
  5497. /**
  5498. * Disables contributions to the sliding window sample set
  5499. * Samples will not be interpolated over the disabled period
  5500. */
  5501. disable(): void;
  5502. /**
  5503. * Returns true if sampling is enabled
  5504. */
  5505. readonly isEnabled: boolean;
  5506. /**
  5507. * Resets performance monitor
  5508. */
  5509. reset(): void;
  5510. }
  5511. /**
  5512. * RollingAverage
  5513. *
  5514. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5515. */
  5516. export class RollingAverage {
  5517. /**
  5518. * Current average
  5519. */
  5520. average: number;
  5521. /**
  5522. * Current variance
  5523. */
  5524. variance: number;
  5525. protected _samples: Array<number>;
  5526. protected _sampleCount: number;
  5527. protected _pos: number;
  5528. protected _m2: number;
  5529. /**
  5530. * constructor
  5531. * @param length The number of samples required to saturate the sliding window
  5532. */
  5533. constructor(length: number);
  5534. /**
  5535. * Adds a sample to the sample set
  5536. * @param v The sample value
  5537. */
  5538. add(v: number): void;
  5539. /**
  5540. * Returns previously added values or null if outside of history or outside the sliding window domain
  5541. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5542. * @return Value previously recorded with add() or null if outside of range
  5543. */
  5544. history(i: number): number;
  5545. /**
  5546. * Returns true if enough samples have been taken to completely fill the sliding window
  5547. * @return true if sample-set saturated
  5548. */
  5549. isSaturated(): boolean;
  5550. /**
  5551. * Resets the rolling average (equivalent to 0 samples taken so far)
  5552. */
  5553. reset(): void;
  5554. /**
  5555. * Wraps a value around the sample range boundaries
  5556. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5557. * @return Wrapped position in sample range
  5558. */
  5559. protected _wrapPosition(i: number): number;
  5560. }
  5561. }
  5562. declare module "babylonjs/Misc/stringDictionary" {
  5563. import { Nullable } from "babylonjs/types";
  5564. /**
  5565. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5566. * The underlying implementation relies on an associative array to ensure the best performances.
  5567. * The value can be anything including 'null' but except 'undefined'
  5568. */
  5569. export class StringDictionary<T> {
  5570. /**
  5571. * This will clear this dictionary and copy the content from the 'source' one.
  5572. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5573. * @param source the dictionary to take the content from and copy to this dictionary
  5574. */
  5575. copyFrom(source: StringDictionary<T>): void;
  5576. /**
  5577. * Get a value based from its key
  5578. * @param key the given key to get the matching value from
  5579. * @return the value if found, otherwise undefined is returned
  5580. */
  5581. get(key: string): T | undefined;
  5582. /**
  5583. * Get a value from its key or add it if it doesn't exist.
  5584. * This method will ensure you that a given key/data will be present in the dictionary.
  5585. * @param key the given key to get the matching value from
  5586. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5587. * The factory will only be invoked if there's no data for the given key.
  5588. * @return the value corresponding to the key.
  5589. */
  5590. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5591. /**
  5592. * Get a value from its key if present in the dictionary otherwise add it
  5593. * @param key the key to get the value from
  5594. * @param val if there's no such key/value pair in the dictionary add it with this value
  5595. * @return the value corresponding to the key
  5596. */
  5597. getOrAdd(key: string, val: T): T;
  5598. /**
  5599. * Check if there's a given key in the dictionary
  5600. * @param key the key to check for
  5601. * @return true if the key is present, false otherwise
  5602. */
  5603. contains(key: string): boolean;
  5604. /**
  5605. * Add a new key and its corresponding value
  5606. * @param key the key to add
  5607. * @param value the value corresponding to the key
  5608. * @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
  5609. */
  5610. add(key: string, value: T): boolean;
  5611. /**
  5612. * Update a specific value associated to a key
  5613. * @param key defines the key to use
  5614. * @param value defines the value to store
  5615. * @returns true if the value was updated (or false if the key was not found)
  5616. */
  5617. set(key: string, value: T): boolean;
  5618. /**
  5619. * Get the element of the given key and remove it from the dictionary
  5620. * @param key defines the key to search
  5621. * @returns the value associated with the key or null if not found
  5622. */
  5623. getAndRemove(key: string): Nullable<T>;
  5624. /**
  5625. * Remove a key/value from the dictionary.
  5626. * @param key the key to remove
  5627. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5628. */
  5629. remove(key: string): boolean;
  5630. /**
  5631. * Clear the whole content of the dictionary
  5632. */
  5633. clear(): void;
  5634. /**
  5635. * Gets the current count
  5636. */
  5637. readonly count: number;
  5638. /**
  5639. * Execute a callback on each key/val of the dictionary.
  5640. * Note that you can remove any element in this dictionary in the callback implementation
  5641. * @param callback the callback to execute on a given key/value pair
  5642. */
  5643. forEach(callback: (key: string, val: T) => void): void;
  5644. /**
  5645. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5646. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5647. * Note that you can remove any element in this dictionary in the callback implementation
  5648. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5649. * @returns the first item
  5650. */
  5651. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5652. private _count;
  5653. private _data;
  5654. }
  5655. }
  5656. declare module "babylonjs/Misc/promise" {
  5657. /**
  5658. * Helper class that provides a small promise polyfill
  5659. */
  5660. export class PromisePolyfill {
  5661. /**
  5662. * Static function used to check if the polyfill is required
  5663. * If this is the case then the function will inject the polyfill to window.Promise
  5664. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5665. */
  5666. static Apply(force?: boolean): void;
  5667. }
  5668. }
  5669. declare module "babylonjs/Meshes/buffer" {
  5670. import { Nullable, DataArray } from "babylonjs/types";
  5671. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5672. /**
  5673. * Class used to store data that will be store in GPU memory
  5674. */
  5675. export class Buffer {
  5676. private _engine;
  5677. private _buffer;
  5678. /** @hidden */
  5679. _data: Nullable<DataArray>;
  5680. private _updatable;
  5681. private _instanced;
  5682. /**
  5683. * Gets the byte stride.
  5684. */
  5685. readonly byteStride: number;
  5686. /**
  5687. * Constructor
  5688. * @param engine the engine
  5689. * @param data the data to use for this buffer
  5690. * @param updatable whether the data is updatable
  5691. * @param stride the stride (optional)
  5692. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5693. * @param instanced whether the buffer is instanced (optional)
  5694. * @param useBytes set to true if the stride in in bytes (optional)
  5695. */
  5696. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5697. /**
  5698. * Create a new VertexBuffer based on the current buffer
  5699. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5700. * @param offset defines offset in the buffer (0 by default)
  5701. * @param size defines the size in floats of attributes (position is 3 for instance)
  5702. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5703. * @param instanced defines if the vertex buffer contains indexed data
  5704. * @param useBytes defines if the offset and stride are in bytes
  5705. * @returns the new vertex buffer
  5706. */
  5707. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5708. /**
  5709. * Gets a boolean indicating if the Buffer is updatable?
  5710. * @returns true if the buffer is updatable
  5711. */
  5712. isUpdatable(): boolean;
  5713. /**
  5714. * Gets current buffer's data
  5715. * @returns a DataArray or null
  5716. */
  5717. getData(): Nullable<DataArray>;
  5718. /**
  5719. * Gets underlying native buffer
  5720. * @returns underlying native buffer
  5721. */
  5722. getBuffer(): Nullable<DataBuffer>;
  5723. /**
  5724. * Gets the stride in float32 units (i.e. byte stride / 4).
  5725. * May not be an integer if the byte stride is not divisible by 4.
  5726. * DEPRECATED. Use byteStride instead.
  5727. * @returns the stride in float32 units
  5728. */
  5729. getStrideSize(): number;
  5730. /**
  5731. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5732. * @param data defines the data to store
  5733. */
  5734. create(data?: Nullable<DataArray>): void;
  5735. /** @hidden */
  5736. _rebuild(): void;
  5737. /**
  5738. * Update current buffer data
  5739. * @param data defines the data to store
  5740. */
  5741. update(data: DataArray): void;
  5742. /**
  5743. * Updates the data directly.
  5744. * @param data the new data
  5745. * @param offset the new offset
  5746. * @param vertexCount the vertex count (optional)
  5747. * @param useBytes set to true if the offset is in bytes
  5748. */
  5749. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5750. /**
  5751. * Release all resources
  5752. */
  5753. dispose(): void;
  5754. }
  5755. /**
  5756. * Specialized buffer used to store vertex data
  5757. */
  5758. export class VertexBuffer {
  5759. /** @hidden */
  5760. _buffer: Buffer;
  5761. private _kind;
  5762. private _size;
  5763. private _ownsBuffer;
  5764. private _instanced;
  5765. private _instanceDivisor;
  5766. /**
  5767. * The byte type.
  5768. */
  5769. static readonly BYTE: number;
  5770. /**
  5771. * The unsigned byte type.
  5772. */
  5773. static readonly UNSIGNED_BYTE: number;
  5774. /**
  5775. * The short type.
  5776. */
  5777. static readonly SHORT: number;
  5778. /**
  5779. * The unsigned short type.
  5780. */
  5781. static readonly UNSIGNED_SHORT: number;
  5782. /**
  5783. * The integer type.
  5784. */
  5785. static readonly INT: number;
  5786. /**
  5787. * The unsigned integer type.
  5788. */
  5789. static readonly UNSIGNED_INT: number;
  5790. /**
  5791. * The float type.
  5792. */
  5793. static readonly FLOAT: number;
  5794. /**
  5795. * Gets or sets the instance divisor when in instanced mode
  5796. */
  5797. instanceDivisor: number;
  5798. /**
  5799. * Gets the byte stride.
  5800. */
  5801. readonly byteStride: number;
  5802. /**
  5803. * Gets the byte offset.
  5804. */
  5805. readonly byteOffset: number;
  5806. /**
  5807. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5808. */
  5809. readonly normalized: boolean;
  5810. /**
  5811. * Gets the data type of each component in the array.
  5812. */
  5813. readonly type: number;
  5814. /**
  5815. * Constructor
  5816. * @param engine the engine
  5817. * @param data the data to use for this vertex buffer
  5818. * @param kind the vertex buffer kind
  5819. * @param updatable whether the data is updatable
  5820. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5821. * @param stride the stride (optional)
  5822. * @param instanced whether the buffer is instanced (optional)
  5823. * @param offset the offset of the data (optional)
  5824. * @param size the number of components (optional)
  5825. * @param type the type of the component (optional)
  5826. * @param normalized whether the data contains normalized data (optional)
  5827. * @param useBytes set to true if stride and offset are in bytes (optional)
  5828. */
  5829. 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);
  5830. /** @hidden */
  5831. _rebuild(): void;
  5832. /**
  5833. * Returns the kind of the VertexBuffer (string)
  5834. * @returns a string
  5835. */
  5836. getKind(): string;
  5837. /**
  5838. * Gets a boolean indicating if the VertexBuffer is updatable?
  5839. * @returns true if the buffer is updatable
  5840. */
  5841. isUpdatable(): boolean;
  5842. /**
  5843. * Gets current buffer's data
  5844. * @returns a DataArray or null
  5845. */
  5846. getData(): Nullable<DataArray>;
  5847. /**
  5848. * Gets underlying native buffer
  5849. * @returns underlying native buffer
  5850. */
  5851. getBuffer(): Nullable<DataBuffer>;
  5852. /**
  5853. * Gets the stride in float32 units (i.e. byte stride / 4).
  5854. * May not be an integer if the byte stride is not divisible by 4.
  5855. * DEPRECATED. Use byteStride instead.
  5856. * @returns the stride in float32 units
  5857. */
  5858. getStrideSize(): number;
  5859. /**
  5860. * Returns the offset as a multiple of the type byte length.
  5861. * DEPRECATED. Use byteOffset instead.
  5862. * @returns the offset in bytes
  5863. */
  5864. getOffset(): number;
  5865. /**
  5866. * Returns the number of components per vertex attribute (integer)
  5867. * @returns the size in float
  5868. */
  5869. getSize(): number;
  5870. /**
  5871. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5872. * @returns true if this buffer is instanced
  5873. */
  5874. getIsInstanced(): boolean;
  5875. /**
  5876. * Returns the instancing divisor, zero for non-instanced (integer).
  5877. * @returns a number
  5878. */
  5879. getInstanceDivisor(): number;
  5880. /**
  5881. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5882. * @param data defines the data to store
  5883. */
  5884. create(data?: DataArray): void;
  5885. /**
  5886. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5887. * This function will create a new buffer if the current one is not updatable
  5888. * @param data defines the data to store
  5889. */
  5890. update(data: DataArray): void;
  5891. /**
  5892. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5893. * Returns the directly updated WebGLBuffer.
  5894. * @param data the new data
  5895. * @param offset the new offset
  5896. * @param useBytes set to true if the offset is in bytes
  5897. */
  5898. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5899. /**
  5900. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5901. */
  5902. dispose(): void;
  5903. /**
  5904. * Enumerates each value of this vertex buffer as numbers.
  5905. * @param count the number of values to enumerate
  5906. * @param callback the callback function called for each value
  5907. */
  5908. forEach(count: number, callback: (value: number, index: number) => void): void;
  5909. /**
  5910. * Positions
  5911. */
  5912. static readonly PositionKind: string;
  5913. /**
  5914. * Normals
  5915. */
  5916. static readonly NormalKind: string;
  5917. /**
  5918. * Tangents
  5919. */
  5920. static readonly TangentKind: string;
  5921. /**
  5922. * Texture coordinates
  5923. */
  5924. static readonly UVKind: string;
  5925. /**
  5926. * Texture coordinates 2
  5927. */
  5928. static readonly UV2Kind: string;
  5929. /**
  5930. * Texture coordinates 3
  5931. */
  5932. static readonly UV3Kind: string;
  5933. /**
  5934. * Texture coordinates 4
  5935. */
  5936. static readonly UV4Kind: string;
  5937. /**
  5938. * Texture coordinates 5
  5939. */
  5940. static readonly UV5Kind: string;
  5941. /**
  5942. * Texture coordinates 6
  5943. */
  5944. static readonly UV6Kind: string;
  5945. /**
  5946. * Colors
  5947. */
  5948. static readonly ColorKind: string;
  5949. /**
  5950. * Matrix indices (for bones)
  5951. */
  5952. static readonly MatricesIndicesKind: string;
  5953. /**
  5954. * Matrix weights (for bones)
  5955. */
  5956. static readonly MatricesWeightsKind: string;
  5957. /**
  5958. * Additional matrix indices (for bones)
  5959. */
  5960. static readonly MatricesIndicesExtraKind: string;
  5961. /**
  5962. * Additional matrix weights (for bones)
  5963. */
  5964. static readonly MatricesWeightsExtraKind: string;
  5965. /**
  5966. * Deduces the stride given a kind.
  5967. * @param kind The kind string to deduce
  5968. * @returns The deduced stride
  5969. */
  5970. static DeduceStride(kind: string): number;
  5971. /**
  5972. * Gets the byte length of the given type.
  5973. * @param type the type
  5974. * @returns the number of bytes
  5975. */
  5976. static GetTypeByteLength(type: number): number;
  5977. /**
  5978. * Enumerates each value of the given parameters as numbers.
  5979. * @param data the data to enumerate
  5980. * @param byteOffset the byte offset of the data
  5981. * @param byteStride the byte stride of the data
  5982. * @param componentCount the number of components per element
  5983. * @param componentType the type of the component
  5984. * @param count the number of values to enumerate
  5985. * @param normalized whether the data is normalized
  5986. * @param callback the callback function called for each value
  5987. */
  5988. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5989. private static _GetFloatValue;
  5990. }
  5991. }
  5992. declare module "babylonjs/Maths/sphericalPolynomial" {
  5993. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5994. /**
  5995. * Class representing spherical harmonics coefficients to the 3rd degree
  5996. */
  5997. export class SphericalHarmonics {
  5998. /**
  5999. * Defines whether or not the harmonics have been prescaled for rendering.
  6000. */
  6001. preScaled: boolean;
  6002. /**
  6003. * The l0,0 coefficients of the spherical harmonics
  6004. */
  6005. l00: Vector3;
  6006. /**
  6007. * The l1,-1 coefficients of the spherical harmonics
  6008. */
  6009. l1_1: Vector3;
  6010. /**
  6011. * The l1,0 coefficients of the spherical harmonics
  6012. */
  6013. l10: Vector3;
  6014. /**
  6015. * The l1,1 coefficients of the spherical harmonics
  6016. */
  6017. l11: Vector3;
  6018. /**
  6019. * The l2,-2 coefficients of the spherical harmonics
  6020. */
  6021. l2_2: Vector3;
  6022. /**
  6023. * The l2,-1 coefficients of the spherical harmonics
  6024. */
  6025. l2_1: Vector3;
  6026. /**
  6027. * The l2,0 coefficients of the spherical harmonics
  6028. */
  6029. l20: Vector3;
  6030. /**
  6031. * The l2,1 coefficients of the spherical harmonics
  6032. */
  6033. l21: Vector3;
  6034. /**
  6035. * The l2,2 coefficients of the spherical harmonics
  6036. */
  6037. l22: Vector3;
  6038. /**
  6039. * Adds a light to the spherical harmonics
  6040. * @param direction the direction of the light
  6041. * @param color the color of the light
  6042. * @param deltaSolidAngle the delta solid angle of the light
  6043. */
  6044. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6045. /**
  6046. * Scales the spherical harmonics by the given amount
  6047. * @param scale the amount to scale
  6048. */
  6049. scaleInPlace(scale: number): void;
  6050. /**
  6051. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6052. *
  6053. * ```
  6054. * E_lm = A_l * L_lm
  6055. * ```
  6056. *
  6057. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6058. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6059. * the scaling factors are given in equation 9.
  6060. */
  6061. convertIncidentRadianceToIrradiance(): void;
  6062. /**
  6063. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6064. *
  6065. * ```
  6066. * L = (1/pi) * E * rho
  6067. * ```
  6068. *
  6069. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6070. */
  6071. convertIrradianceToLambertianRadiance(): void;
  6072. /**
  6073. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6074. * required operations at run time.
  6075. *
  6076. * This is simply done by scaling back the SH with Ylm constants parameter.
  6077. * The trigonometric part being applied by the shader at run time.
  6078. */
  6079. preScaleForRendering(): void;
  6080. /**
  6081. * Constructs a spherical harmonics from an array.
  6082. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6083. * @returns the spherical harmonics
  6084. */
  6085. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6086. /**
  6087. * Gets the spherical harmonics from polynomial
  6088. * @param polynomial the spherical polynomial
  6089. * @returns the spherical harmonics
  6090. */
  6091. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6092. }
  6093. /**
  6094. * Class representing spherical polynomial coefficients to the 3rd degree
  6095. */
  6096. export class SphericalPolynomial {
  6097. private _harmonics;
  6098. /**
  6099. * The spherical harmonics used to create the polynomials.
  6100. */
  6101. readonly preScaledHarmonics: SphericalHarmonics;
  6102. /**
  6103. * The x coefficients of the spherical polynomial
  6104. */
  6105. x: Vector3;
  6106. /**
  6107. * The y coefficients of the spherical polynomial
  6108. */
  6109. y: Vector3;
  6110. /**
  6111. * The z coefficients of the spherical polynomial
  6112. */
  6113. z: Vector3;
  6114. /**
  6115. * The xx coefficients of the spherical polynomial
  6116. */
  6117. xx: Vector3;
  6118. /**
  6119. * The yy coefficients of the spherical polynomial
  6120. */
  6121. yy: Vector3;
  6122. /**
  6123. * The zz coefficients of the spherical polynomial
  6124. */
  6125. zz: Vector3;
  6126. /**
  6127. * The xy coefficients of the spherical polynomial
  6128. */
  6129. xy: Vector3;
  6130. /**
  6131. * The yz coefficients of the spherical polynomial
  6132. */
  6133. yz: Vector3;
  6134. /**
  6135. * The zx coefficients of the spherical polynomial
  6136. */
  6137. zx: Vector3;
  6138. /**
  6139. * Adds an ambient color to the spherical polynomial
  6140. * @param color the color to add
  6141. */
  6142. addAmbient(color: Color3): void;
  6143. /**
  6144. * Scales the spherical polynomial by the given amount
  6145. * @param scale the amount to scale
  6146. */
  6147. scaleInPlace(scale: number): void;
  6148. /**
  6149. * Gets the spherical polynomial from harmonics
  6150. * @param harmonics the spherical harmonics
  6151. * @returns the spherical polynomial
  6152. */
  6153. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6154. /**
  6155. * Constructs a spherical polynomial from an array.
  6156. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6157. * @returns the spherical polynomial
  6158. */
  6159. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6160. }
  6161. }
  6162. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6163. import { Nullable } from "babylonjs/types";
  6164. /**
  6165. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6166. */
  6167. export interface CubeMapInfo {
  6168. /**
  6169. * The pixel array for the front face.
  6170. * This is stored in format, left to right, up to down format.
  6171. */
  6172. front: Nullable<ArrayBufferView>;
  6173. /**
  6174. * The pixel array for the back face.
  6175. * This is stored in format, left to right, up to down format.
  6176. */
  6177. back: Nullable<ArrayBufferView>;
  6178. /**
  6179. * The pixel array for the left face.
  6180. * This is stored in format, left to right, up to down format.
  6181. */
  6182. left: Nullable<ArrayBufferView>;
  6183. /**
  6184. * The pixel array for the right face.
  6185. * This is stored in format, left to right, up to down format.
  6186. */
  6187. right: Nullable<ArrayBufferView>;
  6188. /**
  6189. * The pixel array for the up face.
  6190. * This is stored in format, left to right, up to down format.
  6191. */
  6192. up: Nullable<ArrayBufferView>;
  6193. /**
  6194. * The pixel array for the down face.
  6195. * This is stored in format, left to right, up to down format.
  6196. */
  6197. down: Nullable<ArrayBufferView>;
  6198. /**
  6199. * The size of the cubemap stored.
  6200. *
  6201. * Each faces will be size * size pixels.
  6202. */
  6203. size: number;
  6204. /**
  6205. * The format of the texture.
  6206. *
  6207. * RGBA, RGB.
  6208. */
  6209. format: number;
  6210. /**
  6211. * The type of the texture data.
  6212. *
  6213. * UNSIGNED_INT, FLOAT.
  6214. */
  6215. type: number;
  6216. /**
  6217. * Specifies whether the texture is in gamma space.
  6218. */
  6219. gammaSpace: boolean;
  6220. }
  6221. /**
  6222. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6223. */
  6224. export class PanoramaToCubeMapTools {
  6225. private static FACE_FRONT;
  6226. private static FACE_BACK;
  6227. private static FACE_RIGHT;
  6228. private static FACE_LEFT;
  6229. private static FACE_DOWN;
  6230. private static FACE_UP;
  6231. /**
  6232. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6233. *
  6234. * @param float32Array The source data.
  6235. * @param inputWidth The width of the input panorama.
  6236. * @param inputHeight The height of the input panorama.
  6237. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6238. * @return The cubemap data
  6239. */
  6240. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6241. private static CreateCubemapTexture;
  6242. private static CalcProjectionSpherical;
  6243. }
  6244. }
  6245. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6246. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6248. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6249. /**
  6250. * Helper class dealing with the extraction of spherical polynomial dataArray
  6251. * from a cube map.
  6252. */
  6253. export class CubeMapToSphericalPolynomialTools {
  6254. private static FileFaces;
  6255. /**
  6256. * Converts a texture to the according Spherical Polynomial data.
  6257. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6258. *
  6259. * @param texture The texture to extract the information from.
  6260. * @return The Spherical Polynomial data.
  6261. */
  6262. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6263. /**
  6264. * Converts a cubemap to the according Spherical Polynomial data.
  6265. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6266. *
  6267. * @param cubeInfo The Cube map to extract the information from.
  6268. * @return The Spherical Polynomial data.
  6269. */
  6270. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6271. }
  6272. }
  6273. declare module "babylonjs/Engines/engineStore" {
  6274. import { Nullable } from "babylonjs/types";
  6275. import { Engine } from "babylonjs/Engines/engine";
  6276. import { Scene } from "babylonjs/scene";
  6277. /**
  6278. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6279. * during the life time of the application.
  6280. */
  6281. export class EngineStore {
  6282. /** Gets the list of created engines */
  6283. static Instances: import("babylonjs/Engines/engine").Engine[];
  6284. /** @hidden */
  6285. static _LastCreatedScene: Nullable<Scene>;
  6286. /**
  6287. * Gets the latest created engine
  6288. */
  6289. static readonly LastCreatedEngine: Nullable<Engine>;
  6290. /**
  6291. * Gets the latest created scene
  6292. */
  6293. static readonly LastCreatedScene: Nullable<Scene>;
  6294. }
  6295. }
  6296. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6297. /**
  6298. * Define options used to create a render target texture
  6299. */
  6300. export class RenderTargetCreationOptions {
  6301. /**
  6302. * Specifies is mipmaps must be generated
  6303. */
  6304. generateMipMaps?: boolean;
  6305. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6306. generateDepthBuffer?: boolean;
  6307. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6308. generateStencilBuffer?: boolean;
  6309. /** Defines texture type (int by default) */
  6310. type?: number;
  6311. /** Defines sampling mode (trilinear by default) */
  6312. samplingMode?: number;
  6313. /** Defines format (RGBA by default) */
  6314. format?: number;
  6315. }
  6316. }
  6317. declare module "babylonjs/States/alphaCullingState" {
  6318. /**
  6319. * @hidden
  6320. **/
  6321. export class _AlphaState {
  6322. private _isAlphaBlendDirty;
  6323. private _isBlendFunctionParametersDirty;
  6324. private _isBlendEquationParametersDirty;
  6325. private _isBlendConstantsDirty;
  6326. private _alphaBlend;
  6327. private _blendFunctionParameters;
  6328. private _blendEquationParameters;
  6329. private _blendConstants;
  6330. /**
  6331. * Initializes the state.
  6332. */
  6333. constructor();
  6334. readonly isDirty: boolean;
  6335. alphaBlend: boolean;
  6336. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6337. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6338. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6339. reset(): void;
  6340. apply(gl: WebGLRenderingContext): void;
  6341. }
  6342. }
  6343. declare module "babylonjs/States/depthCullingState" {
  6344. import { Nullable } from "babylonjs/types";
  6345. /**
  6346. * @hidden
  6347. **/
  6348. export class _DepthCullingState {
  6349. private _isDepthTestDirty;
  6350. private _isDepthMaskDirty;
  6351. private _isDepthFuncDirty;
  6352. private _isCullFaceDirty;
  6353. private _isCullDirty;
  6354. private _isZOffsetDirty;
  6355. private _isFrontFaceDirty;
  6356. private _depthTest;
  6357. private _depthMask;
  6358. private _depthFunc;
  6359. private _cull;
  6360. private _cullFace;
  6361. private _zOffset;
  6362. private _frontFace;
  6363. /**
  6364. * Initializes the state.
  6365. */
  6366. constructor();
  6367. readonly isDirty: boolean;
  6368. zOffset: number;
  6369. cullFace: Nullable<number>;
  6370. cull: Nullable<boolean>;
  6371. depthFunc: Nullable<number>;
  6372. depthMask: boolean;
  6373. depthTest: boolean;
  6374. frontFace: Nullable<number>;
  6375. reset(): void;
  6376. apply(gl: WebGLRenderingContext): void;
  6377. }
  6378. }
  6379. declare module "babylonjs/States/stencilState" {
  6380. /**
  6381. * @hidden
  6382. **/
  6383. export class _StencilState {
  6384. /** 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 */
  6385. static readonly ALWAYS: number;
  6386. /** Passed to stencilOperation to specify that stencil value must be kept */
  6387. static readonly KEEP: number;
  6388. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6389. static readonly REPLACE: number;
  6390. private _isStencilTestDirty;
  6391. private _isStencilMaskDirty;
  6392. private _isStencilFuncDirty;
  6393. private _isStencilOpDirty;
  6394. private _stencilTest;
  6395. private _stencilMask;
  6396. private _stencilFunc;
  6397. private _stencilFuncRef;
  6398. private _stencilFuncMask;
  6399. private _stencilOpStencilFail;
  6400. private _stencilOpDepthFail;
  6401. private _stencilOpStencilDepthPass;
  6402. readonly isDirty: boolean;
  6403. stencilFunc: number;
  6404. stencilFuncRef: number;
  6405. stencilFuncMask: number;
  6406. stencilOpStencilFail: number;
  6407. stencilOpDepthFail: number;
  6408. stencilOpStencilDepthPass: number;
  6409. stencilMask: number;
  6410. stencilTest: boolean;
  6411. constructor();
  6412. reset(): void;
  6413. apply(gl: WebGLRenderingContext): void;
  6414. }
  6415. }
  6416. declare module "babylonjs/States/index" {
  6417. export * from "babylonjs/States/alphaCullingState";
  6418. export * from "babylonjs/States/depthCullingState";
  6419. export * from "babylonjs/States/stencilState";
  6420. }
  6421. declare module "babylonjs/Instrumentation/timeToken" {
  6422. import { Nullable } from "babylonjs/types";
  6423. /**
  6424. * @hidden
  6425. **/
  6426. export class _TimeToken {
  6427. _startTimeQuery: Nullable<WebGLQuery>;
  6428. _endTimeQuery: Nullable<WebGLQuery>;
  6429. _timeElapsedQuery: Nullable<WebGLQuery>;
  6430. _timeElapsedQueryEnded: boolean;
  6431. }
  6432. }
  6433. declare module "babylonjs/Materials/Textures/internalTexture" {
  6434. import { Observable } from "babylonjs/Misc/observable";
  6435. import { Nullable, int } from "babylonjs/types";
  6436. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6437. import { Engine } from "babylonjs/Engines/engine";
  6438. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6439. /**
  6440. * Class used to store data associated with WebGL texture data for the engine
  6441. * This class should not be used directly
  6442. */
  6443. export class InternalTexture {
  6444. /** @hidden */
  6445. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6446. /**
  6447. * The source of the texture data is unknown
  6448. */
  6449. static DATASOURCE_UNKNOWN: number;
  6450. /**
  6451. * Texture data comes from an URL
  6452. */
  6453. static DATASOURCE_URL: number;
  6454. /**
  6455. * Texture data is only used for temporary storage
  6456. */
  6457. static DATASOURCE_TEMP: number;
  6458. /**
  6459. * Texture data comes from raw data (ArrayBuffer)
  6460. */
  6461. static DATASOURCE_RAW: number;
  6462. /**
  6463. * Texture content is dynamic (video or dynamic texture)
  6464. */
  6465. static DATASOURCE_DYNAMIC: number;
  6466. /**
  6467. * Texture content is generated by rendering to it
  6468. */
  6469. static DATASOURCE_RENDERTARGET: number;
  6470. /**
  6471. * Texture content is part of a multi render target process
  6472. */
  6473. static DATASOURCE_MULTIRENDERTARGET: number;
  6474. /**
  6475. * Texture data comes from a cube data file
  6476. */
  6477. static DATASOURCE_CUBE: number;
  6478. /**
  6479. * Texture data comes from a raw cube data
  6480. */
  6481. static DATASOURCE_CUBERAW: number;
  6482. /**
  6483. * Texture data come from a prefiltered cube data file
  6484. */
  6485. static DATASOURCE_CUBEPREFILTERED: number;
  6486. /**
  6487. * Texture content is raw 3D data
  6488. */
  6489. static DATASOURCE_RAW3D: number;
  6490. /**
  6491. * Texture content is a depth texture
  6492. */
  6493. static DATASOURCE_DEPTHTEXTURE: number;
  6494. /**
  6495. * Texture data comes from a raw cube data encoded with RGBD
  6496. */
  6497. static DATASOURCE_CUBERAW_RGBD: number;
  6498. /**
  6499. * Defines if the texture is ready
  6500. */
  6501. isReady: boolean;
  6502. /**
  6503. * Defines if the texture is a cube texture
  6504. */
  6505. isCube: boolean;
  6506. /**
  6507. * Defines if the texture contains 3D data
  6508. */
  6509. is3D: boolean;
  6510. /**
  6511. * Defines if the texture contains multiview data
  6512. */
  6513. isMultiview: boolean;
  6514. /**
  6515. * Gets the URL used to load this texture
  6516. */
  6517. url: string;
  6518. /**
  6519. * Gets the sampling mode of the texture
  6520. */
  6521. samplingMode: number;
  6522. /**
  6523. * Gets a boolean indicating if the texture needs mipmaps generation
  6524. */
  6525. generateMipMaps: boolean;
  6526. /**
  6527. * Gets the number of samples used by the texture (WebGL2+ only)
  6528. */
  6529. samples: number;
  6530. /**
  6531. * Gets the type of the texture (int, float...)
  6532. */
  6533. type: number;
  6534. /**
  6535. * Gets the format of the texture (RGB, RGBA...)
  6536. */
  6537. format: number;
  6538. /**
  6539. * Observable called when the texture is loaded
  6540. */
  6541. onLoadedObservable: Observable<InternalTexture>;
  6542. /**
  6543. * Gets the width of the texture
  6544. */
  6545. width: number;
  6546. /**
  6547. * Gets the height of the texture
  6548. */
  6549. height: number;
  6550. /**
  6551. * Gets the depth of the texture
  6552. */
  6553. depth: number;
  6554. /**
  6555. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6556. */
  6557. baseWidth: number;
  6558. /**
  6559. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6560. */
  6561. baseHeight: number;
  6562. /**
  6563. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6564. */
  6565. baseDepth: number;
  6566. /**
  6567. * Gets a boolean indicating if the texture is inverted on Y axis
  6568. */
  6569. invertY: boolean;
  6570. /** @hidden */
  6571. _invertVScale: boolean;
  6572. /** @hidden */
  6573. _associatedChannel: number;
  6574. /** @hidden */
  6575. _dataSource: number;
  6576. /** @hidden */
  6577. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6578. /** @hidden */
  6579. _bufferView: Nullable<ArrayBufferView>;
  6580. /** @hidden */
  6581. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6582. /** @hidden */
  6583. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6584. /** @hidden */
  6585. _size: number;
  6586. /** @hidden */
  6587. _extension: string;
  6588. /** @hidden */
  6589. _files: Nullable<string[]>;
  6590. /** @hidden */
  6591. _workingCanvas: Nullable<HTMLCanvasElement>;
  6592. /** @hidden */
  6593. _workingContext: Nullable<CanvasRenderingContext2D>;
  6594. /** @hidden */
  6595. _framebuffer: Nullable<WebGLFramebuffer>;
  6596. /** @hidden */
  6597. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6598. /** @hidden */
  6599. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6600. /** @hidden */
  6601. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6602. /** @hidden */
  6603. _attachments: Nullable<number[]>;
  6604. /** @hidden */
  6605. _cachedCoordinatesMode: Nullable<number>;
  6606. /** @hidden */
  6607. _cachedWrapU: Nullable<number>;
  6608. /** @hidden */
  6609. _cachedWrapV: Nullable<number>;
  6610. /** @hidden */
  6611. _cachedWrapR: Nullable<number>;
  6612. /** @hidden */
  6613. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6614. /** @hidden */
  6615. _isDisabled: boolean;
  6616. /** @hidden */
  6617. _compression: Nullable<string>;
  6618. /** @hidden */
  6619. _generateStencilBuffer: boolean;
  6620. /** @hidden */
  6621. _generateDepthBuffer: boolean;
  6622. /** @hidden */
  6623. _comparisonFunction: number;
  6624. /** @hidden */
  6625. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6626. /** @hidden */
  6627. _lodGenerationScale: number;
  6628. /** @hidden */
  6629. _lodGenerationOffset: number;
  6630. /** @hidden */
  6631. _colorTextureArray: Nullable<WebGLTexture>;
  6632. /** @hidden */
  6633. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6634. /** @hidden */
  6635. _lodTextureHigh: Nullable<BaseTexture>;
  6636. /** @hidden */
  6637. _lodTextureMid: Nullable<BaseTexture>;
  6638. /** @hidden */
  6639. _lodTextureLow: Nullable<BaseTexture>;
  6640. /** @hidden */
  6641. _isRGBD: boolean;
  6642. /** @hidden */
  6643. _linearSpecularLOD: boolean;
  6644. /** @hidden */
  6645. _irradianceTexture: Nullable<BaseTexture>;
  6646. /** @hidden */
  6647. _webGLTexture: Nullable<WebGLTexture>;
  6648. /** @hidden */
  6649. _references: number;
  6650. private _engine;
  6651. /**
  6652. * Gets the Engine the texture belongs to.
  6653. * @returns The babylon engine
  6654. */
  6655. getEngine(): Engine;
  6656. /**
  6657. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6658. */
  6659. readonly dataSource: number;
  6660. /**
  6661. * Creates a new InternalTexture
  6662. * @param engine defines the engine to use
  6663. * @param dataSource defines the type of data that will be used
  6664. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6665. */
  6666. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6667. /**
  6668. * Increments the number of references (ie. the number of Texture that point to it)
  6669. */
  6670. incrementReferences(): void;
  6671. /**
  6672. * Change the size of the texture (not the size of the content)
  6673. * @param width defines the new width
  6674. * @param height defines the new height
  6675. * @param depth defines the new depth (1 by default)
  6676. */
  6677. updateSize(width: int, height: int, depth?: int): void;
  6678. /** @hidden */
  6679. _rebuild(): void;
  6680. /** @hidden */
  6681. _swapAndDie(target: InternalTexture): void;
  6682. /**
  6683. * Dispose the current allocated resources
  6684. */
  6685. dispose(): void;
  6686. }
  6687. }
  6688. declare module "babylonjs/Animations/easing" {
  6689. /**
  6690. * This represents the main contract an easing function should follow.
  6691. * Easing functions are used throughout the animation system.
  6692. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6693. */
  6694. export interface IEasingFunction {
  6695. /**
  6696. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6697. * of the easing function.
  6698. * The link below provides some of the most common examples of easing functions.
  6699. * @see https://easings.net/
  6700. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6701. * @returns the corresponding value on the curve defined by the easing function
  6702. */
  6703. ease(gradient: number): number;
  6704. }
  6705. /**
  6706. * Base class used for every default easing function.
  6707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6708. */
  6709. export class EasingFunction implements IEasingFunction {
  6710. /**
  6711. * Interpolation follows the mathematical formula associated with the easing function.
  6712. */
  6713. static readonly EASINGMODE_EASEIN: number;
  6714. /**
  6715. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6716. */
  6717. static readonly EASINGMODE_EASEOUT: number;
  6718. /**
  6719. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6720. */
  6721. static readonly EASINGMODE_EASEINOUT: number;
  6722. private _easingMode;
  6723. /**
  6724. * Sets the easing mode of the current function.
  6725. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6726. */
  6727. setEasingMode(easingMode: number): void;
  6728. /**
  6729. * Gets the current easing mode.
  6730. * @returns the easing mode
  6731. */
  6732. getEasingMode(): number;
  6733. /**
  6734. * @hidden
  6735. */
  6736. easeInCore(gradient: number): number;
  6737. /**
  6738. * Given an input gradient between 0 and 1, this returns the corresponding value
  6739. * of the easing function.
  6740. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6741. * @returns the corresponding value on the curve defined by the easing function
  6742. */
  6743. ease(gradient: number): number;
  6744. }
  6745. /**
  6746. * Easing function with a circle shape (see link below).
  6747. * @see https://easings.net/#easeInCirc
  6748. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6749. */
  6750. export class CircleEase extends EasingFunction implements IEasingFunction {
  6751. /** @hidden */
  6752. easeInCore(gradient: number): number;
  6753. }
  6754. /**
  6755. * Easing function with a ease back shape (see link below).
  6756. * @see https://easings.net/#easeInBack
  6757. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6758. */
  6759. export class BackEase extends EasingFunction implements IEasingFunction {
  6760. /** Defines the amplitude of the function */
  6761. amplitude: number;
  6762. /**
  6763. * Instantiates a back ease easing
  6764. * @see https://easings.net/#easeInBack
  6765. * @param amplitude Defines the amplitude of the function
  6766. */
  6767. constructor(
  6768. /** Defines the amplitude of the function */
  6769. amplitude?: number);
  6770. /** @hidden */
  6771. easeInCore(gradient: number): number;
  6772. }
  6773. /**
  6774. * Easing function with a bouncing shape (see link below).
  6775. * @see https://easings.net/#easeInBounce
  6776. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6777. */
  6778. export class BounceEase extends EasingFunction implements IEasingFunction {
  6779. /** Defines the number of bounces */
  6780. bounces: number;
  6781. /** Defines the amplitude of the bounce */
  6782. bounciness: number;
  6783. /**
  6784. * Instantiates a bounce easing
  6785. * @see https://easings.net/#easeInBounce
  6786. * @param bounces Defines the number of bounces
  6787. * @param bounciness Defines the amplitude of the bounce
  6788. */
  6789. constructor(
  6790. /** Defines the number of bounces */
  6791. bounces?: number,
  6792. /** Defines the amplitude of the bounce */
  6793. bounciness?: number);
  6794. /** @hidden */
  6795. easeInCore(gradient: number): number;
  6796. }
  6797. /**
  6798. * Easing function with a power of 3 shape (see link below).
  6799. * @see https://easings.net/#easeInCubic
  6800. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6801. */
  6802. export class CubicEase extends EasingFunction implements IEasingFunction {
  6803. /** @hidden */
  6804. easeInCore(gradient: number): number;
  6805. }
  6806. /**
  6807. * Easing function with an elastic shape (see link below).
  6808. * @see https://easings.net/#easeInElastic
  6809. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6810. */
  6811. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6812. /** Defines the number of oscillations*/
  6813. oscillations: number;
  6814. /** Defines the amplitude of the oscillations*/
  6815. springiness: number;
  6816. /**
  6817. * Instantiates an elastic easing function
  6818. * @see https://easings.net/#easeInElastic
  6819. * @param oscillations Defines the number of oscillations
  6820. * @param springiness Defines the amplitude of the oscillations
  6821. */
  6822. constructor(
  6823. /** Defines the number of oscillations*/
  6824. oscillations?: number,
  6825. /** Defines the amplitude of the oscillations*/
  6826. springiness?: number);
  6827. /** @hidden */
  6828. easeInCore(gradient: number): number;
  6829. }
  6830. /**
  6831. * Easing function with an exponential shape (see link below).
  6832. * @see https://easings.net/#easeInExpo
  6833. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6834. */
  6835. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6836. /** Defines the exponent of the function */
  6837. exponent: number;
  6838. /**
  6839. * Instantiates an exponential easing function
  6840. * @see https://easings.net/#easeInExpo
  6841. * @param exponent Defines the exponent of the function
  6842. */
  6843. constructor(
  6844. /** Defines the exponent of the function */
  6845. exponent?: number);
  6846. /** @hidden */
  6847. easeInCore(gradient: number): number;
  6848. }
  6849. /**
  6850. * Easing function with a power shape (see link below).
  6851. * @see https://easings.net/#easeInQuad
  6852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6853. */
  6854. export class PowerEase extends EasingFunction implements IEasingFunction {
  6855. /** Defines the power of the function */
  6856. power: number;
  6857. /**
  6858. * Instantiates an power base easing function
  6859. * @see https://easings.net/#easeInQuad
  6860. * @param power Defines the power of the function
  6861. */
  6862. constructor(
  6863. /** Defines the power of the function */
  6864. power?: number);
  6865. /** @hidden */
  6866. easeInCore(gradient: number): number;
  6867. }
  6868. /**
  6869. * Easing function with a power of 2 shape (see link below).
  6870. * @see https://easings.net/#easeInQuad
  6871. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6872. */
  6873. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6874. /** @hidden */
  6875. easeInCore(gradient: number): number;
  6876. }
  6877. /**
  6878. * Easing function with a power of 4 shape (see link below).
  6879. * @see https://easings.net/#easeInQuart
  6880. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6881. */
  6882. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6883. /** @hidden */
  6884. easeInCore(gradient: number): number;
  6885. }
  6886. /**
  6887. * Easing function with a power of 5 shape (see link below).
  6888. * @see https://easings.net/#easeInQuint
  6889. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6890. */
  6891. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6892. /** @hidden */
  6893. easeInCore(gradient: number): number;
  6894. }
  6895. /**
  6896. * Easing function with a sin shape (see link below).
  6897. * @see https://easings.net/#easeInSine
  6898. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6899. */
  6900. export class SineEase extends EasingFunction implements IEasingFunction {
  6901. /** @hidden */
  6902. easeInCore(gradient: number): number;
  6903. }
  6904. /**
  6905. * Easing function with a bezier shape (see link below).
  6906. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6907. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6908. */
  6909. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6910. /** Defines the x component of the start tangent in the bezier curve */
  6911. x1: number;
  6912. /** Defines the y component of the start tangent in the bezier curve */
  6913. y1: number;
  6914. /** Defines the x component of the end tangent in the bezier curve */
  6915. x2: number;
  6916. /** Defines the y component of the end tangent in the bezier curve */
  6917. y2: number;
  6918. /**
  6919. * Instantiates a bezier function
  6920. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6921. * @param x1 Defines the x component of the start tangent in the bezier curve
  6922. * @param y1 Defines the y component of the start tangent in the bezier curve
  6923. * @param x2 Defines the x component of the end tangent in the bezier curve
  6924. * @param y2 Defines the y component of the end tangent in the bezier curve
  6925. */
  6926. constructor(
  6927. /** Defines the x component of the start tangent in the bezier curve */
  6928. x1?: number,
  6929. /** Defines the y component of the start tangent in the bezier curve */
  6930. y1?: number,
  6931. /** Defines the x component of the end tangent in the bezier curve */
  6932. x2?: number,
  6933. /** Defines the y component of the end tangent in the bezier curve */
  6934. y2?: number);
  6935. /** @hidden */
  6936. easeInCore(gradient: number): number;
  6937. }
  6938. }
  6939. declare module "babylonjs/Animations/animationKey" {
  6940. /**
  6941. * Defines an interface which represents an animation key frame
  6942. */
  6943. export interface IAnimationKey {
  6944. /**
  6945. * Frame of the key frame
  6946. */
  6947. frame: number;
  6948. /**
  6949. * Value at the specifies key frame
  6950. */
  6951. value: any;
  6952. /**
  6953. * The input tangent for the cubic hermite spline
  6954. */
  6955. inTangent?: any;
  6956. /**
  6957. * The output tangent for the cubic hermite spline
  6958. */
  6959. outTangent?: any;
  6960. /**
  6961. * The animation interpolation type
  6962. */
  6963. interpolation?: AnimationKeyInterpolation;
  6964. }
  6965. /**
  6966. * Enum for the animation key frame interpolation type
  6967. */
  6968. export enum AnimationKeyInterpolation {
  6969. /**
  6970. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6971. */
  6972. STEP = 1
  6973. }
  6974. }
  6975. declare module "babylonjs/Animations/animationRange" {
  6976. /**
  6977. * Represents the range of an animation
  6978. */
  6979. export class AnimationRange {
  6980. /**The name of the animation range**/
  6981. name: string;
  6982. /**The starting frame of the animation */
  6983. from: number;
  6984. /**The ending frame of the animation*/
  6985. to: number;
  6986. /**
  6987. * Initializes the range of an animation
  6988. * @param name The name of the animation range
  6989. * @param from The starting frame of the animation
  6990. * @param to The ending frame of the animation
  6991. */
  6992. constructor(
  6993. /**The name of the animation range**/
  6994. name: string,
  6995. /**The starting frame of the animation */
  6996. from: number,
  6997. /**The ending frame of the animation*/
  6998. to: number);
  6999. /**
  7000. * Makes a copy of the animation range
  7001. * @returns A copy of the animation range
  7002. */
  7003. clone(): AnimationRange;
  7004. }
  7005. }
  7006. declare module "babylonjs/Animations/animationEvent" {
  7007. /**
  7008. * Composed of a frame, and an action function
  7009. */
  7010. export class AnimationEvent {
  7011. /** The frame for which the event is triggered **/
  7012. frame: number;
  7013. /** The event to perform when triggered **/
  7014. action: (currentFrame: number) => void;
  7015. /** Specifies if the event should be triggered only once**/
  7016. onlyOnce?: boolean | undefined;
  7017. /**
  7018. * Specifies if the animation event is done
  7019. */
  7020. isDone: boolean;
  7021. /**
  7022. * Initializes the animation event
  7023. * @param frame The frame for which the event is triggered
  7024. * @param action The event to perform when triggered
  7025. * @param onlyOnce Specifies if the event should be triggered only once
  7026. */
  7027. constructor(
  7028. /** The frame for which the event is triggered **/
  7029. frame: number,
  7030. /** The event to perform when triggered **/
  7031. action: (currentFrame: number) => void,
  7032. /** Specifies if the event should be triggered only once**/
  7033. onlyOnce?: boolean | undefined);
  7034. /** @hidden */
  7035. _clone(): AnimationEvent;
  7036. }
  7037. }
  7038. declare module "babylonjs/Behaviors/behavior" {
  7039. import { Nullable } from "babylonjs/types";
  7040. /**
  7041. * Interface used to define a behavior
  7042. */
  7043. export interface Behavior<T> {
  7044. /** gets or sets behavior's name */
  7045. name: string;
  7046. /**
  7047. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7048. */
  7049. init(): void;
  7050. /**
  7051. * Called when the behavior is attached to a target
  7052. * @param target defines the target where the behavior is attached to
  7053. */
  7054. attach(target: T): void;
  7055. /**
  7056. * Called when the behavior is detached from its target
  7057. */
  7058. detach(): void;
  7059. }
  7060. /**
  7061. * Interface implemented by classes supporting behaviors
  7062. */
  7063. export interface IBehaviorAware<T> {
  7064. /**
  7065. * Attach a behavior
  7066. * @param behavior defines the behavior to attach
  7067. * @returns the current host
  7068. */
  7069. addBehavior(behavior: Behavior<T>): T;
  7070. /**
  7071. * Remove a behavior from the current object
  7072. * @param behavior defines the behavior to detach
  7073. * @returns the current host
  7074. */
  7075. removeBehavior(behavior: Behavior<T>): T;
  7076. /**
  7077. * Gets a behavior using its name to search
  7078. * @param name defines the name to search
  7079. * @returns the behavior or null if not found
  7080. */
  7081. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7082. }
  7083. }
  7084. declare module "babylonjs/Collisions/intersectionInfo" {
  7085. import { Nullable } from "babylonjs/types";
  7086. /**
  7087. * @hidden
  7088. */
  7089. export class IntersectionInfo {
  7090. bu: Nullable<number>;
  7091. bv: Nullable<number>;
  7092. distance: number;
  7093. faceId: number;
  7094. subMeshId: number;
  7095. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7096. }
  7097. }
  7098. declare module "babylonjs/Culling/boundingSphere" {
  7099. import { DeepImmutable } from "babylonjs/types";
  7100. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7101. /**
  7102. * Class used to store bounding sphere information
  7103. */
  7104. export class BoundingSphere {
  7105. /**
  7106. * Gets the center of the bounding sphere in local space
  7107. */
  7108. readonly center: Vector3;
  7109. /**
  7110. * Radius of the bounding sphere in local space
  7111. */
  7112. radius: number;
  7113. /**
  7114. * Gets the center of the bounding sphere in world space
  7115. */
  7116. readonly centerWorld: Vector3;
  7117. /**
  7118. * Radius of the bounding sphere in world space
  7119. */
  7120. radiusWorld: number;
  7121. /**
  7122. * Gets the minimum vector in local space
  7123. */
  7124. readonly minimum: Vector3;
  7125. /**
  7126. * Gets the maximum vector in local space
  7127. */
  7128. readonly maximum: Vector3;
  7129. private _worldMatrix;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Creates a new bounding sphere
  7133. * @param min defines the minimum vector (in local space)
  7134. * @param max defines the maximum vector (in local space)
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * Scale the current bounding sphere by applying a scale factor
  7147. * @param factor defines the scale factor to apply
  7148. * @returns the current bounding box
  7149. */
  7150. scale(factor: number): BoundingSphere;
  7151. /**
  7152. * Gets the world matrix of the bounding box
  7153. * @returns a matrix
  7154. */
  7155. getWorldMatrix(): DeepImmutable<Matrix>;
  7156. /** @hidden */
  7157. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7158. /**
  7159. * Tests if the bounding sphere is intersecting the frustum planes
  7160. * @param frustumPlanes defines the frustum planes to test
  7161. * @returns true if there is an intersection
  7162. */
  7163. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7164. /**
  7165. * Tests if the bounding sphere center is in between the frustum planes.
  7166. * Used for optimistic fast inclusion.
  7167. * @param frustumPlanes defines the frustum planes to test
  7168. * @returns true if the sphere center is in between the frustum planes
  7169. */
  7170. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7171. /**
  7172. * Tests if a point is inside the bounding sphere
  7173. * @param point defines the point to test
  7174. * @returns true if the point is inside the bounding sphere
  7175. */
  7176. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7177. /**
  7178. * Checks if two sphere intersct
  7179. * @param sphere0 sphere 0
  7180. * @param sphere1 sphere 1
  7181. * @returns true if the speres intersect
  7182. */
  7183. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7184. }
  7185. }
  7186. declare module "babylonjs/Culling/boundingBox" {
  7187. import { DeepImmutable } from "babylonjs/types";
  7188. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7189. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7190. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7191. /**
  7192. * Class used to store bounding box information
  7193. */
  7194. export class BoundingBox implements ICullable {
  7195. /**
  7196. * Gets the 8 vectors representing the bounding box in local space
  7197. */
  7198. readonly vectors: Vector3[];
  7199. /**
  7200. * Gets the center of the bounding box in local space
  7201. */
  7202. readonly center: Vector3;
  7203. /**
  7204. * Gets the center of the bounding box in world space
  7205. */
  7206. readonly centerWorld: Vector3;
  7207. /**
  7208. * Gets the extend size in local space
  7209. */
  7210. readonly extendSize: Vector3;
  7211. /**
  7212. * Gets the extend size in world space
  7213. */
  7214. readonly extendSizeWorld: Vector3;
  7215. /**
  7216. * Gets the OBB (object bounding box) directions
  7217. */
  7218. readonly directions: Vector3[];
  7219. /**
  7220. * Gets the 8 vectors representing the bounding box in world space
  7221. */
  7222. readonly vectorsWorld: Vector3[];
  7223. /**
  7224. * Gets the minimum vector in world space
  7225. */
  7226. readonly minimumWorld: Vector3;
  7227. /**
  7228. * Gets the maximum vector in world space
  7229. */
  7230. readonly maximumWorld: Vector3;
  7231. /**
  7232. * Gets the minimum vector in local space
  7233. */
  7234. readonly minimum: Vector3;
  7235. /**
  7236. * Gets the maximum vector in local space
  7237. */
  7238. readonly maximum: Vector3;
  7239. private _worldMatrix;
  7240. private static readonly TmpVector3;
  7241. /**
  7242. * @hidden
  7243. */
  7244. _tag: number;
  7245. /**
  7246. * Creates a new bounding box
  7247. * @param min defines the minimum vector (in local space)
  7248. * @param max defines the maximum vector (in local space)
  7249. * @param worldMatrix defines the new world matrix
  7250. */
  7251. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7252. /**
  7253. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7254. * @param min defines the new minimum vector (in local space)
  7255. * @param max defines the new maximum vector (in local space)
  7256. * @param worldMatrix defines the new world matrix
  7257. */
  7258. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7259. /**
  7260. * Scale the current bounding box by applying a scale factor
  7261. * @param factor defines the scale factor to apply
  7262. * @returns the current bounding box
  7263. */
  7264. scale(factor: number): BoundingBox;
  7265. /**
  7266. * Gets the world matrix of the bounding box
  7267. * @returns a matrix
  7268. */
  7269. getWorldMatrix(): DeepImmutable<Matrix>;
  7270. /** @hidden */
  7271. _update(world: DeepImmutable<Matrix>): void;
  7272. /**
  7273. * Tests if the bounding box is intersecting the frustum planes
  7274. * @param frustumPlanes defines the frustum planes to test
  7275. * @returns true if there is an intersection
  7276. */
  7277. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7278. /**
  7279. * Tests if the bounding box is entirely inside the frustum planes
  7280. * @param frustumPlanes defines the frustum planes to test
  7281. * @returns true if there is an inclusion
  7282. */
  7283. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. /**
  7285. * Tests if a point is inside the bounding box
  7286. * @param point defines the point to test
  7287. * @returns true if the point is inside the bounding box
  7288. */
  7289. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7290. /**
  7291. * Tests if the bounding box intersects with a bounding sphere
  7292. * @param sphere defines the sphere to test
  7293. * @returns true if there is an intersection
  7294. */
  7295. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7296. /**
  7297. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7298. * @param min defines the min vector to use
  7299. * @param max defines the max vector to use
  7300. * @returns true if there is an intersection
  7301. */
  7302. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7303. /**
  7304. * Tests if two bounding boxes are intersections
  7305. * @param box0 defines the first box to test
  7306. * @param box1 defines the second box to test
  7307. * @returns true if there is an intersection
  7308. */
  7309. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7310. /**
  7311. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7312. * @param minPoint defines the minimum vector of the bounding box
  7313. * @param maxPoint defines the maximum vector of the bounding box
  7314. * @param sphereCenter defines the sphere center
  7315. * @param sphereRadius defines the sphere radius
  7316. * @returns true if there is an intersection
  7317. */
  7318. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7319. /**
  7320. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7321. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7322. * @param frustumPlanes defines the frustum planes to test
  7323. * @return true if there is an inclusion
  7324. */
  7325. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7326. /**
  7327. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7328. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7329. * @param frustumPlanes defines the frustum planes to test
  7330. * @return true if there is an intersection
  7331. */
  7332. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7333. }
  7334. }
  7335. declare module "babylonjs/Collisions/collider" {
  7336. import { Nullable, IndicesArray } from "babylonjs/types";
  7337. import { Vector3, Plane } from "babylonjs/Maths/math";
  7338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7339. /** @hidden */
  7340. export class Collider {
  7341. /** Define if a collision was found */
  7342. collisionFound: boolean;
  7343. /**
  7344. * Define last intersection point in local space
  7345. */
  7346. intersectionPoint: Vector3;
  7347. /**
  7348. * Define last collided mesh
  7349. */
  7350. collidedMesh: Nullable<AbstractMesh>;
  7351. private _collisionPoint;
  7352. private _planeIntersectionPoint;
  7353. private _tempVector;
  7354. private _tempVector2;
  7355. private _tempVector3;
  7356. private _tempVector4;
  7357. private _edge;
  7358. private _baseToVertex;
  7359. private _destinationPoint;
  7360. private _slidePlaneNormal;
  7361. private _displacementVector;
  7362. /** @hidden */
  7363. _radius: Vector3;
  7364. /** @hidden */
  7365. _retry: number;
  7366. private _velocity;
  7367. private _basePoint;
  7368. private _epsilon;
  7369. /** @hidden */
  7370. _velocityWorldLength: number;
  7371. /** @hidden */
  7372. _basePointWorld: Vector3;
  7373. private _velocityWorld;
  7374. private _normalizedVelocity;
  7375. /** @hidden */
  7376. _initialVelocity: Vector3;
  7377. /** @hidden */
  7378. _initialPosition: Vector3;
  7379. private _nearestDistance;
  7380. private _collisionMask;
  7381. collisionMask: number;
  7382. /**
  7383. * Gets the plane normal used to compute the sliding response (in local space)
  7384. */
  7385. readonly slidePlaneNormal: Vector3;
  7386. /** @hidden */
  7387. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7388. /** @hidden */
  7389. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7390. /** @hidden */
  7391. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7392. /** @hidden */
  7393. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7394. /** @hidden */
  7395. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7396. /** @hidden */
  7397. _getResponse(pos: Vector3, vel: Vector3): void;
  7398. }
  7399. }
  7400. declare module "babylonjs/Culling/boundingInfo" {
  7401. import { DeepImmutable } from "babylonjs/types";
  7402. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7403. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7404. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7405. import { Collider } from "babylonjs/Collisions/collider";
  7406. /**
  7407. * Interface for cullable objects
  7408. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7409. */
  7410. export interface ICullable {
  7411. /**
  7412. * Checks if the object or part of the object is in the frustum
  7413. * @param frustumPlanes Camera near/planes
  7414. * @returns true if the object is in frustum otherwise false
  7415. */
  7416. isInFrustum(frustumPlanes: Plane[]): boolean;
  7417. /**
  7418. * Checks if a cullable object (mesh...) is in the camera frustum
  7419. * Unlike isInFrustum this cheks the full bounding box
  7420. * @param frustumPlanes Camera near/planes
  7421. * @returns true if the object is in frustum otherwise false
  7422. */
  7423. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7424. }
  7425. /**
  7426. * Info for a bounding data of a mesh
  7427. */
  7428. export class BoundingInfo implements ICullable {
  7429. /**
  7430. * Bounding box for the mesh
  7431. */
  7432. readonly boundingBox: BoundingBox;
  7433. /**
  7434. * Bounding sphere for the mesh
  7435. */
  7436. readonly boundingSphere: BoundingSphere;
  7437. private _isLocked;
  7438. private static readonly TmpVector3;
  7439. /**
  7440. * Constructs bounding info
  7441. * @param minimum min vector of the bounding box/sphere
  7442. * @param maximum max vector of the bounding box/sphere
  7443. * @param worldMatrix defines the new world matrix
  7444. */
  7445. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7446. /**
  7447. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7448. * @param min defines the new minimum vector (in local space)
  7449. * @param max defines the new maximum vector (in local space)
  7450. * @param worldMatrix defines the new world matrix
  7451. */
  7452. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7453. /**
  7454. * min vector of the bounding box/sphere
  7455. */
  7456. readonly minimum: Vector3;
  7457. /**
  7458. * max vector of the bounding box/sphere
  7459. */
  7460. readonly maximum: Vector3;
  7461. /**
  7462. * If the info is locked and won't be updated to avoid perf overhead
  7463. */
  7464. isLocked: boolean;
  7465. /**
  7466. * Updates the bounding sphere and box
  7467. * @param world world matrix to be used to update
  7468. */
  7469. update(world: DeepImmutable<Matrix>): void;
  7470. /**
  7471. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7472. * @param center New center of the bounding info
  7473. * @param extend New extend of the bounding info
  7474. * @returns the current bounding info
  7475. */
  7476. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7477. /**
  7478. * Scale the current bounding info by applying a scale factor
  7479. * @param factor defines the scale factor to apply
  7480. * @returns the current bounding info
  7481. */
  7482. scale(factor: number): BoundingInfo;
  7483. /**
  7484. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7485. * @param frustumPlanes defines the frustum to test
  7486. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7487. * @returns true if the bounding info is in the frustum planes
  7488. */
  7489. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7490. /**
  7491. * Gets the world distance between the min and max points of the bounding box
  7492. */
  7493. readonly diagonalLength: number;
  7494. /**
  7495. * Checks if a cullable object (mesh...) is in the camera frustum
  7496. * Unlike isInFrustum this cheks the full bounding box
  7497. * @param frustumPlanes Camera near/planes
  7498. * @returns true if the object is in frustum otherwise false
  7499. */
  7500. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7501. /** @hidden */
  7502. _checkCollision(collider: Collider): boolean;
  7503. /**
  7504. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7505. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7506. * @param point the point to check intersection with
  7507. * @returns if the point intersects
  7508. */
  7509. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7510. /**
  7511. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7512. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7513. * @param boundingInfo the bounding info to check intersection with
  7514. * @param precise if the intersection should be done using OBB
  7515. * @returns if the bounding info intersects
  7516. */
  7517. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7518. }
  7519. }
  7520. declare module "babylonjs/Misc/smartArray" {
  7521. /**
  7522. * Defines an array and its length.
  7523. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7524. */
  7525. export interface ISmartArrayLike<T> {
  7526. /**
  7527. * The data of the array.
  7528. */
  7529. data: Array<T>;
  7530. /**
  7531. * The active length of the array.
  7532. */
  7533. length: number;
  7534. }
  7535. /**
  7536. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7537. */
  7538. export class SmartArray<T> implements ISmartArrayLike<T> {
  7539. /**
  7540. * The full set of data from the array.
  7541. */
  7542. data: Array<T>;
  7543. /**
  7544. * The active length of the array.
  7545. */
  7546. length: number;
  7547. protected _id: number;
  7548. /**
  7549. * Instantiates a Smart Array.
  7550. * @param capacity defines the default capacity of the array.
  7551. */
  7552. constructor(capacity: number);
  7553. /**
  7554. * Pushes a value at the end of the active data.
  7555. * @param value defines the object to push in the array.
  7556. */
  7557. push(value: T): void;
  7558. /**
  7559. * Iterates over the active data and apply the lambda to them.
  7560. * @param func defines the action to apply on each value.
  7561. */
  7562. forEach(func: (content: T) => void): void;
  7563. /**
  7564. * Sorts the full sets of data.
  7565. * @param compareFn defines the comparison function to apply.
  7566. */
  7567. sort(compareFn: (a: T, b: T) => number): void;
  7568. /**
  7569. * Resets the active data to an empty array.
  7570. */
  7571. reset(): void;
  7572. /**
  7573. * Releases all the data from the array as well as the array.
  7574. */
  7575. dispose(): void;
  7576. /**
  7577. * Concats the active data with a given array.
  7578. * @param array defines the data to concatenate with.
  7579. */
  7580. concat(array: any): void;
  7581. /**
  7582. * Returns the position of a value in the active data.
  7583. * @param value defines the value to find the index for
  7584. * @returns the index if found in the active data otherwise -1
  7585. */
  7586. indexOf(value: T): number;
  7587. /**
  7588. * Returns whether an element is part of the active data.
  7589. * @param value defines the value to look for
  7590. * @returns true if found in the active data otherwise false
  7591. */
  7592. contains(value: T): boolean;
  7593. private static _GlobalId;
  7594. }
  7595. /**
  7596. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7597. * The data in this array can only be present once
  7598. */
  7599. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7600. private _duplicateId;
  7601. /**
  7602. * Pushes a value at the end of the active data.
  7603. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7604. * @param value defines the object to push in the array.
  7605. */
  7606. push(value: T): void;
  7607. /**
  7608. * Pushes a value at the end of the active data.
  7609. * If the data is already present, it won t be added again
  7610. * @param value defines the object to push in the array.
  7611. * @returns true if added false if it was already present
  7612. */
  7613. pushNoDuplicate(value: T): boolean;
  7614. /**
  7615. * Resets the active data to an empty array.
  7616. */
  7617. reset(): void;
  7618. /**
  7619. * Concats the active data with a given array.
  7620. * This ensures no dupplicate will be present in the result.
  7621. * @param array defines the data to concatenate with.
  7622. */
  7623. concatWithNoDuplicate(array: any): void;
  7624. }
  7625. }
  7626. declare module "babylonjs/Misc/iInspectable" {
  7627. /**
  7628. * Enum that determines the text-wrapping mode to use.
  7629. */
  7630. export enum InspectableType {
  7631. /**
  7632. * Checkbox for booleans
  7633. */
  7634. Checkbox = 0,
  7635. /**
  7636. * Sliders for numbers
  7637. */
  7638. Slider = 1,
  7639. /**
  7640. * Vector3
  7641. */
  7642. Vector3 = 2,
  7643. /**
  7644. * Quaternions
  7645. */
  7646. Quaternion = 3,
  7647. /**
  7648. * Color3
  7649. */
  7650. Color3 = 4
  7651. }
  7652. /**
  7653. * Interface used to define custom inspectable properties.
  7654. * This interface is used by the inspector to display custom property grids
  7655. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7656. */
  7657. export interface IInspectable {
  7658. /**
  7659. * Gets the label to display
  7660. */
  7661. label: string;
  7662. /**
  7663. * Gets the name of the property to edit
  7664. */
  7665. propertyName: string;
  7666. /**
  7667. * Gets the type of the editor to use
  7668. */
  7669. type: InspectableType;
  7670. /**
  7671. * Gets the minimum value of the property when using in "slider" mode
  7672. */
  7673. min?: number;
  7674. /**
  7675. * Gets the maximum value of the property when using in "slider" mode
  7676. */
  7677. max?: number;
  7678. /**
  7679. * Gets the setp to use when using in "slider" mode
  7680. */
  7681. step?: number;
  7682. }
  7683. }
  7684. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7685. import { Nullable } from "babylonjs/types";
  7686. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7687. /**
  7688. * This represents the required contract to create a new type of texture loader.
  7689. */
  7690. export interface IInternalTextureLoader {
  7691. /**
  7692. * Defines wether the loader supports cascade loading the different faces.
  7693. */
  7694. supportCascades: boolean;
  7695. /**
  7696. * This returns if the loader support the current file information.
  7697. * @param extension defines the file extension of the file being loaded
  7698. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7699. * @param fallback defines the fallback internal texture if any
  7700. * @param isBase64 defines whether the texture is encoded as a base64
  7701. * @param isBuffer defines whether the texture data are stored as a buffer
  7702. * @returns true if the loader can load the specified file
  7703. */
  7704. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7705. /**
  7706. * Transform the url before loading if required.
  7707. * @param rootUrl the url of the texture
  7708. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7709. * @returns the transformed texture
  7710. */
  7711. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7712. /**
  7713. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7714. * @param rootUrl the url of the texture
  7715. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7716. * @returns the fallback texture
  7717. */
  7718. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7719. /**
  7720. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7721. * @param data contains the texture data
  7722. * @param texture defines the BabylonJS internal texture
  7723. * @param createPolynomials will be true if polynomials have been requested
  7724. * @param onLoad defines the callback to trigger once the texture is ready
  7725. * @param onError defines the callback to trigger in case of error
  7726. */
  7727. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7728. /**
  7729. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7730. * @param data contains the texture data
  7731. * @param texture defines the BabylonJS internal texture
  7732. * @param callback defines the method to call once ready to upload
  7733. */
  7734. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7735. }
  7736. }
  7737. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7739. import { Nullable } from "babylonjs/types";
  7740. import { Scene } from "babylonjs/scene";
  7741. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7742. module "babylonjs/Engines/engine" {
  7743. interface Engine {
  7744. /**
  7745. * Creates a depth stencil cube texture.
  7746. * This is only available in WebGL 2.
  7747. * @param size The size of face edge in the cube texture.
  7748. * @param options The options defining the cube texture.
  7749. * @returns The cube texture
  7750. */
  7751. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7752. /**
  7753. * Creates a cube texture
  7754. * @param rootUrl defines the url where the files to load is located
  7755. * @param scene defines the current scene
  7756. * @param files defines the list of files to load (1 per face)
  7757. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7758. * @param onLoad defines an optional callback raised when the texture is loaded
  7759. * @param onError defines an optional callback raised if there is an issue to load the texture
  7760. * @param format defines the format of the data
  7761. * @param forcedExtension defines the extension to use to pick the right loader
  7762. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7765. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7766. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7767. * @returns the cube texture as an InternalTexture
  7768. */
  7769. 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;
  7770. /**
  7771. * Creates a cube texture
  7772. * @param rootUrl defines the url where the files to load is located
  7773. * @param scene defines the current scene
  7774. * @param files defines the list of files to load (1 per face)
  7775. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7776. * @param onLoad defines an optional callback raised when the texture is loaded
  7777. * @param onError defines an optional callback raised if there is an issue to load the texture
  7778. * @param format defines the format of the data
  7779. * @param forcedExtension defines the extension to use to pick the right loader
  7780. * @returns the cube texture as an InternalTexture
  7781. */
  7782. 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;
  7783. /**
  7784. * Creates a cube texture
  7785. * @param rootUrl defines the url where the files to load is located
  7786. * @param scene defines the current scene
  7787. * @param files defines the list of files to load (1 per face)
  7788. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7789. * @param onLoad defines an optional callback raised when the texture is loaded
  7790. * @param onError defines an optional callback raised if there is an issue to load the texture
  7791. * @param format defines the format of the data
  7792. * @param forcedExtension defines the extension to use to pick the right loader
  7793. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7794. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7795. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7796. * @returns the cube texture as an InternalTexture
  7797. */
  7798. 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;
  7799. /** @hidden */
  7800. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7801. /** @hidden */
  7802. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7803. /** @hidden */
  7804. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7805. /** @hidden */
  7806. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7807. }
  7808. }
  7809. }
  7810. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7811. import { Nullable } from "babylonjs/types";
  7812. import { Scene } from "babylonjs/scene";
  7813. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7814. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7815. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7816. /**
  7817. * Class for creating a cube texture
  7818. */
  7819. export class CubeTexture extends BaseTexture {
  7820. private _delayedOnLoad;
  7821. /**
  7822. * The url of the texture
  7823. */
  7824. url: string;
  7825. /**
  7826. * Gets or sets the center of the bounding box associated with the cube texture.
  7827. * It must define where the camera used to render the texture was set
  7828. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7829. */
  7830. boundingBoxPosition: Vector3;
  7831. private _boundingBoxSize;
  7832. /**
  7833. * Gets or sets the size of the bounding box associated with the cube texture
  7834. * When defined, the cubemap will switch to local mode
  7835. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7836. * @example https://www.babylonjs-playground.com/#RNASML
  7837. */
  7838. /**
  7839. * Returns the bounding box size
  7840. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7841. */
  7842. boundingBoxSize: Vector3;
  7843. protected _rotationY: number;
  7844. /**
  7845. * Sets texture matrix rotation angle around Y axis in radians.
  7846. */
  7847. /**
  7848. * Gets texture matrix rotation angle around Y axis radians.
  7849. */
  7850. rotationY: number;
  7851. /**
  7852. * Are mip maps generated for this texture or not.
  7853. */
  7854. readonly noMipmap: boolean;
  7855. private _noMipmap;
  7856. private _files;
  7857. private _extensions;
  7858. private _textureMatrix;
  7859. private _format;
  7860. private _createPolynomials;
  7861. /** @hidden */
  7862. _prefiltered: boolean;
  7863. /**
  7864. * Creates a cube texture from an array of image urls
  7865. * @param files defines an array of image urls
  7866. * @param scene defines the hosting scene
  7867. * @param noMipmap specifies if mip maps are not used
  7868. * @returns a cube texture
  7869. */
  7870. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7871. /**
  7872. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7873. * @param url defines the url of the prefiltered texture
  7874. * @param scene defines the scene the texture is attached to
  7875. * @param forcedExtension defines the extension of the file if different from the url
  7876. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7877. * @return the prefiltered texture
  7878. */
  7879. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7880. /**
  7881. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7882. * as prefiltered data.
  7883. * @param rootUrl defines the url of the texture or the root name of the six images
  7884. * @param scene defines the scene the texture is attached to
  7885. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7886. * @param noMipmap defines if mipmaps should be created or not
  7887. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7888. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7889. * @param onError defines a callback triggered in case of error during load
  7890. * @param format defines the internal format to use for the texture once loaded
  7891. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7892. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7893. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7894. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7895. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7896. * @return the cube texture
  7897. */
  7898. 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);
  7899. /**
  7900. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7901. */
  7902. readonly isPrefiltered: boolean;
  7903. /**
  7904. * Get the current class name of the texture useful for serialization or dynamic coding.
  7905. * @returns "CubeTexture"
  7906. */
  7907. getClassName(): string;
  7908. /**
  7909. * Update the url (and optional buffer) of this texture if url was null during construction.
  7910. * @param url the url of the texture
  7911. * @param forcedExtension defines the extension to use
  7912. * @param onLoad callback called when the texture is loaded (defaults to null)
  7913. */
  7914. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7915. /**
  7916. * Delays loading of the cube texture
  7917. * @param forcedExtension defines the extension to use
  7918. */
  7919. delayLoad(forcedExtension?: string): void;
  7920. /**
  7921. * Returns the reflection texture matrix
  7922. * @returns the reflection texture matrix
  7923. */
  7924. getReflectionTextureMatrix(): Matrix;
  7925. /**
  7926. * Sets the reflection texture matrix
  7927. * @param value Reflection texture matrix
  7928. */
  7929. setReflectionTextureMatrix(value: Matrix): void;
  7930. /**
  7931. * Parses text to create a cube texture
  7932. * @param parsedTexture define the serialized text to read from
  7933. * @param scene defines the hosting scene
  7934. * @param rootUrl defines the root url of the cube texture
  7935. * @returns a cube texture
  7936. */
  7937. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7938. /**
  7939. * Makes a clone, or deep copy, of the cube texture
  7940. * @returns a new cube texture
  7941. */
  7942. clone(): CubeTexture;
  7943. }
  7944. }
  7945. declare module "babylonjs/Shaders/postprocess.vertex" {
  7946. /** @hidden */
  7947. export var postprocessVertexShader: {
  7948. name: string;
  7949. shader: string;
  7950. };
  7951. }
  7952. declare module "babylonjs/Cameras/targetCamera" {
  7953. import { Nullable } from "babylonjs/types";
  7954. import { Camera } from "babylonjs/Cameras/camera";
  7955. import { Scene } from "babylonjs/scene";
  7956. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7957. /**
  7958. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7959. * This is the base of the follow, arc rotate cameras and Free camera
  7960. * @see http://doc.babylonjs.com/features/cameras
  7961. */
  7962. export class TargetCamera extends Camera {
  7963. private static _RigCamTransformMatrix;
  7964. private static _TargetTransformMatrix;
  7965. private static _TargetFocalPoint;
  7966. /**
  7967. * Define the current direction the camera is moving to
  7968. */
  7969. cameraDirection: Vector3;
  7970. /**
  7971. * Define the current rotation the camera is rotating to
  7972. */
  7973. cameraRotation: Vector2;
  7974. /**
  7975. * When set, the up vector of the camera will be updated by the rotation of the camera
  7976. */
  7977. updateUpVectorFromRotation: boolean;
  7978. private _tmpQuaternion;
  7979. /**
  7980. * Define the current rotation of the camera
  7981. */
  7982. rotation: Vector3;
  7983. /**
  7984. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7985. */
  7986. rotationQuaternion: Quaternion;
  7987. /**
  7988. * Define the current speed of the camera
  7989. */
  7990. speed: number;
  7991. /**
  7992. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7993. * around all axis.
  7994. */
  7995. noRotationConstraint: boolean;
  7996. /**
  7997. * Define the current target of the camera as an object or a position.
  7998. */
  7999. lockedTarget: any;
  8000. /** @hidden */
  8001. _currentTarget: Vector3;
  8002. /** @hidden */
  8003. _initialFocalDistance: number;
  8004. /** @hidden */
  8005. _viewMatrix: Matrix;
  8006. /** @hidden */
  8007. _camMatrix: Matrix;
  8008. /** @hidden */
  8009. _cameraTransformMatrix: Matrix;
  8010. /** @hidden */
  8011. _cameraRotationMatrix: Matrix;
  8012. /** @hidden */
  8013. _referencePoint: Vector3;
  8014. /** @hidden */
  8015. _transformedReferencePoint: Vector3;
  8016. protected _globalCurrentTarget: Vector3;
  8017. protected _globalCurrentUpVector: Vector3;
  8018. /** @hidden */
  8019. _reset: () => void;
  8020. private _defaultUp;
  8021. /**
  8022. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8023. * This is the base of the follow, arc rotate cameras and Free camera
  8024. * @see http://doc.babylonjs.com/features/cameras
  8025. * @param name Defines the name of the camera in the scene
  8026. * @param position Defines the start position of the camera in the scene
  8027. * @param scene Defines the scene the camera belongs to
  8028. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8029. */
  8030. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8031. /**
  8032. * Gets the position in front of the camera at a given distance.
  8033. * @param distance The distance from the camera we want the position to be
  8034. * @returns the position
  8035. */
  8036. getFrontPosition(distance: number): Vector3;
  8037. /** @hidden */
  8038. _getLockedTargetPosition(): Nullable<Vector3>;
  8039. private _storedPosition;
  8040. private _storedRotation;
  8041. private _storedRotationQuaternion;
  8042. /**
  8043. * Store current camera state of the camera (fov, position, rotation, etc..)
  8044. * @returns the camera
  8045. */
  8046. storeState(): Camera;
  8047. /**
  8048. * Restored camera state. You must call storeState() first
  8049. * @returns whether it was successful or not
  8050. * @hidden
  8051. */
  8052. _restoreStateValues(): boolean;
  8053. /** @hidden */
  8054. _initCache(): void;
  8055. /** @hidden */
  8056. _updateCache(ignoreParentClass?: boolean): void;
  8057. /** @hidden */
  8058. _isSynchronizedViewMatrix(): boolean;
  8059. /** @hidden */
  8060. _computeLocalCameraSpeed(): number;
  8061. /**
  8062. * Defines the target the camera should look at.
  8063. * @param target Defines the new target as a Vector or a mesh
  8064. */
  8065. setTarget(target: Vector3): void;
  8066. /**
  8067. * Return the current target position of the camera. This value is expressed in local space.
  8068. * @returns the target position
  8069. */
  8070. getTarget(): Vector3;
  8071. /** @hidden */
  8072. _decideIfNeedsToMove(): boolean;
  8073. /** @hidden */
  8074. _updatePosition(): void;
  8075. /** @hidden */
  8076. _checkInputs(): void;
  8077. protected _updateCameraRotationMatrix(): void;
  8078. /**
  8079. * 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)
  8080. * @returns the current camera
  8081. */
  8082. private _rotateUpVectorWithCameraRotationMatrix;
  8083. private _cachedRotationZ;
  8084. private _cachedQuaternionRotationZ;
  8085. /** @hidden */
  8086. _getViewMatrix(): Matrix;
  8087. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8088. /**
  8089. * @hidden
  8090. */
  8091. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8092. /**
  8093. * @hidden
  8094. */
  8095. _updateRigCameras(): void;
  8096. private _getRigCamPositionAndTarget;
  8097. /**
  8098. * Gets the current object class name.
  8099. * @return the class name
  8100. */
  8101. getClassName(): string;
  8102. }
  8103. }
  8104. declare module "babylonjs/Cameras/cameraInputsManager" {
  8105. import { Nullable } from "babylonjs/types";
  8106. import { Camera } from "babylonjs/Cameras/camera";
  8107. /**
  8108. * @ignore
  8109. * This is a list of all the different input types that are available in the application.
  8110. * Fo instance: ArcRotateCameraGamepadInput...
  8111. */
  8112. export var CameraInputTypes: {};
  8113. /**
  8114. * This is the contract to implement in order to create a new input class.
  8115. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8116. */
  8117. export interface ICameraInput<TCamera extends Camera> {
  8118. /**
  8119. * Defines the camera the input is attached to.
  8120. */
  8121. camera: Nullable<TCamera>;
  8122. /**
  8123. * Gets the class name of the current intput.
  8124. * @returns the class name
  8125. */
  8126. getClassName(): string;
  8127. /**
  8128. * Get the friendly name associated with the input class.
  8129. * @returns the input friendly name
  8130. */
  8131. getSimpleName(): string;
  8132. /**
  8133. * Attach the input controls to a specific dom element to get the input from.
  8134. * @param element Defines the element the controls should be listened from
  8135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8136. */
  8137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8138. /**
  8139. * Detach the current controls from the specified dom element.
  8140. * @param element Defines the element to stop listening the inputs from
  8141. */
  8142. detachControl(element: Nullable<HTMLElement>): void;
  8143. /**
  8144. * Update the current camera state depending on the inputs that have been used this frame.
  8145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8146. */
  8147. checkInputs?: () => void;
  8148. }
  8149. /**
  8150. * Represents a map of input types to input instance or input index to input instance.
  8151. */
  8152. export interface CameraInputsMap<TCamera extends Camera> {
  8153. /**
  8154. * Accessor to the input by input type.
  8155. */
  8156. [name: string]: ICameraInput<TCamera>;
  8157. /**
  8158. * Accessor to the input by input index.
  8159. */
  8160. [idx: number]: ICameraInput<TCamera>;
  8161. }
  8162. /**
  8163. * This represents the input manager used within a camera.
  8164. * It helps dealing with all the different kind of input attached to a camera.
  8165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8166. */
  8167. export class CameraInputsManager<TCamera extends Camera> {
  8168. /**
  8169. * Defines the list of inputs attahed to the camera.
  8170. */
  8171. attached: CameraInputsMap<TCamera>;
  8172. /**
  8173. * Defines the dom element the camera is collecting inputs from.
  8174. * This is null if the controls have not been attached.
  8175. */
  8176. attachedElement: Nullable<HTMLElement>;
  8177. /**
  8178. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8179. */
  8180. noPreventDefault: boolean;
  8181. /**
  8182. * Defined the camera the input manager belongs to.
  8183. */
  8184. camera: TCamera;
  8185. /**
  8186. * Update the current camera state depending on the inputs that have been used this frame.
  8187. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8188. */
  8189. checkInputs: () => void;
  8190. /**
  8191. * Instantiate a new Camera Input Manager.
  8192. * @param camera Defines the camera the input manager blongs to
  8193. */
  8194. constructor(camera: TCamera);
  8195. /**
  8196. * Add an input method to a camera
  8197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8198. * @param input camera input method
  8199. */
  8200. add(input: ICameraInput<TCamera>): void;
  8201. /**
  8202. * Remove a specific input method from a camera
  8203. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8204. * @param inputToRemove camera input method
  8205. */
  8206. remove(inputToRemove: ICameraInput<TCamera>): void;
  8207. /**
  8208. * Remove a specific input type from a camera
  8209. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8210. * @param inputType the type of the input to remove
  8211. */
  8212. removeByType(inputType: string): void;
  8213. private _addCheckInputs;
  8214. /**
  8215. * Attach the input controls to the currently attached dom element to listen the events from.
  8216. * @param input Defines the input to attach
  8217. */
  8218. attachInput(input: ICameraInput<TCamera>): void;
  8219. /**
  8220. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8221. * @param element Defines the dom element to collect the events from
  8222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8223. */
  8224. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8225. /**
  8226. * Detach the current manager inputs controls from a specific dom element.
  8227. * @param element Defines the dom element to collect the events from
  8228. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8229. */
  8230. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8231. /**
  8232. * Rebuild the dynamic inputCheck function from the current list of
  8233. * defined inputs in the manager.
  8234. */
  8235. rebuildInputCheck(): void;
  8236. /**
  8237. * Remove all attached input methods from a camera
  8238. */
  8239. clear(): void;
  8240. /**
  8241. * Serialize the current input manager attached to a camera.
  8242. * This ensures than once parsed,
  8243. * the input associated to the camera will be identical to the current ones
  8244. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8245. */
  8246. serialize(serializedCamera: any): void;
  8247. /**
  8248. * Parses an input manager serialized JSON to restore the previous list of inputs
  8249. * and states associated to a camera.
  8250. * @param parsedCamera Defines the JSON to parse
  8251. */
  8252. parse(parsedCamera: any): void;
  8253. }
  8254. }
  8255. declare module "babylonjs/Events/keyboardEvents" {
  8256. /**
  8257. * Gather the list of keyboard event types as constants.
  8258. */
  8259. export class KeyboardEventTypes {
  8260. /**
  8261. * The keydown event is fired when a key becomes active (pressed).
  8262. */
  8263. static readonly KEYDOWN: number;
  8264. /**
  8265. * The keyup event is fired when a key has been released.
  8266. */
  8267. static readonly KEYUP: number;
  8268. }
  8269. /**
  8270. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8271. */
  8272. export class KeyboardInfo {
  8273. /**
  8274. * Defines the type of event (KeyboardEventTypes)
  8275. */
  8276. type: number;
  8277. /**
  8278. * Defines the related dom event
  8279. */
  8280. event: KeyboardEvent;
  8281. /**
  8282. * Instantiates a new keyboard info.
  8283. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8284. * @param type Defines the type of event (KeyboardEventTypes)
  8285. * @param event Defines the related dom event
  8286. */
  8287. constructor(
  8288. /**
  8289. * Defines the type of event (KeyboardEventTypes)
  8290. */
  8291. type: number,
  8292. /**
  8293. * Defines the related dom event
  8294. */
  8295. event: KeyboardEvent);
  8296. }
  8297. /**
  8298. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8299. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8300. */
  8301. export class KeyboardInfoPre extends KeyboardInfo {
  8302. /**
  8303. * Defines the type of event (KeyboardEventTypes)
  8304. */
  8305. type: number;
  8306. /**
  8307. * Defines the related dom event
  8308. */
  8309. event: KeyboardEvent;
  8310. /**
  8311. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8312. */
  8313. skipOnPointerObservable: boolean;
  8314. /**
  8315. * Instantiates a new keyboard pre info.
  8316. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8317. * @param type Defines the type of event (KeyboardEventTypes)
  8318. * @param event Defines the related dom event
  8319. */
  8320. constructor(
  8321. /**
  8322. * Defines the type of event (KeyboardEventTypes)
  8323. */
  8324. type: number,
  8325. /**
  8326. * Defines the related dom event
  8327. */
  8328. event: KeyboardEvent);
  8329. }
  8330. }
  8331. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8332. import { Nullable } from "babylonjs/types";
  8333. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8334. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8335. /**
  8336. * Manage the keyboard inputs to control the movement of a free camera.
  8337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8338. */
  8339. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8340. /**
  8341. * Defines the camera the input is attached to.
  8342. */
  8343. camera: FreeCamera;
  8344. /**
  8345. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8346. */
  8347. keysUp: number[];
  8348. /**
  8349. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8350. */
  8351. keysDown: number[];
  8352. /**
  8353. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8354. */
  8355. keysLeft: number[];
  8356. /**
  8357. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8358. */
  8359. keysRight: number[];
  8360. private _keys;
  8361. private _onCanvasBlurObserver;
  8362. private _onKeyboardObserver;
  8363. private _engine;
  8364. private _scene;
  8365. /**
  8366. * Attach the input controls to a specific dom element to get the input from.
  8367. * @param element Defines the element the controls should be listened from
  8368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8369. */
  8370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8371. /**
  8372. * Detach the current controls from the specified dom element.
  8373. * @param element Defines the element to stop listening the inputs from
  8374. */
  8375. detachControl(element: Nullable<HTMLElement>): void;
  8376. /**
  8377. * Update the current camera state depending on the inputs that have been used this frame.
  8378. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8379. */
  8380. checkInputs(): void;
  8381. /**
  8382. * Gets the class name of the current intput.
  8383. * @returns the class name
  8384. */
  8385. getClassName(): string;
  8386. /** @hidden */
  8387. _onLostFocus(): void;
  8388. /**
  8389. * Get the friendly name associated with the input class.
  8390. * @returns the input friendly name
  8391. */
  8392. getSimpleName(): string;
  8393. }
  8394. }
  8395. declare module "babylonjs/Materials/multiMaterial" {
  8396. import { Nullable } from "babylonjs/types";
  8397. import { Scene } from "babylonjs/scene";
  8398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8399. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  8400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8401. import { Material } from "babylonjs/Materials/material";
  8402. /**
  8403. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8404. * separate meshes. This can be use to improve performances.
  8405. * @see http://doc.babylonjs.com/how_to/multi_materials
  8406. */
  8407. export class MultiMaterial extends Material {
  8408. private _subMaterials;
  8409. /**
  8410. * Gets or Sets the list of Materials used within the multi material.
  8411. * They need to be ordered according to the submeshes order in the associated mesh
  8412. */
  8413. subMaterials: Nullable<Material>[];
  8414. /**
  8415. * Function used to align with Node.getChildren()
  8416. * @returns the list of Materials used within the multi material
  8417. */
  8418. getChildren(): Nullable<Material>[];
  8419. /**
  8420. * Instantiates a new Multi Material
  8421. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8422. * separate meshes. This can be use to improve performances.
  8423. * @see http://doc.babylonjs.com/how_to/multi_materials
  8424. * @param name Define the name in the scene
  8425. * @param scene Define the scene the material belongs to
  8426. */
  8427. constructor(name: string, scene: Scene);
  8428. private _hookArray;
  8429. /**
  8430. * Get one of the submaterial by its index in the submaterials array
  8431. * @param index The index to look the sub material at
  8432. * @returns The Material if the index has been defined
  8433. */
  8434. getSubMaterial(index: number): Nullable<Material>;
  8435. /**
  8436. * Get the list of active textures for the whole sub materials list.
  8437. * @returns All the textures that will be used during the rendering
  8438. */
  8439. getActiveTextures(): BaseTexture[];
  8440. /**
  8441. * Gets the current class name of the material e.g. "MultiMaterial"
  8442. * Mainly use in serialization.
  8443. * @returns the class name
  8444. */
  8445. getClassName(): string;
  8446. /**
  8447. * Checks if the material is ready to render the requested sub mesh
  8448. * @param mesh Define the mesh the submesh belongs to
  8449. * @param subMesh Define the sub mesh to look readyness for
  8450. * @param useInstances Define whether or not the material is used with instances
  8451. * @returns true if ready, otherwise false
  8452. */
  8453. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8454. /**
  8455. * Clones the current material and its related sub materials
  8456. * @param name Define the name of the newly cloned material
  8457. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8458. * @returns the cloned material
  8459. */
  8460. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8461. /**
  8462. * Serializes the materials into a JSON representation.
  8463. * @returns the JSON representation
  8464. */
  8465. serialize(): any;
  8466. /**
  8467. * Dispose the material and release its associated resources
  8468. * @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)
  8469. * @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)
  8470. * @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)
  8471. */
  8472. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8473. /**
  8474. * Creates a MultiMaterial from parsed MultiMaterial data.
  8475. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8476. * @param scene defines the hosting scene
  8477. * @returns a new MultiMaterial
  8478. */
  8479. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8480. }
  8481. }
  8482. declare module "babylonjs/Loading/sceneLoaderFlags" {
  8483. /**
  8484. * Class used to represent data loading progression
  8485. */
  8486. export class SceneLoaderFlags {
  8487. private static _ForceFullSceneLoadingForIncremental;
  8488. private static _ShowLoadingScreen;
  8489. private static _CleanBoneMatrixWeights;
  8490. private static _loggingLevel;
  8491. /**
  8492. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8493. */
  8494. static ForceFullSceneLoadingForIncremental: boolean;
  8495. /**
  8496. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8497. */
  8498. static ShowLoadingScreen: boolean;
  8499. /**
  8500. * Defines the current logging level (while loading the scene)
  8501. * @ignorenaming
  8502. */
  8503. static loggingLevel: number;
  8504. /**
  8505. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8506. */
  8507. static CleanBoneMatrixWeights: boolean;
  8508. }
  8509. }
  8510. declare module "babylonjs/Meshes/transformNode" {
  8511. import { DeepImmutable } from "babylonjs/types";
  8512. import { Observable } from "babylonjs/Misc/observable";
  8513. import { Nullable } from "babylonjs/types";
  8514. import { Camera } from "babylonjs/Cameras/camera";
  8515. import { Scene } from "babylonjs/scene";
  8516. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  8517. import { Node } from "babylonjs/node";
  8518. import { Bone } from "babylonjs/Bones/bone";
  8519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8520. /**
  8521. * 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.
  8522. * @see https://doc.babylonjs.com/how_to/transformnode
  8523. */
  8524. export class TransformNode extends Node {
  8525. /**
  8526. * Object will not rotate to face the camera
  8527. */
  8528. static BILLBOARDMODE_NONE: number;
  8529. /**
  8530. * Object will rotate to face the camera but only on the x axis
  8531. */
  8532. static BILLBOARDMODE_X: number;
  8533. /**
  8534. * Object will rotate to face the camera but only on the y axis
  8535. */
  8536. static BILLBOARDMODE_Y: number;
  8537. /**
  8538. * Object will rotate to face the camera but only on the z axis
  8539. */
  8540. static BILLBOARDMODE_Z: number;
  8541. /**
  8542. * Object will rotate to face the camera
  8543. */
  8544. static BILLBOARDMODE_ALL: number;
  8545. private _forward;
  8546. private _forwardInverted;
  8547. private _up;
  8548. private _right;
  8549. private _rightInverted;
  8550. private _position;
  8551. private _rotation;
  8552. private _rotationQuaternion;
  8553. protected _scaling: Vector3;
  8554. protected _isDirty: boolean;
  8555. private _transformToBoneReferal;
  8556. private _billboardMode;
  8557. /**
  8558. * Gets or sets the billboard mode. Default is 0.
  8559. *
  8560. * | Value | Type | Description |
  8561. * | --- | --- | --- |
  8562. * | 0 | BILLBOARDMODE_NONE | |
  8563. * | 1 | BILLBOARDMODE_X | |
  8564. * | 2 | BILLBOARDMODE_Y | |
  8565. * | 4 | BILLBOARDMODE_Z | |
  8566. * | 7 | BILLBOARDMODE_ALL | |
  8567. *
  8568. */
  8569. billboardMode: number;
  8570. private _preserveParentRotationForBillboard;
  8571. /**
  8572. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8573. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8574. */
  8575. preserveParentRotationForBillboard: boolean;
  8576. /**
  8577. * 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
  8578. */
  8579. scalingDeterminant: number;
  8580. private _infiniteDistance;
  8581. /**
  8582. * Gets or sets the distance of the object to max, often used by skybox
  8583. */
  8584. infiniteDistance: boolean;
  8585. /**
  8586. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8587. * By default the system will update normals to compensate
  8588. */
  8589. ignoreNonUniformScaling: boolean;
  8590. /**
  8591. * 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
  8592. */
  8593. reIntegrateRotationIntoRotationQuaternion: boolean;
  8594. /** @hidden */
  8595. _poseMatrix: Nullable<Matrix>;
  8596. /** @hidden */
  8597. _localMatrix: Matrix;
  8598. private _usePivotMatrix;
  8599. private _absolutePosition;
  8600. private _pivotMatrix;
  8601. private _pivotMatrixInverse;
  8602. protected _postMultiplyPivotMatrix: boolean;
  8603. protected _isWorldMatrixFrozen: boolean;
  8604. /** @hidden */
  8605. _indexInSceneTransformNodesArray: number;
  8606. /**
  8607. * An event triggered after the world matrix is updated
  8608. */
  8609. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8610. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8611. /**
  8612. * Gets a string identifying the name of the class
  8613. * @returns "TransformNode" string
  8614. */
  8615. getClassName(): string;
  8616. /**
  8617. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8618. */
  8619. position: Vector3;
  8620. /**
  8621. * 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)).
  8622. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8623. */
  8624. rotation: Vector3;
  8625. /**
  8626. * 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)).
  8627. */
  8628. scaling: Vector3;
  8629. /**
  8630. * 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).
  8631. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8632. */
  8633. rotationQuaternion: Nullable<Quaternion>;
  8634. /**
  8635. * The forward direction of that transform in world space.
  8636. */
  8637. readonly forward: Vector3;
  8638. /**
  8639. * The up direction of that transform in world space.
  8640. */
  8641. readonly up: Vector3;
  8642. /**
  8643. * The right direction of that transform in world space.
  8644. */
  8645. readonly right: Vector3;
  8646. /**
  8647. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8648. * @param matrix the matrix to copy the pose from
  8649. * @returns this TransformNode.
  8650. */
  8651. updatePoseMatrix(matrix: Matrix): TransformNode;
  8652. /**
  8653. * Returns the mesh Pose matrix.
  8654. * @returns the pose matrix
  8655. */
  8656. getPoseMatrix(): Matrix;
  8657. /** @hidden */
  8658. _isSynchronized(): boolean;
  8659. /** @hidden */
  8660. _initCache(): void;
  8661. /**
  8662. * Flag the transform node as dirty (Forcing it to update everything)
  8663. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8664. * @returns this transform node
  8665. */
  8666. markAsDirty(property: string): TransformNode;
  8667. /**
  8668. * Returns the current mesh absolute position.
  8669. * Returns a Vector3.
  8670. */
  8671. readonly absolutePosition: Vector3;
  8672. /**
  8673. * Sets a new matrix to apply before all other transformation
  8674. * @param matrix defines the transform matrix
  8675. * @returns the current TransformNode
  8676. */
  8677. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8678. /**
  8679. * Sets a new pivot matrix to the current node
  8680. * @param matrix defines the new pivot matrix to use
  8681. * @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
  8682. * @returns the current TransformNode
  8683. */
  8684. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8685. /**
  8686. * Returns the mesh pivot matrix.
  8687. * Default : Identity.
  8688. * @returns the matrix
  8689. */
  8690. getPivotMatrix(): Matrix;
  8691. /**
  8692. * Prevents the World matrix to be computed any longer.
  8693. * @returns the TransformNode.
  8694. */
  8695. freezeWorldMatrix(): TransformNode;
  8696. /**
  8697. * Allows back the World matrix computation.
  8698. * @returns the TransformNode.
  8699. */
  8700. unfreezeWorldMatrix(): this;
  8701. /**
  8702. * True if the World matrix has been frozen.
  8703. */
  8704. readonly isWorldMatrixFrozen: boolean;
  8705. /**
  8706. * Retuns the mesh absolute position in the World.
  8707. * @returns a Vector3.
  8708. */
  8709. getAbsolutePosition(): Vector3;
  8710. /**
  8711. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8712. * @param absolutePosition the absolute position to set
  8713. * @returns the TransformNode.
  8714. */
  8715. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8716. /**
  8717. * Sets the mesh position in its local space.
  8718. * @param vector3 the position to set in localspace
  8719. * @returns the TransformNode.
  8720. */
  8721. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8722. /**
  8723. * Returns the mesh position in the local space from the current World matrix values.
  8724. * @returns a new Vector3.
  8725. */
  8726. getPositionExpressedInLocalSpace(): Vector3;
  8727. /**
  8728. * Translates the mesh along the passed Vector3 in its local space.
  8729. * @param vector3 the distance to translate in localspace
  8730. * @returns the TransformNode.
  8731. */
  8732. locallyTranslate(vector3: Vector3): TransformNode;
  8733. private static _lookAtVectorCache;
  8734. /**
  8735. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8736. * @param targetPoint the position (must be in same space as current mesh) to look at
  8737. * @param yawCor optional yaw (y-axis) correction in radians
  8738. * @param pitchCor optional pitch (x-axis) correction in radians
  8739. * @param rollCor optional roll (z-axis) correction in radians
  8740. * @param space the choosen space of the target
  8741. * @returns the TransformNode.
  8742. */
  8743. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8744. /**
  8745. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8746. * This Vector3 is expressed in the World space.
  8747. * @param localAxis axis to rotate
  8748. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8749. */
  8750. getDirection(localAxis: Vector3): Vector3;
  8751. /**
  8752. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8753. * localAxis is expressed in the mesh local space.
  8754. * result is computed in the Wordl space from the mesh World matrix.
  8755. * @param localAxis axis to rotate
  8756. * @param result the resulting transformnode
  8757. * @returns this TransformNode.
  8758. */
  8759. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8760. /**
  8761. * Sets this transform node rotation to the given local axis.
  8762. * @param localAxis the axis in local space
  8763. * @param yawCor optional yaw (y-axis) correction in radians
  8764. * @param pitchCor optional pitch (x-axis) correction in radians
  8765. * @param rollCor optional roll (z-axis) correction in radians
  8766. * @returns this TransformNode
  8767. */
  8768. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8769. /**
  8770. * Sets a new pivot point to the current node
  8771. * @param point defines the new pivot point to use
  8772. * @param space defines if the point is in world or local space (local by default)
  8773. * @returns the current TransformNode
  8774. */
  8775. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8776. /**
  8777. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8778. * @returns the pivot point
  8779. */
  8780. getPivotPoint(): Vector3;
  8781. /**
  8782. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8783. * @param result the vector3 to store the result
  8784. * @returns this TransformNode.
  8785. */
  8786. getPivotPointToRef(result: Vector3): TransformNode;
  8787. /**
  8788. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8789. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8790. */
  8791. getAbsolutePivotPoint(): Vector3;
  8792. /**
  8793. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8794. * @param result vector3 to store the result
  8795. * @returns this TransformNode.
  8796. */
  8797. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8798. /**
  8799. * Defines the passed node as the parent of the current node.
  8800. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8801. * @see https://doc.babylonjs.com/how_to/parenting
  8802. * @param node the node ot set as the parent
  8803. * @returns this TransformNode.
  8804. */
  8805. setParent(node: Nullable<Node>): TransformNode;
  8806. private _nonUniformScaling;
  8807. /**
  8808. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8809. */
  8810. readonly nonUniformScaling: boolean;
  8811. /** @hidden */
  8812. _updateNonUniformScalingState(value: boolean): boolean;
  8813. /**
  8814. * Attach the current TransformNode to another TransformNode associated with a bone
  8815. * @param bone Bone affecting the TransformNode
  8816. * @param affectedTransformNode TransformNode associated with the bone
  8817. * @returns this object
  8818. */
  8819. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8820. /**
  8821. * Detach the transform node if its associated with a bone
  8822. * @returns this object
  8823. */
  8824. detachFromBone(): TransformNode;
  8825. private static _rotationAxisCache;
  8826. /**
  8827. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8828. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8829. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8830. * The passed axis is also normalized.
  8831. * @param axis the axis to rotate around
  8832. * @param amount the amount to rotate in radians
  8833. * @param space Space to rotate in (Default: local)
  8834. * @returns the TransformNode.
  8835. */
  8836. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8837. /**
  8838. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8839. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8840. * The passed axis is also normalized. .
  8841. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8842. * @param point the point to rotate around
  8843. * @param axis the axis to rotate around
  8844. * @param amount the amount to rotate in radians
  8845. * @returns the TransformNode
  8846. */
  8847. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8848. /**
  8849. * Translates the mesh along the axis vector for the passed distance in the given space.
  8850. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8851. * @param axis the axis to translate in
  8852. * @param distance the distance to translate
  8853. * @param space Space to rotate in (Default: local)
  8854. * @returns the TransformNode.
  8855. */
  8856. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8857. /**
  8858. * Adds a rotation step to the mesh current rotation.
  8859. * x, y, z are Euler angles expressed in radians.
  8860. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8861. * This means this rotation is made in the mesh local space only.
  8862. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8863. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8864. * ```javascript
  8865. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8866. * ```
  8867. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8868. * 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.
  8869. * @param x Rotation to add
  8870. * @param y Rotation to add
  8871. * @param z Rotation to add
  8872. * @returns the TransformNode.
  8873. */
  8874. addRotation(x: number, y: number, z: number): TransformNode;
  8875. /**
  8876. * @hidden
  8877. */
  8878. protected _getEffectiveParent(): Nullable<Node>;
  8879. /**
  8880. * Computes the world matrix of the node
  8881. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8882. * @returns the world matrix
  8883. */
  8884. computeWorldMatrix(force?: boolean): Matrix;
  8885. protected _afterComputeWorldMatrix(): void;
  8886. /**
  8887. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8888. * @param func callback function to add
  8889. *
  8890. * @returns the TransformNode.
  8891. */
  8892. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8893. /**
  8894. * Removes a registered callback function.
  8895. * @param func callback function to remove
  8896. * @returns the TransformNode.
  8897. */
  8898. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8899. /**
  8900. * Gets the position of the current mesh in camera space
  8901. * @param camera defines the camera to use
  8902. * @returns a position
  8903. */
  8904. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8905. /**
  8906. * Returns the distance from the mesh to the active camera
  8907. * @param camera defines the camera to use
  8908. * @returns the distance
  8909. */
  8910. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8911. /**
  8912. * Clone the current transform node
  8913. * @param name Name of the new clone
  8914. * @param newParent New parent for the clone
  8915. * @param doNotCloneChildren Do not clone children hierarchy
  8916. * @returns the new transform node
  8917. */
  8918. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8919. /**
  8920. * Serializes the objects information.
  8921. * @param currentSerializationObject defines the object to serialize in
  8922. * @returns the serialized object
  8923. */
  8924. serialize(currentSerializationObject?: any): any;
  8925. /**
  8926. * Returns a new TransformNode object parsed from the source provided.
  8927. * @param parsedTransformNode is the source.
  8928. * @param scene the scne the object belongs to
  8929. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8930. * @returns a new TransformNode object parsed from the source provided.
  8931. */
  8932. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8933. /**
  8934. * Get all child-transformNodes of this node
  8935. * @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
  8936. * @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
  8937. * @returns an array of TransformNode
  8938. */
  8939. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8940. /**
  8941. * Releases resources associated with this transform node.
  8942. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8943. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8944. */
  8945. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8946. /**
  8947. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8948. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8949. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8950. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8951. * @returns the current mesh
  8952. */
  8953. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8954. }
  8955. }
  8956. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8957. /**
  8958. * Class used to override all child animations of a given target
  8959. */
  8960. export class AnimationPropertiesOverride {
  8961. /**
  8962. * Gets or sets a value indicating if animation blending must be used
  8963. */
  8964. enableBlending: boolean;
  8965. /**
  8966. * Gets or sets the blending speed to use when enableBlending is true
  8967. */
  8968. blendingSpeed: number;
  8969. /**
  8970. * Gets or sets the default loop mode to use
  8971. */
  8972. loopMode: number;
  8973. }
  8974. }
  8975. declare module "babylonjs/Bones/bone" {
  8976. import { Skeleton } from "babylonjs/Bones/skeleton";
  8977. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8978. import { Nullable } from "babylonjs/types";
  8979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8980. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8981. import { Node } from "babylonjs/node";
  8982. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8983. /**
  8984. * Class used to store bone information
  8985. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8986. */
  8987. export class Bone extends Node {
  8988. /**
  8989. * defines the bone name
  8990. */
  8991. name: string;
  8992. private static _tmpVecs;
  8993. private static _tmpQuat;
  8994. private static _tmpMats;
  8995. /**
  8996. * Gets the list of child bones
  8997. */
  8998. children: Bone[];
  8999. /** Gets the animations associated with this bone */
  9000. animations: import("babylonjs/Animations/animation").Animation[];
  9001. /**
  9002. * Gets or sets bone length
  9003. */
  9004. length: number;
  9005. /**
  9006. * @hidden Internal only
  9007. * Set this value to map this bone to a different index in the transform matrices
  9008. * Set this value to -1 to exclude the bone from the transform matrices
  9009. */
  9010. _index: Nullable<number>;
  9011. private _skeleton;
  9012. private _localMatrix;
  9013. private _restPose;
  9014. private _baseMatrix;
  9015. private _absoluteTransform;
  9016. private _invertedAbsoluteTransform;
  9017. private _parent;
  9018. private _scalingDeterminant;
  9019. private _worldTransform;
  9020. private _localScaling;
  9021. private _localRotation;
  9022. private _localPosition;
  9023. private _needToDecompose;
  9024. private _needToCompose;
  9025. /** @hidden */
  9026. _linkedTransformNode: Nullable<TransformNode>;
  9027. /** @hidden */
  9028. _waitingTransformNodeId: Nullable<string>;
  9029. /** @hidden */
  9030. /** @hidden */
  9031. _matrix: Matrix;
  9032. /**
  9033. * Create a new bone
  9034. * @param name defines the bone name
  9035. * @param skeleton defines the parent skeleton
  9036. * @param parentBone defines the parent (can be null if the bone is the root)
  9037. * @param localMatrix defines the local matrix
  9038. * @param restPose defines the rest pose matrix
  9039. * @param baseMatrix defines the base matrix
  9040. * @param index defines index of the bone in the hiearchy
  9041. */
  9042. constructor(
  9043. /**
  9044. * defines the bone name
  9045. */
  9046. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9047. /**
  9048. * Gets the current object class name.
  9049. * @return the class name
  9050. */
  9051. getClassName(): string;
  9052. /**
  9053. * Gets the parent skeleton
  9054. * @returns a skeleton
  9055. */
  9056. getSkeleton(): Skeleton;
  9057. /**
  9058. * Gets parent bone
  9059. * @returns a bone or null if the bone is the root of the bone hierarchy
  9060. */
  9061. getParent(): Nullable<Bone>;
  9062. /**
  9063. * Returns an array containing the root bones
  9064. * @returns an array containing the root bones
  9065. */
  9066. getChildren(): Array<Bone>;
  9067. /**
  9068. * Sets the parent bone
  9069. * @param parent defines the parent (can be null if the bone is the root)
  9070. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9071. */
  9072. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9073. /**
  9074. * Gets the local matrix
  9075. * @returns a matrix
  9076. */
  9077. getLocalMatrix(): Matrix;
  9078. /**
  9079. * Gets the base matrix (initial matrix which remains unchanged)
  9080. * @returns a matrix
  9081. */
  9082. getBaseMatrix(): Matrix;
  9083. /**
  9084. * Gets the rest pose matrix
  9085. * @returns a matrix
  9086. */
  9087. getRestPose(): Matrix;
  9088. /**
  9089. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9090. */
  9091. getWorldMatrix(): Matrix;
  9092. /**
  9093. * Sets the local matrix to rest pose matrix
  9094. */
  9095. returnToRest(): void;
  9096. /**
  9097. * Gets the inverse of the absolute transform matrix.
  9098. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9099. * @returns a matrix
  9100. */
  9101. getInvertedAbsoluteTransform(): Matrix;
  9102. /**
  9103. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9104. * @returns a matrix
  9105. */
  9106. getAbsoluteTransform(): Matrix;
  9107. /**
  9108. * Links with the given transform node.
  9109. * The local matrix of this bone is copied from the transform node every frame.
  9110. * @param transformNode defines the transform node to link to
  9111. */
  9112. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9113. /** Gets or sets current position (in local space) */
  9114. position: Vector3;
  9115. /** Gets or sets current rotation (in local space) */
  9116. rotation: Vector3;
  9117. /** Gets or sets current rotation quaternion (in local space) */
  9118. rotationQuaternion: Quaternion;
  9119. /** Gets or sets current scaling (in local space) */
  9120. scaling: Vector3;
  9121. /**
  9122. * Gets the animation properties override
  9123. */
  9124. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9125. private _decompose;
  9126. private _compose;
  9127. /**
  9128. * Update the base and local matrices
  9129. * @param matrix defines the new base or local matrix
  9130. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9131. * @param updateLocalMatrix defines if the local matrix should be updated
  9132. */
  9133. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9134. /** @hidden */
  9135. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9136. /**
  9137. * Flag the bone as dirty (Forcing it to update everything)
  9138. */
  9139. markAsDirty(): void;
  9140. /** @hidden */
  9141. _markAsDirtyAndCompose(): void;
  9142. private _markAsDirtyAndDecompose;
  9143. /**
  9144. * Translate the bone in local or world space
  9145. * @param vec The amount to translate the bone
  9146. * @param space The space that the translation is in
  9147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9148. */
  9149. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9150. /**
  9151. * Set the postion of the bone in local or world space
  9152. * @param position The position to set the bone
  9153. * @param space The space that the position is in
  9154. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9155. */
  9156. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9157. /**
  9158. * Set the absolute position of the bone (world space)
  9159. * @param position The position to set the bone
  9160. * @param mesh The mesh that this bone is attached to
  9161. */
  9162. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9163. /**
  9164. * Scale the bone on the x, y and z axes (in local space)
  9165. * @param x The amount to scale the bone on the x axis
  9166. * @param y The amount to scale the bone on the y axis
  9167. * @param z The amount to scale the bone on the z axis
  9168. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9169. */
  9170. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9171. /**
  9172. * Set the bone scaling in local space
  9173. * @param scale defines the scaling vector
  9174. */
  9175. setScale(scale: Vector3): void;
  9176. /**
  9177. * Gets the current scaling in local space
  9178. * @returns the current scaling vector
  9179. */
  9180. getScale(): Vector3;
  9181. /**
  9182. * Gets the current scaling in local space and stores it in a target vector
  9183. * @param result defines the target vector
  9184. */
  9185. getScaleToRef(result: Vector3): void;
  9186. /**
  9187. * Set the yaw, pitch, and roll of the bone in local or world space
  9188. * @param yaw The rotation of the bone on the y axis
  9189. * @param pitch The rotation of the bone on the x axis
  9190. * @param roll The rotation of the bone on the z axis
  9191. * @param space The space that the axes of rotation are in
  9192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9193. */
  9194. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9195. /**
  9196. * Add a rotation to the bone on an axis in local or world space
  9197. * @param axis The axis to rotate the bone on
  9198. * @param amount The amount to rotate the bone
  9199. * @param space The space that the axis is in
  9200. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9201. */
  9202. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9203. /**
  9204. * Set the rotation of the bone to a particular axis angle in local or world space
  9205. * @param axis The axis to rotate the bone on
  9206. * @param angle The angle that the bone should be rotated to
  9207. * @param space The space that the axis is in
  9208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9209. */
  9210. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9211. /**
  9212. * Set the euler rotation of the bone in local of world space
  9213. * @param rotation The euler rotation that the bone should be set to
  9214. * @param space The space that the rotation is in
  9215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9216. */
  9217. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9218. /**
  9219. * Set the quaternion rotation of the bone in local of world space
  9220. * @param quat The quaternion rotation that the bone should be set to
  9221. * @param space The space that the rotation is in
  9222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9223. */
  9224. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9225. /**
  9226. * Set the rotation matrix of the bone in local of world space
  9227. * @param rotMat The rotation matrix that the bone should be set to
  9228. * @param space The space that the rotation is in
  9229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9230. */
  9231. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9232. private _rotateWithMatrix;
  9233. private _getNegativeRotationToRef;
  9234. /**
  9235. * Get the position of the bone in local or world space
  9236. * @param space The space that the returned position is in
  9237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9238. * @returns The position of the bone
  9239. */
  9240. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9241. /**
  9242. * Copy the position of the bone to a vector3 in local or world space
  9243. * @param space The space that the returned position is in
  9244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9245. * @param result The vector3 to copy the position to
  9246. */
  9247. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9248. /**
  9249. * Get the absolute position of the bone (world space)
  9250. * @param mesh The mesh that this bone is attached to
  9251. * @returns The absolute position of the bone
  9252. */
  9253. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9254. /**
  9255. * Copy the absolute position of the bone (world space) to the result param
  9256. * @param mesh The mesh that this bone is attached to
  9257. * @param result The vector3 to copy the absolute position to
  9258. */
  9259. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9260. /**
  9261. * Compute the absolute transforms of this bone and its children
  9262. */
  9263. computeAbsoluteTransforms(): void;
  9264. /**
  9265. * Get the world direction from an axis that is in the local space of the bone
  9266. * @param localAxis The local direction that is used to compute the world direction
  9267. * @param mesh The mesh that this bone is attached to
  9268. * @returns The world direction
  9269. */
  9270. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9271. /**
  9272. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9273. * @param localAxis The local direction that is used to compute the world direction
  9274. * @param mesh The mesh that this bone is attached to
  9275. * @param result The vector3 that the world direction will be copied to
  9276. */
  9277. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9278. /**
  9279. * Get the euler rotation of the bone in local or world space
  9280. * @param space The space that the rotation should be in
  9281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9282. * @returns The euler rotation
  9283. */
  9284. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9285. /**
  9286. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9287. * @param space The space that the rotation should be in
  9288. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9289. * @param result The vector3 that the rotation should be copied to
  9290. */
  9291. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9292. /**
  9293. * Get the quaternion rotation of the bone in either local or world space
  9294. * @param space The space that the rotation should be in
  9295. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9296. * @returns The quaternion rotation
  9297. */
  9298. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9299. /**
  9300. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9301. * @param space The space that the rotation should be in
  9302. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9303. * @param result The quaternion that the rotation should be copied to
  9304. */
  9305. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9306. /**
  9307. * Get the rotation matrix of the bone in local or world space
  9308. * @param space The space that the rotation should be in
  9309. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9310. * @returns The rotation matrix
  9311. */
  9312. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9313. /**
  9314. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9315. * @param space The space that the rotation should be in
  9316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9317. * @param result The quaternion that the rotation should be copied to
  9318. */
  9319. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9320. /**
  9321. * Get the world position of a point that is in the local space of the bone
  9322. * @param position The local position
  9323. * @param mesh The mesh that this bone is attached to
  9324. * @returns The world position
  9325. */
  9326. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9327. /**
  9328. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9329. * @param position The local position
  9330. * @param mesh The mesh that this bone is attached to
  9331. * @param result The vector3 that the world position should be copied to
  9332. */
  9333. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9334. /**
  9335. * Get the local position of a point that is in world space
  9336. * @param position The world position
  9337. * @param mesh The mesh that this bone is attached to
  9338. * @returns The local position
  9339. */
  9340. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9341. /**
  9342. * Get the local position of a point that is in world space and copy it to the result param
  9343. * @param position The world position
  9344. * @param mesh The mesh that this bone is attached to
  9345. * @param result The vector3 that the local position should be copied to
  9346. */
  9347. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9348. }
  9349. }
  9350. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  9351. import { Nullable } from "babylonjs/types";
  9352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  9353. import { Scene } from "babylonjs/scene";
  9354. module "babylonjs/Engines/engine" {
  9355. interface Engine {
  9356. /**
  9357. * Creates a raw texture
  9358. * @param data defines the data to store in the texture
  9359. * @param width defines the width of the texture
  9360. * @param height defines the height of the texture
  9361. * @param format defines the format of the data
  9362. * @param generateMipMaps defines if the engine should generate the mip levels
  9363. * @param invertY defines if data must be stored with Y axis inverted
  9364. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9365. * @param compression defines the compression used (null by default)
  9366. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9367. * @returns the raw texture inside an InternalTexture
  9368. */
  9369. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9370. /**
  9371. * Update a raw texture
  9372. * @param texture defines the texture to update
  9373. * @param data defines the data to store in the texture
  9374. * @param format defines the format of the data
  9375. * @param invertY defines if data must be stored with Y axis inverted
  9376. */
  9377. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9378. /**
  9379. * Update a raw texture
  9380. * @param texture defines the texture to update
  9381. * @param data defines the data to store in the texture
  9382. * @param format defines the format of the data
  9383. * @param invertY defines if data must be stored with Y axis inverted
  9384. * @param compression defines the compression used (null by default)
  9385. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9386. */
  9387. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9388. /**
  9389. * Creates a new raw cube texture
  9390. * @param data defines the array of data to use to create each face
  9391. * @param size defines the size of the textures
  9392. * @param format defines the format of the data
  9393. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9394. * @param generateMipMaps defines if the engine should generate the mip levels
  9395. * @param invertY defines if data must be stored with Y axis inverted
  9396. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9397. * @param compression defines the compression used (null by default)
  9398. * @returns the cube texture as an InternalTexture
  9399. */
  9400. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9401. /**
  9402. * Update a raw cube texture
  9403. * @param texture defines the texture to udpdate
  9404. * @param data defines the data to store
  9405. * @param format defines the data format
  9406. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9407. * @param invertY defines if data must be stored with Y axis inverted
  9408. */
  9409. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9410. /**
  9411. * Update a raw cube texture
  9412. * @param texture defines the texture to udpdate
  9413. * @param data defines the data to store
  9414. * @param format defines the data format
  9415. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9416. * @param invertY defines if data must be stored with Y axis inverted
  9417. * @param compression defines the compression used (null by default)
  9418. */
  9419. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9420. /**
  9421. * Update a raw cube texture
  9422. * @param texture defines the texture to udpdate
  9423. * @param data defines the data to store
  9424. * @param format defines the data format
  9425. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9426. * @param invertY defines if data must be stored with Y axis inverted
  9427. * @param compression defines the compression used (null by default)
  9428. * @param level defines which level of the texture to update
  9429. */
  9430. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9431. /**
  9432. * Creates a new raw cube texture from a specified url
  9433. * @param url defines the url where the data is located
  9434. * @param scene defines the current scene
  9435. * @param size defines the size of the textures
  9436. * @param format defines the format of the data
  9437. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9438. * @param noMipmap defines if the engine should avoid generating the mip levels
  9439. * @param callback defines a callback used to extract texture data from loaded data
  9440. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9441. * @param onLoad defines a callback called when texture is loaded
  9442. * @param onError defines a callback called if there is an error
  9443. * @returns the cube texture as an InternalTexture
  9444. */
  9445. 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;
  9446. /**
  9447. * Creates a new raw cube texture from a specified url
  9448. * @param url defines the url where the data is located
  9449. * @param scene defines the current scene
  9450. * @param size defines the size of the textures
  9451. * @param format defines the format of the data
  9452. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9453. * @param noMipmap defines if the engine should avoid generating the mip levels
  9454. * @param callback defines a callback used to extract texture data from loaded data
  9455. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9456. * @param onLoad defines a callback called when texture is loaded
  9457. * @param onError defines a callback called if there is an error
  9458. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9459. * @param invertY defines if data must be stored with Y axis inverted
  9460. * @returns the cube texture as an InternalTexture
  9461. */
  9462. 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;
  9463. /**
  9464. * Creates a new raw 3D texture
  9465. * @param data defines the data used to create the texture
  9466. * @param width defines the width of the texture
  9467. * @param height defines the height of the texture
  9468. * @param depth defines the depth of the texture
  9469. * @param format defines the format of the texture
  9470. * @param generateMipMaps defines if the engine must generate mip levels
  9471. * @param invertY defines if data must be stored with Y axis inverted
  9472. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9473. * @param compression defines the compressed used (can be null)
  9474. * @param textureType defines the compressed used (can be null)
  9475. * @returns a new raw 3D texture (stored in an InternalTexture)
  9476. */
  9477. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9478. /**
  9479. * Update a raw 3D texture
  9480. * @param texture defines the texture to update
  9481. * @param data defines the data to store
  9482. * @param format defines the data format
  9483. * @param invertY defines if data must be stored with Y axis inverted
  9484. */
  9485. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9486. /**
  9487. * Update a raw 3D texture
  9488. * @param texture defines the texture to update
  9489. * @param data defines the data to store
  9490. * @param format defines the data format
  9491. * @param invertY defines if data must be stored with Y axis inverted
  9492. * @param compression defines the used compression (can be null)
  9493. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9494. */
  9495. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9496. }
  9497. }
  9498. }
  9499. declare module "babylonjs/Materials/Textures/rawTexture" {
  9500. import { Scene } from "babylonjs/scene";
  9501. import { Texture } from "babylonjs/Materials/Textures/texture";
  9502. import "babylonjs/Engines/Extensions/engine.rawTexture";
  9503. /**
  9504. * Raw texture can help creating a texture directly from an array of data.
  9505. * This can be super useful if you either get the data from an uncompressed source or
  9506. * if you wish to create your texture pixel by pixel.
  9507. */
  9508. export class RawTexture extends Texture {
  9509. /**
  9510. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9511. */
  9512. format: number;
  9513. private _engine;
  9514. /**
  9515. * Instantiates a new RawTexture.
  9516. * Raw texture can help creating a texture directly from an array of data.
  9517. * This can be super useful if you either get the data from an uncompressed source or
  9518. * if you wish to create your texture pixel by pixel.
  9519. * @param data define the array of data to use to create the texture
  9520. * @param width define the width of the texture
  9521. * @param height define the height of the texture
  9522. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9523. * @param scene define the scene the texture belongs to
  9524. * @param generateMipMaps define whether mip maps should be generated or not
  9525. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9526. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9527. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9528. */
  9529. constructor(data: ArrayBufferView, width: number, height: number,
  9530. /**
  9531. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9532. */
  9533. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9534. /**
  9535. * Updates the texture underlying data.
  9536. * @param data Define the new data of the texture
  9537. */
  9538. update(data: ArrayBufferView): void;
  9539. /**
  9540. * Creates a luminance texture from some data.
  9541. * @param data Define the texture data
  9542. * @param width Define the width of the texture
  9543. * @param height Define the height of the texture
  9544. * @param scene Define the scene the texture belongs to
  9545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9548. * @returns the luminance texture
  9549. */
  9550. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9551. /**
  9552. * Creates a luminance alpha texture from some data.
  9553. * @param data Define the texture data
  9554. * @param width Define the width of the texture
  9555. * @param height Define the height of the texture
  9556. * @param scene Define the scene the texture belongs to
  9557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9560. * @returns the luminance alpha texture
  9561. */
  9562. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9563. /**
  9564. * Creates an alpha texture from some data.
  9565. * @param data Define the texture data
  9566. * @param width Define the width of the texture
  9567. * @param height Define the height of the texture
  9568. * @param scene Define the scene the texture belongs to
  9569. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9572. * @returns the alpha texture
  9573. */
  9574. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9575. /**
  9576. * Creates a RGB texture from some data.
  9577. * @param data Define the texture data
  9578. * @param width Define the width of the texture
  9579. * @param height Define the height of the texture
  9580. * @param scene Define the scene the texture belongs to
  9581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9585. * @returns the RGB alpha texture
  9586. */
  9587. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9588. /**
  9589. * Creates a RGBA texture from some data.
  9590. * @param data Define the texture data
  9591. * @param width Define the width of the texture
  9592. * @param height Define the height of the texture
  9593. * @param scene Define the scene the texture belongs to
  9594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9597. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9598. * @returns the RGBA texture
  9599. */
  9600. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9601. /**
  9602. * Creates a R texture from some data.
  9603. * @param data Define the texture data
  9604. * @param width Define the width of the texture
  9605. * @param height Define the height of the texture
  9606. * @param scene Define the scene the texture belongs to
  9607. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9608. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9609. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9610. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9611. * @returns the R texture
  9612. */
  9613. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9614. }
  9615. }
  9616. declare module "babylonjs/Animations/runtimeAnimation" {
  9617. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  9618. import { Animatable } from "babylonjs/Animations/animatable";
  9619. import { Scene } from "babylonjs/scene";
  9620. /**
  9621. * Defines a runtime animation
  9622. */
  9623. export class RuntimeAnimation {
  9624. private _events;
  9625. /**
  9626. * The current frame of the runtime animation
  9627. */
  9628. private _currentFrame;
  9629. /**
  9630. * The animation used by the runtime animation
  9631. */
  9632. private _animation;
  9633. /**
  9634. * The target of the runtime animation
  9635. */
  9636. private _target;
  9637. /**
  9638. * The initiating animatable
  9639. */
  9640. private _host;
  9641. /**
  9642. * The original value of the runtime animation
  9643. */
  9644. private _originalValue;
  9645. /**
  9646. * The original blend value of the runtime animation
  9647. */
  9648. private _originalBlendValue;
  9649. /**
  9650. * The offsets cache of the runtime animation
  9651. */
  9652. private _offsetsCache;
  9653. /**
  9654. * The high limits cache of the runtime animation
  9655. */
  9656. private _highLimitsCache;
  9657. /**
  9658. * Specifies if the runtime animation has been stopped
  9659. */
  9660. private _stopped;
  9661. /**
  9662. * The blending factor of the runtime animation
  9663. */
  9664. private _blendingFactor;
  9665. /**
  9666. * The BabylonJS scene
  9667. */
  9668. private _scene;
  9669. /**
  9670. * The current value of the runtime animation
  9671. */
  9672. private _currentValue;
  9673. /** @hidden */
  9674. _animationState: _IAnimationState;
  9675. /**
  9676. * The active target of the runtime animation
  9677. */
  9678. private _activeTargets;
  9679. private _currentActiveTarget;
  9680. private _directTarget;
  9681. /**
  9682. * The target path of the runtime animation
  9683. */
  9684. private _targetPath;
  9685. /**
  9686. * The weight of the runtime animation
  9687. */
  9688. private _weight;
  9689. /**
  9690. * The ratio offset of the runtime animation
  9691. */
  9692. private _ratioOffset;
  9693. /**
  9694. * The previous delay of the runtime animation
  9695. */
  9696. private _previousDelay;
  9697. /**
  9698. * The previous ratio of the runtime animation
  9699. */
  9700. private _previousRatio;
  9701. private _enableBlending;
  9702. private _keys;
  9703. private _minFrame;
  9704. private _maxFrame;
  9705. private _minValue;
  9706. private _maxValue;
  9707. private _targetIsArray;
  9708. /**
  9709. * Gets the current frame of the runtime animation
  9710. */
  9711. readonly currentFrame: number;
  9712. /**
  9713. * Gets the weight of the runtime animation
  9714. */
  9715. readonly weight: number;
  9716. /**
  9717. * Gets the current value of the runtime animation
  9718. */
  9719. readonly currentValue: any;
  9720. /**
  9721. * Gets the target path of the runtime animation
  9722. */
  9723. readonly targetPath: string;
  9724. /**
  9725. * Gets the actual target of the runtime animation
  9726. */
  9727. readonly target: any;
  9728. /** @hidden */
  9729. _onLoop: () => void;
  9730. /**
  9731. * Create a new RuntimeAnimation object
  9732. * @param target defines the target of the animation
  9733. * @param animation defines the source animation object
  9734. * @param scene defines the hosting scene
  9735. * @param host defines the initiating Animatable
  9736. */
  9737. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9738. private _preparePath;
  9739. /**
  9740. * Gets the animation from the runtime animation
  9741. */
  9742. readonly animation: Animation;
  9743. /**
  9744. * Resets the runtime animation to the beginning
  9745. * @param restoreOriginal defines whether to restore the target property to the original value
  9746. */
  9747. reset(restoreOriginal?: boolean): void;
  9748. /**
  9749. * Specifies if the runtime animation is stopped
  9750. * @returns Boolean specifying if the runtime animation is stopped
  9751. */
  9752. isStopped(): boolean;
  9753. /**
  9754. * Disposes of the runtime animation
  9755. */
  9756. dispose(): void;
  9757. /**
  9758. * Apply the interpolated value to the target
  9759. * @param currentValue defines the value computed by the animation
  9760. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9761. */
  9762. setValue(currentValue: any, weight: number): void;
  9763. private _getOriginalValues;
  9764. private _setValue;
  9765. /**
  9766. * Gets the loop pmode of the runtime animation
  9767. * @returns Loop Mode
  9768. */
  9769. private _getCorrectLoopMode;
  9770. /**
  9771. * Move the current animation to a given frame
  9772. * @param frame defines the frame to move to
  9773. */
  9774. goToFrame(frame: number): void;
  9775. /**
  9776. * @hidden Internal use only
  9777. */
  9778. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9779. /**
  9780. * Execute the current animation
  9781. * @param delay defines the delay to add to the current frame
  9782. * @param from defines the lower bound of the animation range
  9783. * @param to defines the upper bound of the animation range
  9784. * @param loop defines if the current animation must loop
  9785. * @param speedRatio defines the current speed ratio
  9786. * @param weight defines the weight of the animation (default is -1 so no weight)
  9787. * @param onLoop optional callback called when animation loops
  9788. * @returns a boolean indicating if the animation is running
  9789. */
  9790. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9791. }
  9792. }
  9793. declare module "babylonjs/Animations/animatable" {
  9794. import { Animation } from "babylonjs/Animations/animation";
  9795. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  9796. import { Nullable } from "babylonjs/types";
  9797. import { Observable } from "babylonjs/Misc/observable";
  9798. import { Scene } from "babylonjs/scene";
  9799. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  9800. import { Node } from "babylonjs/node";
  9801. /**
  9802. * Class used to store an actual running animation
  9803. */
  9804. export class Animatable {
  9805. /** defines the target object */
  9806. target: any;
  9807. /** defines the starting frame number (default is 0) */
  9808. fromFrame: number;
  9809. /** defines the ending frame number (default is 100) */
  9810. toFrame: number;
  9811. /** defines if the animation must loop (default is false) */
  9812. loopAnimation: boolean;
  9813. /** defines a callback to call when animation ends if it is not looping */
  9814. onAnimationEnd?: (() => void) | null | undefined;
  9815. /** defines a callback to call when animation loops */
  9816. onAnimationLoop?: (() => void) | null | undefined;
  9817. private _localDelayOffset;
  9818. private _pausedDelay;
  9819. private _runtimeAnimations;
  9820. private _paused;
  9821. private _scene;
  9822. private _speedRatio;
  9823. private _weight;
  9824. private _syncRoot;
  9825. /**
  9826. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9827. * This will only apply for non looping animation (default is true)
  9828. */
  9829. disposeOnEnd: boolean;
  9830. /**
  9831. * Gets a boolean indicating if the animation has started
  9832. */
  9833. animationStarted: boolean;
  9834. /**
  9835. * Observer raised when the animation ends
  9836. */
  9837. onAnimationEndObservable: Observable<Animatable>;
  9838. /**
  9839. * Observer raised when the animation loops
  9840. */
  9841. onAnimationLoopObservable: Observable<Animatable>;
  9842. /**
  9843. * Gets the root Animatable used to synchronize and normalize animations
  9844. */
  9845. readonly syncRoot: Nullable<Animatable>;
  9846. /**
  9847. * Gets the current frame of the first RuntimeAnimation
  9848. * Used to synchronize Animatables
  9849. */
  9850. readonly masterFrame: number;
  9851. /**
  9852. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9853. */
  9854. weight: number;
  9855. /**
  9856. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9857. */
  9858. speedRatio: number;
  9859. /**
  9860. * Creates a new Animatable
  9861. * @param scene defines the hosting scene
  9862. * @param target defines the target object
  9863. * @param fromFrame defines the starting frame number (default is 0)
  9864. * @param toFrame defines the ending frame number (default is 100)
  9865. * @param loopAnimation defines if the animation must loop (default is false)
  9866. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9867. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9868. * @param animations defines a group of animation to add to the new Animatable
  9869. * @param onAnimationLoop defines a callback to call when animation loops
  9870. */
  9871. constructor(scene: Scene,
  9872. /** defines the target object */
  9873. target: any,
  9874. /** defines the starting frame number (default is 0) */
  9875. fromFrame?: number,
  9876. /** defines the ending frame number (default is 100) */
  9877. toFrame?: number,
  9878. /** defines if the animation must loop (default is false) */
  9879. loopAnimation?: boolean, speedRatio?: number,
  9880. /** defines a callback to call when animation ends if it is not looping */
  9881. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9882. /** defines a callback to call when animation loops */
  9883. onAnimationLoop?: (() => void) | null | undefined);
  9884. /**
  9885. * Synchronize and normalize current Animatable with a source Animatable
  9886. * This is useful when using animation weights and when animations are not of the same length
  9887. * @param root defines the root Animatable to synchronize with
  9888. * @returns the current Animatable
  9889. */
  9890. syncWith(root: Animatable): Animatable;
  9891. /**
  9892. * Gets the list of runtime animations
  9893. * @returns an array of RuntimeAnimation
  9894. */
  9895. getAnimations(): RuntimeAnimation[];
  9896. /**
  9897. * Adds more animations to the current animatable
  9898. * @param target defines the target of the animations
  9899. * @param animations defines the new animations to add
  9900. */
  9901. appendAnimations(target: any, animations: Animation[]): void;
  9902. /**
  9903. * Gets the source animation for a specific property
  9904. * @param property defines the propertyu to look for
  9905. * @returns null or the source animation for the given property
  9906. */
  9907. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9908. /**
  9909. * Gets the runtime animation for a specific property
  9910. * @param property defines the propertyu to look for
  9911. * @returns null or the runtime animation for the given property
  9912. */
  9913. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9914. /**
  9915. * Resets the animatable to its original state
  9916. */
  9917. reset(): void;
  9918. /**
  9919. * Allows the animatable to blend with current running animations
  9920. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9921. * @param blendingSpeed defines the blending speed to use
  9922. */
  9923. enableBlending(blendingSpeed: number): void;
  9924. /**
  9925. * Disable animation blending
  9926. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9927. */
  9928. disableBlending(): void;
  9929. /**
  9930. * Jump directly to a given frame
  9931. * @param frame defines the frame to jump to
  9932. */
  9933. goToFrame(frame: number): void;
  9934. /**
  9935. * Pause the animation
  9936. */
  9937. pause(): void;
  9938. /**
  9939. * Restart the animation
  9940. */
  9941. restart(): void;
  9942. private _raiseOnAnimationEnd;
  9943. /**
  9944. * Stop and delete the current animation
  9945. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9946. * @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)
  9947. */
  9948. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9949. /**
  9950. * Wait asynchronously for the animation to end
  9951. * @returns a promise which will be fullfilled when the animation ends
  9952. */
  9953. waitAsync(): Promise<Animatable>;
  9954. /** @hidden */
  9955. _animate(delay: number): boolean;
  9956. }
  9957. module "babylonjs/scene" {
  9958. interface Scene {
  9959. /** @hidden */
  9960. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9961. /** @hidden */
  9962. _processLateAnimationBindingsForMatrices(holder: {
  9963. totalWeight: number;
  9964. animations: RuntimeAnimation[];
  9965. originalValue: Matrix;
  9966. }): any;
  9967. /** @hidden */
  9968. _processLateAnimationBindingsForQuaternions(holder: {
  9969. totalWeight: number;
  9970. animations: RuntimeAnimation[];
  9971. originalValue: Quaternion;
  9972. }, refQuaternion: Quaternion): Quaternion;
  9973. /** @hidden */
  9974. _processLateAnimationBindings(): void;
  9975. /**
  9976. * Will start the animation sequence of a given target
  9977. * @param target defines the target
  9978. * @param from defines from which frame should animation start
  9979. * @param to defines until which frame should animation run.
  9980. * @param weight defines the weight to apply to the animation (1.0 by default)
  9981. * @param loop defines if the animation loops
  9982. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9983. * @param onAnimationEnd defines the function to be executed when the animation ends
  9984. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9985. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9986. * @param onAnimationLoop defines the callback to call when an animation loops
  9987. * @returns the animatable object created for this animation
  9988. */
  9989. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9990. /**
  9991. * Will start the animation sequence of a given target
  9992. * @param target defines the target
  9993. * @param from defines from which frame should animation start
  9994. * @param to defines until which frame should animation run.
  9995. * @param loop defines if the animation loops
  9996. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9997. * @param onAnimationEnd defines the function to be executed when the animation ends
  9998. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9999. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10000. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  10001. * @param onAnimationLoop defines the callback to call when an animation loops
  10002. * @returns the animatable object created for this animation
  10003. */
  10004. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  10005. /**
  10006. * Will start the animation sequence of a given target and its hierarchy
  10007. * @param target defines the target
  10008. * @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.
  10009. * @param from defines from which frame should animation start
  10010. * @param to defines until which frame should animation run.
  10011. * @param loop defines if the animation loops
  10012. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  10013. * @param onAnimationEnd defines the function to be executed when the animation ends
  10014. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  10015. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10016. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  10017. * @param onAnimationLoop defines the callback to call when an animation loops
  10018. * @returns the list of created animatables
  10019. */
  10020. 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[];
  10021. /**
  10022. * Begin a new animation on a given node
  10023. * @param target defines the target where the animation will take place
  10024. * @param animations defines the list of animations to start
  10025. * @param from defines the initial value
  10026. * @param to defines the final value
  10027. * @param loop defines if you want animation to loop (off by default)
  10028. * @param speedRatio defines the speed ratio to apply to all animations
  10029. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10030. * @param onAnimationLoop defines the callback to call when an animation loops
  10031. * @returns the list of created animatables
  10032. */
  10033. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  10034. /**
  10035. * Begin a new animation on a given node and its hierarchy
  10036. * @param target defines the root node where the animation will take place
  10037. * @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.
  10038. * @param animations defines the list of animations to start
  10039. * @param from defines the initial value
  10040. * @param to defines the final value
  10041. * @param loop defines if you want animation to loop (off by default)
  10042. * @param speedRatio defines the speed ratio to apply to all animations
  10043. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10044. * @param onAnimationLoop defines the callback to call when an animation loops
  10045. * @returns the list of animatables created for all nodes
  10046. */
  10047. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  10048. /**
  10049. * Gets the animatable associated with a specific target
  10050. * @param target defines the target of the animatable
  10051. * @returns the required animatable if found
  10052. */
  10053. getAnimatableByTarget(target: any): Nullable<Animatable>;
  10054. /**
  10055. * Gets all animatables associated with a given target
  10056. * @param target defines the target to look animatables for
  10057. * @returns an array of Animatables
  10058. */
  10059. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  10060. /**
  10061. * Stops and removes all animations that have been applied to the scene
  10062. */
  10063. stopAllAnimations(): void;
  10064. }
  10065. }
  10066. module "babylonjs/Bones/bone" {
  10067. interface Bone {
  10068. /**
  10069. * Copy an animation range from another bone
  10070. * @param source defines the source bone
  10071. * @param rangeName defines the range name to copy
  10072. * @param frameOffset defines the frame offset
  10073. * @param rescaleAsRequired defines if rescaling must be applied if required
  10074. * @param skelDimensionsRatio defines the scaling ratio
  10075. * @returns true if operation was successful
  10076. */
  10077. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  10078. }
  10079. }
  10080. }
  10081. declare module "babylonjs/Bones/skeleton" {
  10082. import { Bone } from "babylonjs/Bones/bone";
  10083. import { IAnimatable } from "babylonjs/Misc/tools";
  10084. import { Observable } from "babylonjs/Misc/observable";
  10085. import { Vector3, Matrix } from "babylonjs/Maths/math";
  10086. import { Scene } from "babylonjs/scene";
  10087. import { Nullable } from "babylonjs/types";
  10088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10089. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  10090. import { Animatable } from "babylonjs/Animations/animatable";
  10091. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10092. import { Animation } from "babylonjs/Animations/animation";
  10093. import { AnimationRange } from "babylonjs/Animations/animationRange";
  10094. import { IInspectable } from "babylonjs/Misc/iInspectable";
  10095. /**
  10096. * Class used to handle skinning animations
  10097. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  10098. */
  10099. export class Skeleton implements IAnimatable {
  10100. /** defines the skeleton name */
  10101. name: string;
  10102. /** defines the skeleton Id */
  10103. id: string;
  10104. /**
  10105. * Defines the list of child bones
  10106. */
  10107. bones: Bone[];
  10108. /**
  10109. * Defines an estimate of the dimension of the skeleton at rest
  10110. */
  10111. dimensionsAtRest: Vector3;
  10112. /**
  10113. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  10114. */
  10115. needInitialSkinMatrix: boolean;
  10116. /**
  10117. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  10118. */
  10119. overrideMesh: Nullable<AbstractMesh>;
  10120. /**
  10121. * Gets the list of animations attached to this skeleton
  10122. */
  10123. animations: Array<Animation>;
  10124. private _scene;
  10125. private _isDirty;
  10126. private _transformMatrices;
  10127. private _transformMatrixTexture;
  10128. private _meshesWithPoseMatrix;
  10129. private _animatables;
  10130. private _identity;
  10131. private _synchronizedWithMesh;
  10132. private _ranges;
  10133. private _lastAbsoluteTransformsUpdateId;
  10134. private _canUseTextureForBones;
  10135. private _uniqueId;
  10136. /** @hidden */
  10137. _numBonesWithLinkedTransformNode: number;
  10138. /** @hidden */
  10139. _hasWaitingData: Nullable<boolean>;
  10140. /**
  10141. * Specifies if the skeleton should be serialized
  10142. */
  10143. doNotSerialize: boolean;
  10144. private _useTextureToStoreBoneMatrices;
  10145. /**
  10146. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10147. * Please note that this option is not available if the hardware does not support it
  10148. */
  10149. useTextureToStoreBoneMatrices: boolean;
  10150. private _animationPropertiesOverride;
  10151. /**
  10152. * Gets or sets the animation properties override
  10153. */
  10154. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10155. /**
  10156. * List of inspectable custom properties (used by the Inspector)
  10157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10158. */
  10159. inspectableCustomProperties: IInspectable[];
  10160. /**
  10161. * An observable triggered before computing the skeleton's matrices
  10162. */
  10163. onBeforeComputeObservable: Observable<Skeleton>;
  10164. /**
  10165. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10166. */
  10167. readonly isUsingTextureForMatrices: boolean;
  10168. /**
  10169. * Gets the unique ID of this skeleton
  10170. */
  10171. readonly uniqueId: number;
  10172. /**
  10173. * Creates a new skeleton
  10174. * @param name defines the skeleton name
  10175. * @param id defines the skeleton Id
  10176. * @param scene defines the hosting scene
  10177. */
  10178. constructor(
  10179. /** defines the skeleton name */
  10180. name: string,
  10181. /** defines the skeleton Id */
  10182. id: string, scene: Scene);
  10183. /**
  10184. * Gets the current object class name.
  10185. * @return the class name
  10186. */
  10187. getClassName(): string;
  10188. /**
  10189. * Returns an array containing the root bones
  10190. * @returns an array containing the root bones
  10191. */
  10192. getChildren(): Array<Bone>;
  10193. /**
  10194. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10195. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10196. * @returns a Float32Array containing matrices data
  10197. */
  10198. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10199. /**
  10200. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10201. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10202. * @returns a raw texture containing the data
  10203. */
  10204. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  10205. /**
  10206. * Gets the current hosting scene
  10207. * @returns a scene object
  10208. */
  10209. getScene(): Scene;
  10210. /**
  10211. * Gets a string representing the current skeleton data
  10212. * @param fullDetails defines a boolean indicating if we want a verbose version
  10213. * @returns a string representing the current skeleton data
  10214. */
  10215. toString(fullDetails?: boolean): string;
  10216. /**
  10217. * Get bone's index searching by name
  10218. * @param name defines bone's name to search for
  10219. * @return the indice of the bone. Returns -1 if not found
  10220. */
  10221. getBoneIndexByName(name: string): number;
  10222. /**
  10223. * Creater a new animation range
  10224. * @param name defines the name of the range
  10225. * @param from defines the start key
  10226. * @param to defines the end key
  10227. */
  10228. createAnimationRange(name: string, from: number, to: number): void;
  10229. /**
  10230. * Delete a specific animation range
  10231. * @param name defines the name of the range
  10232. * @param deleteFrames defines if frames must be removed as well
  10233. */
  10234. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10235. /**
  10236. * Gets a specific animation range
  10237. * @param name defines the name of the range to look for
  10238. * @returns the requested animation range or null if not found
  10239. */
  10240. getAnimationRange(name: string): Nullable<AnimationRange>;
  10241. /**
  10242. * Gets the list of all animation ranges defined on this skeleton
  10243. * @returns an array
  10244. */
  10245. getAnimationRanges(): Nullable<AnimationRange>[];
  10246. /**
  10247. * Copy animation range from a source skeleton.
  10248. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10249. * @param source defines the source skeleton
  10250. * @param name defines the name of the range to copy
  10251. * @param rescaleAsRequired defines if rescaling must be applied if required
  10252. * @returns true if operation was successful
  10253. */
  10254. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10255. /**
  10256. * Forces the skeleton to go to rest pose
  10257. */
  10258. returnToRest(): void;
  10259. private _getHighestAnimationFrame;
  10260. /**
  10261. * Begin a specific animation range
  10262. * @param name defines the name of the range to start
  10263. * @param loop defines if looping must be turned on (false by default)
  10264. * @param speedRatio defines the speed ratio to apply (1 by default)
  10265. * @param onAnimationEnd defines a callback which will be called when animation will end
  10266. * @returns a new animatable
  10267. */
  10268. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10269. /** @hidden */
  10270. _markAsDirty(): void;
  10271. /** @hidden */
  10272. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10273. /** @hidden */
  10274. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10275. private _computeTransformMatrices;
  10276. /**
  10277. * Build all resources required to render a skeleton
  10278. */
  10279. prepare(): void;
  10280. /**
  10281. * Gets the list of animatables currently running for this skeleton
  10282. * @returns an array of animatables
  10283. */
  10284. getAnimatables(): IAnimatable[];
  10285. /**
  10286. * Clone the current skeleton
  10287. * @param name defines the name of the new skeleton
  10288. * @param id defines the id of the new skeleton
  10289. * @returns the new skeleton
  10290. */
  10291. clone(name: string, id: string): Skeleton;
  10292. /**
  10293. * Enable animation blending for this skeleton
  10294. * @param blendingSpeed defines the blending speed to apply
  10295. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10296. */
  10297. enableBlending(blendingSpeed?: number): void;
  10298. /**
  10299. * Releases all resources associated with the current skeleton
  10300. */
  10301. dispose(): void;
  10302. /**
  10303. * Serialize the skeleton in a JSON object
  10304. * @returns a JSON object
  10305. */
  10306. serialize(): any;
  10307. /**
  10308. * Creates a new skeleton from serialized data
  10309. * @param parsedSkeleton defines the serialized data
  10310. * @param scene defines the hosting scene
  10311. * @returns a new skeleton
  10312. */
  10313. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10314. /**
  10315. * Compute all node absolute transforms
  10316. * @param forceUpdate defines if computation must be done even if cache is up to date
  10317. */
  10318. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10319. /**
  10320. * Gets the root pose matrix
  10321. * @returns a matrix
  10322. */
  10323. getPoseMatrix(): Nullable<Matrix>;
  10324. /**
  10325. * Sorts bones per internal index
  10326. */
  10327. sortBones(): void;
  10328. private _sortBones;
  10329. }
  10330. }
  10331. declare module "babylonjs/Morph/morphTarget" {
  10332. import { IAnimatable } from "babylonjs/Misc/tools";
  10333. import { Observable } from "babylonjs/Misc/observable";
  10334. import { Nullable, FloatArray } from "babylonjs/types";
  10335. import { Scene } from "babylonjs/scene";
  10336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10337. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10338. /**
  10339. * Defines a target to use with MorphTargetManager
  10340. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10341. */
  10342. export class MorphTarget implements IAnimatable {
  10343. /** defines the name of the target */
  10344. name: string;
  10345. /**
  10346. * Gets or sets the list of animations
  10347. */
  10348. animations: import("babylonjs/Animations/animation").Animation[];
  10349. private _scene;
  10350. private _positions;
  10351. private _normals;
  10352. private _tangents;
  10353. private _uvs;
  10354. private _influence;
  10355. /**
  10356. * Observable raised when the influence changes
  10357. */
  10358. onInfluenceChanged: Observable<boolean>;
  10359. /** @hidden */
  10360. _onDataLayoutChanged: Observable<void>;
  10361. /**
  10362. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10363. */
  10364. influence: number;
  10365. /**
  10366. * Gets or sets the id of the morph Target
  10367. */
  10368. id: string;
  10369. private _animationPropertiesOverride;
  10370. /**
  10371. * Gets or sets the animation properties override
  10372. */
  10373. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10374. /**
  10375. * Creates a new MorphTarget
  10376. * @param name defines the name of the target
  10377. * @param influence defines the influence to use
  10378. * @param scene defines the scene the morphtarget belongs to
  10379. */
  10380. constructor(
  10381. /** defines the name of the target */
  10382. name: string, influence?: number, scene?: Nullable<Scene>);
  10383. /**
  10384. * Gets a boolean defining if the target contains position data
  10385. */
  10386. readonly hasPositions: boolean;
  10387. /**
  10388. * Gets a boolean defining if the target contains normal data
  10389. */
  10390. readonly hasNormals: boolean;
  10391. /**
  10392. * Gets a boolean defining if the target contains tangent data
  10393. */
  10394. readonly hasTangents: boolean;
  10395. /**
  10396. * Gets a boolean defining if the target contains texture coordinates data
  10397. */
  10398. readonly hasUVs: boolean;
  10399. /**
  10400. * Affects position data to this target
  10401. * @param data defines the position data to use
  10402. */
  10403. setPositions(data: Nullable<FloatArray>): void;
  10404. /**
  10405. * Gets the position data stored in this target
  10406. * @returns a FloatArray containing the position data (or null if not present)
  10407. */
  10408. getPositions(): Nullable<FloatArray>;
  10409. /**
  10410. * Affects normal data to this target
  10411. * @param data defines the normal data to use
  10412. */
  10413. setNormals(data: Nullable<FloatArray>): void;
  10414. /**
  10415. * Gets the normal data stored in this target
  10416. * @returns a FloatArray containing the normal data (or null if not present)
  10417. */
  10418. getNormals(): Nullable<FloatArray>;
  10419. /**
  10420. * Affects tangent data to this target
  10421. * @param data defines the tangent data to use
  10422. */
  10423. setTangents(data: Nullable<FloatArray>): void;
  10424. /**
  10425. * Gets the tangent data stored in this target
  10426. * @returns a FloatArray containing the tangent data (or null if not present)
  10427. */
  10428. getTangents(): Nullable<FloatArray>;
  10429. /**
  10430. * Affects texture coordinates data to this target
  10431. * @param data defines the texture coordinates data to use
  10432. */
  10433. setUVs(data: Nullable<FloatArray>): void;
  10434. /**
  10435. * Gets the texture coordinates data stored in this target
  10436. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10437. */
  10438. getUVs(): Nullable<FloatArray>;
  10439. /**
  10440. * Serializes the current target into a Serialization object
  10441. * @returns the serialized object
  10442. */
  10443. serialize(): any;
  10444. /**
  10445. * Returns the string "MorphTarget"
  10446. * @returns "MorphTarget"
  10447. */
  10448. getClassName(): string;
  10449. /**
  10450. * Creates a new target from serialized data
  10451. * @param serializationObject defines the serialized data to use
  10452. * @returns a new MorphTarget
  10453. */
  10454. static Parse(serializationObject: any): MorphTarget;
  10455. /**
  10456. * Creates a MorphTarget from mesh data
  10457. * @param mesh defines the source mesh
  10458. * @param name defines the name to use for the new target
  10459. * @param influence defines the influence to attach to the target
  10460. * @returns a new MorphTarget
  10461. */
  10462. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10463. }
  10464. }
  10465. declare module "babylonjs/Morph/morphTargetManager" {
  10466. import { Nullable } from "babylonjs/types";
  10467. import { Scene } from "babylonjs/scene";
  10468. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  10469. /**
  10470. * This class is used to deform meshes using morphing between different targets
  10471. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10472. */
  10473. export class MorphTargetManager {
  10474. private _targets;
  10475. private _targetInfluenceChangedObservers;
  10476. private _targetDataLayoutChangedObservers;
  10477. private _activeTargets;
  10478. private _scene;
  10479. private _influences;
  10480. private _supportsNormals;
  10481. private _supportsTangents;
  10482. private _supportsUVs;
  10483. private _vertexCount;
  10484. private _uniqueId;
  10485. private _tempInfluences;
  10486. /**
  10487. * Gets or sets a boolean indicating if normals must be morphed
  10488. */
  10489. enableNormalMorphing: boolean;
  10490. /**
  10491. * Gets or sets a boolean indicating if tangents must be morphed
  10492. */
  10493. enableTangentMorphing: boolean;
  10494. /**
  10495. * Gets or sets a boolean indicating if UV must be morphed
  10496. */
  10497. enableUVMorphing: boolean;
  10498. /**
  10499. * Creates a new MorphTargetManager
  10500. * @param scene defines the current scene
  10501. */
  10502. constructor(scene?: Nullable<Scene>);
  10503. /**
  10504. * Gets the unique ID of this manager
  10505. */
  10506. readonly uniqueId: number;
  10507. /**
  10508. * Gets the number of vertices handled by this manager
  10509. */
  10510. readonly vertexCount: number;
  10511. /**
  10512. * Gets a boolean indicating if this manager supports morphing of normals
  10513. */
  10514. readonly supportsNormals: boolean;
  10515. /**
  10516. * Gets a boolean indicating if this manager supports morphing of tangents
  10517. */
  10518. readonly supportsTangents: boolean;
  10519. /**
  10520. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10521. */
  10522. readonly supportsUVs: boolean;
  10523. /**
  10524. * Gets the number of targets stored in this manager
  10525. */
  10526. readonly numTargets: number;
  10527. /**
  10528. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10529. */
  10530. readonly numInfluencers: number;
  10531. /**
  10532. * Gets the list of influences (one per target)
  10533. */
  10534. readonly influences: Float32Array;
  10535. /**
  10536. * Gets the active target at specified index. An active target is a target with an influence > 0
  10537. * @param index defines the index to check
  10538. * @returns the requested target
  10539. */
  10540. getActiveTarget(index: number): MorphTarget;
  10541. /**
  10542. * Gets the target at specified index
  10543. * @param index defines the index to check
  10544. * @returns the requested target
  10545. */
  10546. getTarget(index: number): MorphTarget;
  10547. /**
  10548. * Add a new target to this manager
  10549. * @param target defines the target to add
  10550. */
  10551. addTarget(target: MorphTarget): void;
  10552. /**
  10553. * Removes a target from the manager
  10554. * @param target defines the target to remove
  10555. */
  10556. removeTarget(target: MorphTarget): void;
  10557. /**
  10558. * Serializes the current manager into a Serialization object
  10559. * @returns the serialized object
  10560. */
  10561. serialize(): any;
  10562. private _syncActiveTargets;
  10563. /**
  10564. * Syncrhonize the targets with all the meshes using this morph target manager
  10565. */
  10566. synchronize(): void;
  10567. /**
  10568. * Creates a new MorphTargetManager from serialized data
  10569. * @param serializationObject defines the serialized data
  10570. * @param scene defines the hosting scene
  10571. * @returns the new MorphTargetManager
  10572. */
  10573. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10574. }
  10575. }
  10576. declare module "babylonjs/sceneComponent" {
  10577. import { Scene } from "babylonjs/scene";
  10578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10579. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10580. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10581. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10582. import { Nullable } from "babylonjs/types";
  10583. import { Camera } from "babylonjs/Cameras/camera";
  10584. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10585. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10586. import { AbstractScene } from "babylonjs/abstractScene";
  10587. /**
  10588. * Groups all the scene component constants in one place to ease maintenance.
  10589. * @hidden
  10590. */
  10591. export class SceneComponentConstants {
  10592. static readonly NAME_EFFECTLAYER: string;
  10593. static readonly NAME_LAYER: string;
  10594. static readonly NAME_LENSFLARESYSTEM: string;
  10595. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10596. static readonly NAME_PARTICLESYSTEM: string;
  10597. static readonly NAME_GAMEPAD: string;
  10598. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10599. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10600. static readonly NAME_DEPTHRENDERER: string;
  10601. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10602. static readonly NAME_SPRITE: string;
  10603. static readonly NAME_OUTLINERENDERER: string;
  10604. static readonly NAME_PROCEDURALTEXTURE: string;
  10605. static readonly NAME_SHADOWGENERATOR: string;
  10606. static readonly NAME_OCTREE: string;
  10607. static readonly NAME_PHYSICSENGINE: string;
  10608. static readonly NAME_AUDIO: string;
  10609. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10610. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10611. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10612. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10613. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10614. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10615. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10616. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10617. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10618. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10619. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10620. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10621. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10622. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10623. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10624. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10625. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10626. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10627. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10628. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10629. static readonly STEP_AFTERRENDER_AUDIO: number;
  10630. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10631. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10632. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10633. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10634. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10635. static readonly STEP_POINTERMOVE_SPRITE: number;
  10636. static readonly STEP_POINTERDOWN_SPRITE: number;
  10637. static readonly STEP_POINTERUP_SPRITE: number;
  10638. }
  10639. /**
  10640. * This represents a scene component.
  10641. *
  10642. * This is used to decouple the dependency the scene is having on the different workloads like
  10643. * layers, post processes...
  10644. */
  10645. export interface ISceneComponent {
  10646. /**
  10647. * The name of the component. Each component must have a unique name.
  10648. */
  10649. name: string;
  10650. /**
  10651. * The scene the component belongs to.
  10652. */
  10653. scene: Scene;
  10654. /**
  10655. * Register the component to one instance of a scene.
  10656. */
  10657. register(): void;
  10658. /**
  10659. * Rebuilds the elements related to this component in case of
  10660. * context lost for instance.
  10661. */
  10662. rebuild(): void;
  10663. /**
  10664. * Disposes the component and the associated ressources.
  10665. */
  10666. dispose(): void;
  10667. }
  10668. /**
  10669. * This represents a SERIALIZABLE scene component.
  10670. *
  10671. * This extends Scene Component to add Serialization methods on top.
  10672. */
  10673. export interface ISceneSerializableComponent extends ISceneComponent {
  10674. /**
  10675. * Adds all the elements from the container to the scene
  10676. * @param container the container holding the elements
  10677. */
  10678. addFromContainer(container: AbstractScene): void;
  10679. /**
  10680. * Removes all the elements in the container from the scene
  10681. * @param container contains the elements to remove
  10682. * @param dispose if the removed element should be disposed (default: false)
  10683. */
  10684. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10685. /**
  10686. * Serializes the component data to the specified json object
  10687. * @param serializationObject The object to serialize to
  10688. */
  10689. serialize(serializationObject: any): void;
  10690. }
  10691. /**
  10692. * Strong typing of a Mesh related stage step action
  10693. */
  10694. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10695. /**
  10696. * Strong typing of a Evaluate Sub Mesh related stage step action
  10697. */
  10698. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10699. /**
  10700. * Strong typing of a Active Mesh related stage step action
  10701. */
  10702. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10703. /**
  10704. * Strong typing of a Camera related stage step action
  10705. */
  10706. export type CameraStageAction = (camera: Camera) => void;
  10707. /**
  10708. * Strong typing of a Camera Frame buffer related stage step action
  10709. */
  10710. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10711. /**
  10712. * Strong typing of a Render Target related stage step action
  10713. */
  10714. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10715. /**
  10716. * Strong typing of a RenderingGroup related stage step action
  10717. */
  10718. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10719. /**
  10720. * Strong typing of a Mesh Render related stage step action
  10721. */
  10722. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10723. /**
  10724. * Strong typing of a simple stage step action
  10725. */
  10726. export type SimpleStageAction = () => void;
  10727. /**
  10728. * Strong typing of a render target action.
  10729. */
  10730. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10731. /**
  10732. * Strong typing of a pointer move action.
  10733. */
  10734. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10735. /**
  10736. * Strong typing of a pointer up/down action.
  10737. */
  10738. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10739. /**
  10740. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10741. * @hidden
  10742. */
  10743. export class Stage<T extends Function> extends Array<{
  10744. index: number;
  10745. component: ISceneComponent;
  10746. action: T;
  10747. }> {
  10748. /**
  10749. * Hide ctor from the rest of the world.
  10750. * @param items The items to add.
  10751. */
  10752. private constructor();
  10753. /**
  10754. * Creates a new Stage.
  10755. * @returns A new instance of a Stage
  10756. */
  10757. static Create<T extends Function>(): Stage<T>;
  10758. /**
  10759. * Registers a step in an ordered way in the targeted stage.
  10760. * @param index Defines the position to register the step in
  10761. * @param component Defines the component attached to the step
  10762. * @param action Defines the action to launch during the step
  10763. */
  10764. registerStep(index: number, component: ISceneComponent, action: T): void;
  10765. /**
  10766. * Clears all the steps from the stage.
  10767. */
  10768. clear(): void;
  10769. }
  10770. }
  10771. declare module "babylonjs/Meshes/meshLODLevel" {
  10772. import { Mesh } from "babylonjs/Meshes/mesh";
  10773. import { Nullable } from "babylonjs/types";
  10774. /**
  10775. * Class used to represent a specific level of detail of a mesh
  10776. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10777. */
  10778. export class MeshLODLevel {
  10779. /** Defines the distance where this level should star being displayed */
  10780. distance: number;
  10781. /** Defines the mesh to use to render this level */
  10782. mesh: Nullable<Mesh>;
  10783. /**
  10784. * Creates a new LOD level
  10785. * @param distance defines the distance where this level should star being displayed
  10786. * @param mesh defines the mesh to use to render this level
  10787. */
  10788. constructor(
  10789. /** Defines the distance where this level should star being displayed */
  10790. distance: number,
  10791. /** Defines the mesh to use to render this level */
  10792. mesh: Nullable<Mesh>);
  10793. }
  10794. }
  10795. declare module "babylonjs/Lights/shadowLight" {
  10796. import { Camera } from "babylonjs/Cameras/camera";
  10797. import { Scene } from "babylonjs/scene";
  10798. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10800. import { Light } from "babylonjs/Lights/light";
  10801. /**
  10802. * Interface describing all the common properties and methods a shadow light needs to implement.
  10803. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10804. * as well as binding the different shadow properties to the effects.
  10805. */
  10806. export interface IShadowLight extends Light {
  10807. /**
  10808. * The light id in the scene (used in scene.findLighById for instance)
  10809. */
  10810. id: string;
  10811. /**
  10812. * The position the shdow will be casted from.
  10813. */
  10814. position: Vector3;
  10815. /**
  10816. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10817. */
  10818. direction: Vector3;
  10819. /**
  10820. * The transformed position. Position of the light in world space taking parenting in account.
  10821. */
  10822. transformedPosition: Vector3;
  10823. /**
  10824. * The transformed direction. Direction of the light in world space taking parenting in account.
  10825. */
  10826. transformedDirection: Vector3;
  10827. /**
  10828. * The friendly name of the light in the scene.
  10829. */
  10830. name: string;
  10831. /**
  10832. * Defines the shadow projection clipping minimum z value.
  10833. */
  10834. shadowMinZ: number;
  10835. /**
  10836. * Defines the shadow projection clipping maximum z value.
  10837. */
  10838. shadowMaxZ: number;
  10839. /**
  10840. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10841. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10842. */
  10843. computeTransformedInformation(): boolean;
  10844. /**
  10845. * Gets the scene the light belongs to.
  10846. * @returns The scene
  10847. */
  10848. getScene(): Scene;
  10849. /**
  10850. * Callback defining a custom Projection Matrix Builder.
  10851. * This can be used to override the default projection matrix computation.
  10852. */
  10853. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10854. /**
  10855. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10856. * @param matrix The materix to updated with the projection information
  10857. * @param viewMatrix The transform matrix of the light
  10858. * @param renderList The list of mesh to render in the map
  10859. * @returns The current light
  10860. */
  10861. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10862. /**
  10863. * Gets the current depth scale used in ESM.
  10864. * @returns The scale
  10865. */
  10866. getDepthScale(): number;
  10867. /**
  10868. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10869. * @returns true if a cube texture needs to be use
  10870. */
  10871. needCube(): boolean;
  10872. /**
  10873. * Detects if the projection matrix requires to be recomputed this frame.
  10874. * @returns true if it requires to be recomputed otherwise, false.
  10875. */
  10876. needProjectionMatrixCompute(): boolean;
  10877. /**
  10878. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10879. */
  10880. forceProjectionMatrixCompute(): void;
  10881. /**
  10882. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10883. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10884. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10885. */
  10886. getShadowDirection(faceIndex?: number): Vector3;
  10887. /**
  10888. * Gets the minZ used for shadow according to both the scene and the light.
  10889. * @param activeCamera The camera we are returning the min for
  10890. * @returns the depth min z
  10891. */
  10892. getDepthMinZ(activeCamera: Camera): number;
  10893. /**
  10894. * Gets the maxZ used for shadow according to both the scene and the light.
  10895. * @param activeCamera The camera we are returning the max for
  10896. * @returns the depth max z
  10897. */
  10898. getDepthMaxZ(activeCamera: Camera): number;
  10899. }
  10900. /**
  10901. * Base implementation IShadowLight
  10902. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10903. */
  10904. export abstract class ShadowLight extends Light implements IShadowLight {
  10905. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10906. protected _position: Vector3;
  10907. protected _setPosition(value: Vector3): void;
  10908. /**
  10909. * Sets the position the shadow will be casted from. Also use as the light position for both
  10910. * point and spot lights.
  10911. */
  10912. /**
  10913. * Sets the position the shadow will be casted from. Also use as the light position for both
  10914. * point and spot lights.
  10915. */
  10916. position: Vector3;
  10917. protected _direction: Vector3;
  10918. protected _setDirection(value: Vector3): void;
  10919. /**
  10920. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10921. * Also use as the light direction on spot and directional lights.
  10922. */
  10923. /**
  10924. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10925. * Also use as the light direction on spot and directional lights.
  10926. */
  10927. direction: Vector3;
  10928. private _shadowMinZ;
  10929. /**
  10930. * Gets the shadow projection clipping minimum z value.
  10931. */
  10932. /**
  10933. * Sets the shadow projection clipping minimum z value.
  10934. */
  10935. shadowMinZ: number;
  10936. private _shadowMaxZ;
  10937. /**
  10938. * Sets the shadow projection clipping maximum z value.
  10939. */
  10940. /**
  10941. * Gets the shadow projection clipping maximum z value.
  10942. */
  10943. shadowMaxZ: number;
  10944. /**
  10945. * Callback defining a custom Projection Matrix Builder.
  10946. * This can be used to override the default projection matrix computation.
  10947. */
  10948. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10949. /**
  10950. * The transformed position. Position of the light in world space taking parenting in account.
  10951. */
  10952. transformedPosition: Vector3;
  10953. /**
  10954. * The transformed direction. Direction of the light in world space taking parenting in account.
  10955. */
  10956. transformedDirection: Vector3;
  10957. private _needProjectionMatrixCompute;
  10958. /**
  10959. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10960. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10961. */
  10962. computeTransformedInformation(): boolean;
  10963. /**
  10964. * Return the depth scale used for the shadow map.
  10965. * @returns the depth scale.
  10966. */
  10967. getDepthScale(): number;
  10968. /**
  10969. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10970. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10971. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10972. */
  10973. getShadowDirection(faceIndex?: number): Vector3;
  10974. /**
  10975. * Returns the ShadowLight absolute position in the World.
  10976. * @returns the position vector in world space
  10977. */
  10978. getAbsolutePosition(): Vector3;
  10979. /**
  10980. * Sets the ShadowLight direction toward the passed target.
  10981. * @param target The point to target in local space
  10982. * @returns the updated ShadowLight direction
  10983. */
  10984. setDirectionToTarget(target: Vector3): Vector3;
  10985. /**
  10986. * Returns the light rotation in euler definition.
  10987. * @returns the x y z rotation in local space.
  10988. */
  10989. getRotation(): Vector3;
  10990. /**
  10991. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10992. * @returns true if a cube texture needs to be use
  10993. */
  10994. needCube(): boolean;
  10995. /**
  10996. * Detects if the projection matrix requires to be recomputed this frame.
  10997. * @returns true if it requires to be recomputed otherwise, false.
  10998. */
  10999. needProjectionMatrixCompute(): boolean;
  11000. /**
  11001. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11002. */
  11003. forceProjectionMatrixCompute(): void;
  11004. /** @hidden */
  11005. _initCache(): void;
  11006. /** @hidden */
  11007. _isSynchronized(): boolean;
  11008. /**
  11009. * Computes the world matrix of the node
  11010. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  11011. * @returns the world matrix
  11012. */
  11013. computeWorldMatrix(force?: boolean): Matrix;
  11014. /**
  11015. * Gets the minZ used for shadow according to both the scene and the light.
  11016. * @param activeCamera The camera we are returning the min for
  11017. * @returns the depth min z
  11018. */
  11019. getDepthMinZ(activeCamera: Camera): number;
  11020. /**
  11021. * Gets the maxZ used for shadow according to both the scene and the light.
  11022. * @param activeCamera The camera we are returning the max for
  11023. * @returns the depth max z
  11024. */
  11025. getDepthMaxZ(activeCamera: Camera): number;
  11026. /**
  11027. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11028. * @param matrix The materix to updated with the projection information
  11029. * @param viewMatrix The transform matrix of the light
  11030. * @param renderList The list of mesh to render in the map
  11031. * @returns The current light
  11032. */
  11033. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11034. }
  11035. }
  11036. declare module "babylonjs/Materials/materialHelper" {
  11037. import { Nullable } from "babylonjs/types";
  11038. import { Scene } from "babylonjs/scene";
  11039. import { Engine } from "babylonjs/Engines/engine";
  11040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11041. import { Light } from "babylonjs/Lights/light";
  11042. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11043. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  11044. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11045. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11046. /**
  11047. * "Static Class" containing the most commonly used helper while dealing with material for
  11048. * rendering purpose.
  11049. *
  11050. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  11051. *
  11052. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  11053. */
  11054. export class MaterialHelper {
  11055. /**
  11056. * Bind the current view position to an effect.
  11057. * @param effect The effect to be bound
  11058. * @param scene The scene the eyes position is used from
  11059. */
  11060. static BindEyePosition(effect: Effect, scene: Scene): void;
  11061. /**
  11062. * Helps preparing the defines values about the UVs in used in the effect.
  11063. * UVs are shared as much as we can accross channels in the shaders.
  11064. * @param texture The texture we are preparing the UVs for
  11065. * @param defines The defines to update
  11066. * @param key The channel key "diffuse", "specular"... used in the shader
  11067. */
  11068. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  11069. /**
  11070. * Binds a texture matrix value to its corrsponding uniform
  11071. * @param texture The texture to bind the matrix for
  11072. * @param uniformBuffer The uniform buffer receivin the data
  11073. * @param key The channel key "diffuse", "specular"... used in the shader
  11074. */
  11075. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  11076. /**
  11077. * Gets the current status of the fog (should it be enabled?)
  11078. * @param mesh defines the mesh to evaluate for fog support
  11079. * @param scene defines the hosting scene
  11080. * @returns true if fog must be enabled
  11081. */
  11082. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  11083. /**
  11084. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  11085. * @param mesh defines the current mesh
  11086. * @param scene defines the current scene
  11087. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  11088. * @param pointsCloud defines if point cloud rendering has to be turned on
  11089. * @param fogEnabled defines if fog has to be turned on
  11090. * @param alphaTest defines if alpha testing has to be turned on
  11091. * @param defines defines the current list of defines
  11092. */
  11093. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  11094. /**
  11095. * Helper used to prepare the list of defines associated with frame values for shader compilation
  11096. * @param scene defines the current scene
  11097. * @param engine defines the current engine
  11098. * @param defines specifies the list of active defines
  11099. * @param useInstances defines if instances have to be turned on
  11100. * @param useClipPlane defines if clip plane have to be turned on
  11101. */
  11102. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  11103. /**
  11104. * Prepares the defines for bones
  11105. * @param mesh The mesh containing the geometry data we will draw
  11106. * @param defines The defines to update
  11107. */
  11108. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  11109. /**
  11110. * Prepares the defines for morph targets
  11111. * @param mesh The mesh containing the geometry data we will draw
  11112. * @param defines The defines to update
  11113. */
  11114. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  11115. /**
  11116. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  11117. * @param mesh The mesh containing the geometry data we will draw
  11118. * @param defines The defines to update
  11119. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  11120. * @param useBones Precise whether bones should be used or not (override mesh info)
  11121. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  11122. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  11123. * @returns false if defines are considered not dirty and have not been checked
  11124. */
  11125. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  11126. /**
  11127. * Prepares the defines related to multiview
  11128. * @param scene The scene we are intending to draw
  11129. * @param defines The defines to update
  11130. */
  11131. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  11132. /**
  11133. * Prepares the defines related to the light information passed in parameter
  11134. * @param scene The scene we are intending to draw
  11135. * @param mesh The mesh the effect is compiling for
  11136. * @param light The light the effect is compiling for
  11137. * @param lightIndex The index of the light
  11138. * @param defines The defines to update
  11139. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11140. * @param state Defines the current state regarding what is needed (normals, etc...)
  11141. */
  11142. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  11143. needNormals: boolean;
  11144. needRebuild: boolean;
  11145. shadowEnabled: boolean;
  11146. specularEnabled: boolean;
  11147. lightmapMode: boolean;
  11148. }): void;
  11149. /**
  11150. * Prepares the defines related to the light information passed in parameter
  11151. * @param scene The scene we are intending to draw
  11152. * @param mesh The mesh the effect is compiling for
  11153. * @param defines The defines to update
  11154. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11155. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  11156. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  11157. * @returns true if normals will be required for the rest of the effect
  11158. */
  11159. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  11160. /**
  11161. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  11162. * @param lightIndex defines the light index
  11163. * @param uniformsList The uniform list
  11164. * @param samplersList The sampler list
  11165. * @param projectedLightTexture defines if projected texture must be used
  11166. * @param uniformBuffersList defines an optional list of uniform buffers
  11167. */
  11168. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  11169. /**
  11170. * Prepares the uniforms and samplers list to be used in the effect
  11171. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11172. * @param samplersList The sampler list
  11173. * @param defines The defines helping in the list generation
  11174. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11175. */
  11176. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11177. /**
  11178. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11179. * @param defines The defines to update while falling back
  11180. * @param fallbacks The authorized effect fallbacks
  11181. * @param maxSimultaneousLights The maximum number of lights allowed
  11182. * @param rank the current rank of the Effect
  11183. * @returns The newly affected rank
  11184. */
  11185. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11186. private static _TmpMorphInfluencers;
  11187. /**
  11188. * Prepares the list of attributes required for morph targets according to the effect defines.
  11189. * @param attribs The current list of supported attribs
  11190. * @param mesh The mesh to prepare the morph targets attributes for
  11191. * @param influencers The number of influencers
  11192. */
  11193. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  11194. /**
  11195. * Prepares the list of attributes required for morph targets according to the effect defines.
  11196. * @param attribs The current list of supported attribs
  11197. * @param mesh The mesh to prepare the morph targets attributes for
  11198. * @param defines The current Defines of the effect
  11199. */
  11200. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11201. /**
  11202. * Prepares the list of attributes required for bones according to the effect defines.
  11203. * @param attribs The current list of supported attribs
  11204. * @param mesh The mesh to prepare the bones attributes for
  11205. * @param defines The current Defines of the effect
  11206. * @param fallbacks The current efffect fallback strategy
  11207. */
  11208. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11209. /**
  11210. * Check and prepare the list of attributes required for instances according to the effect defines.
  11211. * @param attribs The current list of supported attribs
  11212. * @param defines The current MaterialDefines of the effect
  11213. */
  11214. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11215. /**
  11216. * Add the list of attributes required for instances to the attribs array.
  11217. * @param attribs The current list of supported attribs
  11218. */
  11219. static PushAttributesForInstances(attribs: string[]): void;
  11220. /**
  11221. * Binds the light shadow information to the effect for the given mesh.
  11222. * @param light The light containing the generator
  11223. * @param scene The scene the lights belongs to
  11224. * @param mesh The mesh we are binding the information to render
  11225. * @param lightIndex The light index in the effect used to render the mesh
  11226. * @param effect The effect we are binding the data to
  11227. */
  11228. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11229. /**
  11230. * Binds the light information to the effect.
  11231. * @param light The light containing the generator
  11232. * @param effect The effect we are binding the data to
  11233. * @param lightIndex The light index in the effect used to render
  11234. */
  11235. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11236. /**
  11237. * Binds the lights information from the scene to the effect for the given mesh.
  11238. * @param light Light to bind
  11239. * @param lightIndex Light index
  11240. * @param scene The scene where the light belongs to
  11241. * @param mesh The mesh we are binding the information to render
  11242. * @param effect The effect we are binding the data to
  11243. * @param useSpecular Defines if specular is supported
  11244. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11245. */
  11246. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  11247. /**
  11248. * Binds the lights information from the scene to the effect for the given mesh.
  11249. * @param scene The scene the lights belongs to
  11250. * @param mesh The mesh we are binding the information to render
  11251. * @param effect The effect we are binding the data to
  11252. * @param defines The generated defines for the effect
  11253. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11254. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11255. */
  11256. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11257. private static _tempFogColor;
  11258. /**
  11259. * Binds the fog information from the scene to the effect for the given mesh.
  11260. * @param scene The scene the lights belongs to
  11261. * @param mesh The mesh we are binding the information to render
  11262. * @param effect The effect we are binding the data to
  11263. * @param linearSpace Defines if the fog effect is applied in linear space
  11264. */
  11265. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11266. /**
  11267. * Binds the bones information from the mesh to the effect.
  11268. * @param mesh The mesh we are binding the information to render
  11269. * @param effect The effect we are binding the data to
  11270. */
  11271. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11272. /**
  11273. * Binds the morph targets information from the mesh to the effect.
  11274. * @param abstractMesh The mesh we are binding the information to render
  11275. * @param effect The effect we are binding the data to
  11276. */
  11277. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11278. /**
  11279. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11280. * @param defines The generated defines used in the effect
  11281. * @param effect The effect we are binding the data to
  11282. * @param scene The scene we are willing to render with logarithmic scale for
  11283. */
  11284. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11285. /**
  11286. * Binds the clip plane information from the scene to the effect.
  11287. * @param scene The scene the clip plane information are extracted from
  11288. * @param effect The effect we are binding the data to
  11289. */
  11290. static BindClipPlane(effect: Effect, scene: Scene): void;
  11291. }
  11292. }
  11293. declare module "babylonjs/Shaders/shadowMap.fragment" {
  11294. /** @hidden */
  11295. export var shadowMapPixelShader: {
  11296. name: string;
  11297. shader: string;
  11298. };
  11299. }
  11300. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  11301. /** @hidden */
  11302. export var bonesDeclaration: {
  11303. name: string;
  11304. shader: string;
  11305. };
  11306. }
  11307. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  11308. /** @hidden */
  11309. export var morphTargetsVertexGlobalDeclaration: {
  11310. name: string;
  11311. shader: string;
  11312. };
  11313. }
  11314. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  11315. /** @hidden */
  11316. export var morphTargetsVertexDeclaration: {
  11317. name: string;
  11318. shader: string;
  11319. };
  11320. }
  11321. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  11322. /** @hidden */
  11323. export var instancesDeclaration: {
  11324. name: string;
  11325. shader: string;
  11326. };
  11327. }
  11328. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  11329. /** @hidden */
  11330. export var helperFunctions: {
  11331. name: string;
  11332. shader: string;
  11333. };
  11334. }
  11335. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  11336. /** @hidden */
  11337. export var morphTargetsVertex: {
  11338. name: string;
  11339. shader: string;
  11340. };
  11341. }
  11342. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  11343. /** @hidden */
  11344. export var instancesVertex: {
  11345. name: string;
  11346. shader: string;
  11347. };
  11348. }
  11349. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  11350. /** @hidden */
  11351. export var bonesVertex: {
  11352. name: string;
  11353. shader: string;
  11354. };
  11355. }
  11356. declare module "babylonjs/Shaders/shadowMap.vertex" {
  11357. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  11358. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  11359. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  11360. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  11361. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11362. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  11363. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  11364. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  11365. /** @hidden */
  11366. export var shadowMapVertexShader: {
  11367. name: string;
  11368. shader: string;
  11369. };
  11370. }
  11371. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  11372. /** @hidden */
  11373. export var depthBoxBlurPixelShader: {
  11374. name: string;
  11375. shader: string;
  11376. };
  11377. }
  11378. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  11379. import { Nullable } from "babylonjs/types";
  11380. import { Scene } from "babylonjs/scene";
  11381. import { Matrix } from "babylonjs/Maths/math";
  11382. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11384. import { Mesh } from "babylonjs/Meshes/mesh";
  11385. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  11386. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11387. import { Effect } from "babylonjs/Materials/effect";
  11388. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11389. import "babylonjs/Shaders/shadowMap.fragment";
  11390. import "babylonjs/Shaders/shadowMap.vertex";
  11391. import "babylonjs/Shaders/depthBoxBlur.fragment";
  11392. import { Observable } from "babylonjs/Misc/observable";
  11393. /**
  11394. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11395. */
  11396. export interface ICustomShaderOptions {
  11397. /**
  11398. * Gets or sets the custom shader name to use
  11399. */
  11400. shaderName: string;
  11401. /**
  11402. * The list of attribute names used in the shader
  11403. */
  11404. attributes?: string[];
  11405. /**
  11406. * The list of unifrom names used in the shader
  11407. */
  11408. uniforms?: string[];
  11409. /**
  11410. * The list of sampler names used in the shader
  11411. */
  11412. samplers?: string[];
  11413. /**
  11414. * The list of defines used in the shader
  11415. */
  11416. defines?: string[];
  11417. }
  11418. /**
  11419. * Interface to implement to create a shadow generator compatible with BJS.
  11420. */
  11421. export interface IShadowGenerator {
  11422. /**
  11423. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11424. * @returns The render target texture if present otherwise, null
  11425. */
  11426. getShadowMap(): Nullable<RenderTargetTexture>;
  11427. /**
  11428. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11429. * @returns The render target texture if the shadow map is present otherwise, null
  11430. */
  11431. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11432. /**
  11433. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11434. * @param subMesh The submesh we want to render in the shadow map
  11435. * @param useInstances Defines wether will draw in the map using instances
  11436. * @returns true if ready otherwise, false
  11437. */
  11438. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11439. /**
  11440. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11441. * @param defines Defines of the material we want to update
  11442. * @param lightIndex Index of the light in the enabled light list of the material
  11443. */
  11444. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11445. /**
  11446. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11447. * defined in the generator but impacting the effect).
  11448. * It implies the unifroms available on the materials are the standard BJS ones.
  11449. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11450. * @param effect The effect we are binfing the information for
  11451. */
  11452. bindShadowLight(lightIndex: string, effect: Effect): void;
  11453. /**
  11454. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11455. * (eq to shadow prjection matrix * light transform matrix)
  11456. * @returns The transform matrix used to create the shadow map
  11457. */
  11458. getTransformMatrix(): Matrix;
  11459. /**
  11460. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11461. * Cube and 2D textures for instance.
  11462. */
  11463. recreateShadowMap(): void;
  11464. /**
  11465. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11466. * @param onCompiled Callback triggered at the and of the effects compilation
  11467. * @param options Sets of optional options forcing the compilation with different modes
  11468. */
  11469. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11470. useInstances: boolean;
  11471. }>): void;
  11472. /**
  11473. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11474. * @param options Sets of optional options forcing the compilation with different modes
  11475. * @returns A promise that resolves when the compilation completes
  11476. */
  11477. forceCompilationAsync(options?: Partial<{
  11478. useInstances: boolean;
  11479. }>): Promise<void>;
  11480. /**
  11481. * Serializes the shadow generator setup to a json object.
  11482. * @returns The serialized JSON object
  11483. */
  11484. serialize(): any;
  11485. /**
  11486. * Disposes the Shadow map and related Textures and effects.
  11487. */
  11488. dispose(): void;
  11489. }
  11490. /**
  11491. * Default implementation IShadowGenerator.
  11492. * This is the main object responsible of generating shadows in the framework.
  11493. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11494. */
  11495. export class ShadowGenerator implements IShadowGenerator {
  11496. /**
  11497. * Shadow generator mode None: no filtering applied.
  11498. */
  11499. static readonly FILTER_NONE: number;
  11500. /**
  11501. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11502. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11503. */
  11504. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11505. /**
  11506. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11507. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11508. */
  11509. static readonly FILTER_POISSONSAMPLING: number;
  11510. /**
  11511. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11512. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11513. */
  11514. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11515. /**
  11516. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11517. * edge artifacts on steep falloff.
  11518. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11519. */
  11520. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11521. /**
  11522. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11523. * edge artifacts on steep falloff.
  11524. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11525. */
  11526. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11527. /**
  11528. * Shadow generator mode PCF: Percentage Closer Filtering
  11529. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11530. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11531. */
  11532. static readonly FILTER_PCF: number;
  11533. /**
  11534. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11535. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11536. * Contact Hardening
  11537. */
  11538. static readonly FILTER_PCSS: number;
  11539. /**
  11540. * Reserved for PCF and PCSS
  11541. * Highest Quality.
  11542. *
  11543. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11544. *
  11545. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11546. */
  11547. static readonly QUALITY_HIGH: number;
  11548. /**
  11549. * Reserved for PCF and PCSS
  11550. * Good tradeoff for quality/perf cross devices
  11551. *
  11552. * Execute PCF on a 3*3 kernel.
  11553. *
  11554. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11555. */
  11556. static readonly QUALITY_MEDIUM: number;
  11557. /**
  11558. * Reserved for PCF and PCSS
  11559. * The lowest quality but the fastest.
  11560. *
  11561. * Execute PCF on a 1*1 kernel.
  11562. *
  11563. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11564. */
  11565. static readonly QUALITY_LOW: number;
  11566. /** Gets or sets the custom shader name to use */
  11567. customShaderOptions: ICustomShaderOptions;
  11568. /**
  11569. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11570. */
  11571. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11572. /**
  11573. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11574. */
  11575. onAfterShadowMapRenderObservable: Observable<Effect>;
  11576. /**
  11577. * Observable triggered before a mesh is rendered in the shadow map.
  11578. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11579. */
  11580. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11581. /**
  11582. * Observable triggered after a mesh is rendered in the shadow map.
  11583. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11584. */
  11585. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11586. private _bias;
  11587. /**
  11588. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11589. */
  11590. /**
  11591. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11592. */
  11593. bias: number;
  11594. private _normalBias;
  11595. /**
  11596. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11597. */
  11598. /**
  11599. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11600. */
  11601. normalBias: number;
  11602. private _blurBoxOffset;
  11603. /**
  11604. * Gets the blur box offset: offset applied during the blur pass.
  11605. * Only useful if useKernelBlur = false
  11606. */
  11607. /**
  11608. * Sets the blur box offset: offset applied during the blur pass.
  11609. * Only useful if useKernelBlur = false
  11610. */
  11611. blurBoxOffset: number;
  11612. private _blurScale;
  11613. /**
  11614. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11615. * 2 means half of the size.
  11616. */
  11617. /**
  11618. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11619. * 2 means half of the size.
  11620. */
  11621. blurScale: number;
  11622. private _blurKernel;
  11623. /**
  11624. * Gets the blur kernel: kernel size of the blur pass.
  11625. * Only useful if useKernelBlur = true
  11626. */
  11627. /**
  11628. * Sets the blur kernel: kernel size of the blur pass.
  11629. * Only useful if useKernelBlur = true
  11630. */
  11631. blurKernel: number;
  11632. private _useKernelBlur;
  11633. /**
  11634. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11635. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11636. */
  11637. /**
  11638. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11639. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11640. */
  11641. useKernelBlur: boolean;
  11642. private _depthScale;
  11643. /**
  11644. * Gets the depth scale used in ESM mode.
  11645. */
  11646. /**
  11647. * Sets the depth scale used in ESM mode.
  11648. * This can override the scale stored on the light.
  11649. */
  11650. depthScale: number;
  11651. private _filter;
  11652. /**
  11653. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11654. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11655. */
  11656. /**
  11657. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11658. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11659. */
  11660. filter: number;
  11661. /**
  11662. * Gets if the current filter is set to Poisson Sampling.
  11663. */
  11664. /**
  11665. * Sets the current filter to Poisson Sampling.
  11666. */
  11667. usePoissonSampling: boolean;
  11668. /**
  11669. * Gets if the current filter is set to ESM.
  11670. */
  11671. /**
  11672. * Sets the current filter is to ESM.
  11673. */
  11674. useExponentialShadowMap: boolean;
  11675. /**
  11676. * Gets if the current filter is set to filtered ESM.
  11677. */
  11678. /**
  11679. * Gets if the current filter is set to filtered ESM.
  11680. */
  11681. useBlurExponentialShadowMap: boolean;
  11682. /**
  11683. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11684. * exponential to prevent steep falloff artifacts).
  11685. */
  11686. /**
  11687. * Sets the current filter to "close ESM" (using the inverse of the
  11688. * exponential to prevent steep falloff artifacts).
  11689. */
  11690. useCloseExponentialShadowMap: boolean;
  11691. /**
  11692. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11693. * exponential to prevent steep falloff artifacts).
  11694. */
  11695. /**
  11696. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11697. * exponential to prevent steep falloff artifacts).
  11698. */
  11699. useBlurCloseExponentialShadowMap: boolean;
  11700. /**
  11701. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11702. */
  11703. /**
  11704. * Sets the current filter to "PCF" (percentage closer filtering).
  11705. */
  11706. usePercentageCloserFiltering: boolean;
  11707. private _filteringQuality;
  11708. /**
  11709. * Gets the PCF or PCSS Quality.
  11710. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11711. */
  11712. /**
  11713. * Sets the PCF or PCSS Quality.
  11714. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11715. */
  11716. filteringQuality: number;
  11717. /**
  11718. * Gets if the current filter is set to "PCSS" (contact hardening).
  11719. */
  11720. /**
  11721. * Sets the current filter to "PCSS" (contact hardening).
  11722. */
  11723. useContactHardeningShadow: boolean;
  11724. private _contactHardeningLightSizeUVRatio;
  11725. /**
  11726. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11727. * Using a ratio helps keeping shape stability independently of the map size.
  11728. *
  11729. * It does not account for the light projection as it was having too much
  11730. * instability during the light setup or during light position changes.
  11731. *
  11732. * Only valid if useContactHardeningShadow is true.
  11733. */
  11734. /**
  11735. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11736. * Using a ratio helps keeping shape stability independently of the map size.
  11737. *
  11738. * It does not account for the light projection as it was having too much
  11739. * instability during the light setup or during light position changes.
  11740. *
  11741. * Only valid if useContactHardeningShadow is true.
  11742. */
  11743. contactHardeningLightSizeUVRatio: number;
  11744. private _darkness;
  11745. /** Gets or sets the actual darkness of a shadow */
  11746. darkness: number;
  11747. /**
  11748. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11749. * 0 means strongest and 1 would means no shadow.
  11750. * @returns the darkness.
  11751. */
  11752. getDarkness(): number;
  11753. /**
  11754. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11755. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11756. * @returns the shadow generator allowing fluent coding.
  11757. */
  11758. setDarkness(darkness: number): ShadowGenerator;
  11759. private _transparencyShadow;
  11760. /** Gets or sets the ability to have transparent shadow */
  11761. transparencyShadow: boolean;
  11762. /**
  11763. * Sets the ability to have transparent shadow (boolean).
  11764. * @param transparent True if transparent else False
  11765. * @returns the shadow generator allowing fluent coding
  11766. */
  11767. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11768. private _shadowMap;
  11769. private _shadowMap2;
  11770. /**
  11771. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11772. * @returns The render target texture if present otherwise, null
  11773. */
  11774. getShadowMap(): Nullable<RenderTargetTexture>;
  11775. /**
  11776. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11777. * @returns The render target texture if the shadow map is present otherwise, null
  11778. */
  11779. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11780. /**
  11781. * Gets the class name of that object
  11782. * @returns "ShadowGenerator"
  11783. */
  11784. getClassName(): string;
  11785. /**
  11786. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11787. * @param mesh Mesh to add
  11788. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11789. * @returns the Shadow Generator itself
  11790. */
  11791. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11792. /**
  11793. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11794. * @param mesh Mesh to remove
  11795. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11796. * @returns the Shadow Generator itself
  11797. */
  11798. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11799. /**
  11800. * Controls the extent to which the shadows fade out at the edge of the frustum
  11801. * Used only by directionals and spots
  11802. */
  11803. frustumEdgeFalloff: number;
  11804. private _light;
  11805. /**
  11806. * Returns the associated light object.
  11807. * @returns the light generating the shadow
  11808. */
  11809. getLight(): IShadowLight;
  11810. /**
  11811. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11812. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11813. * It might on the other hand introduce peter panning.
  11814. */
  11815. forceBackFacesOnly: boolean;
  11816. private _scene;
  11817. private _lightDirection;
  11818. private _effect;
  11819. private _viewMatrix;
  11820. private _projectionMatrix;
  11821. private _transformMatrix;
  11822. private _cachedPosition;
  11823. private _cachedDirection;
  11824. private _cachedDefines;
  11825. private _currentRenderID;
  11826. private _boxBlurPostprocess;
  11827. private _kernelBlurXPostprocess;
  11828. private _kernelBlurYPostprocess;
  11829. private _blurPostProcesses;
  11830. private _mapSize;
  11831. private _currentFaceIndex;
  11832. private _currentFaceIndexCache;
  11833. private _textureType;
  11834. private _defaultTextureMatrix;
  11835. /** @hidden */
  11836. static _SceneComponentInitialization: (scene: Scene) => void;
  11837. /**
  11838. * Creates a ShadowGenerator object.
  11839. * A ShadowGenerator is the required tool to use the shadows.
  11840. * Each light casting shadows needs to use its own ShadowGenerator.
  11841. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11842. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11843. * @param light The light object generating the shadows.
  11844. * @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.
  11845. */
  11846. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11847. private _initializeGenerator;
  11848. private _initializeShadowMap;
  11849. private _initializeBlurRTTAndPostProcesses;
  11850. private _renderForShadowMap;
  11851. private _renderSubMeshForShadowMap;
  11852. private _applyFilterValues;
  11853. /**
  11854. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11855. * @param onCompiled Callback triggered at the and of the effects compilation
  11856. * @param options Sets of optional options forcing the compilation with different modes
  11857. */
  11858. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11859. useInstances: boolean;
  11860. }>): void;
  11861. /**
  11862. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11863. * @param options Sets of optional options forcing the compilation with different modes
  11864. * @returns A promise that resolves when the compilation completes
  11865. */
  11866. forceCompilationAsync(options?: Partial<{
  11867. useInstances: boolean;
  11868. }>): Promise<void>;
  11869. /**
  11870. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11871. * @param subMesh The submesh we want to render in the shadow map
  11872. * @param useInstances Defines wether will draw in the map using instances
  11873. * @returns true if ready otherwise, false
  11874. */
  11875. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11876. /**
  11877. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11878. * @param defines Defines of the material we want to update
  11879. * @param lightIndex Index of the light in the enabled light list of the material
  11880. */
  11881. prepareDefines(defines: any, lightIndex: number): void;
  11882. /**
  11883. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11884. * defined in the generator but impacting the effect).
  11885. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11886. * @param effect The effect we are binfing the information for
  11887. */
  11888. bindShadowLight(lightIndex: string, effect: Effect): void;
  11889. /**
  11890. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11891. * (eq to shadow prjection matrix * light transform matrix)
  11892. * @returns The transform matrix used to create the shadow map
  11893. */
  11894. getTransformMatrix(): Matrix;
  11895. /**
  11896. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11897. * Cube and 2D textures for instance.
  11898. */
  11899. recreateShadowMap(): void;
  11900. private _disposeBlurPostProcesses;
  11901. private _disposeRTTandPostProcesses;
  11902. /**
  11903. * Disposes the ShadowGenerator.
  11904. * Returns nothing.
  11905. */
  11906. dispose(): void;
  11907. /**
  11908. * Serializes the shadow generator setup to a json object.
  11909. * @returns The serialized JSON object
  11910. */
  11911. serialize(): any;
  11912. /**
  11913. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11914. * @param parsedShadowGenerator The JSON object to parse
  11915. * @param scene The scene to create the shadow map for
  11916. * @returns The parsed shadow generator
  11917. */
  11918. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11919. }
  11920. }
  11921. declare module "babylonjs/Lights/light" {
  11922. import { Nullable } from "babylonjs/types";
  11923. import { Scene } from "babylonjs/scene";
  11924. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11925. import { Node } from "babylonjs/node";
  11926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11927. import { Effect } from "babylonjs/Materials/effect";
  11928. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11929. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11930. /**
  11931. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11932. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11933. * 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.
  11934. */
  11935. export abstract class Light extends Node {
  11936. /**
  11937. * Falloff Default: light is falling off following the material specification:
  11938. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11939. */
  11940. static readonly FALLOFF_DEFAULT: number;
  11941. /**
  11942. * Falloff Physical: light is falling off following the inverse squared distance law.
  11943. */
  11944. static readonly FALLOFF_PHYSICAL: number;
  11945. /**
  11946. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11947. * to enhance interoperability with other engines.
  11948. */
  11949. static readonly FALLOFF_GLTF: number;
  11950. /**
  11951. * Falloff Standard: light is falling off like in the standard material
  11952. * to enhance interoperability with other materials.
  11953. */
  11954. static readonly FALLOFF_STANDARD: number;
  11955. /**
  11956. * If every light affecting the material is in this lightmapMode,
  11957. * material.lightmapTexture adds or multiplies
  11958. * (depends on material.useLightmapAsShadowmap)
  11959. * after every other light calculations.
  11960. */
  11961. static readonly LIGHTMAP_DEFAULT: number;
  11962. /**
  11963. * material.lightmapTexture as only diffuse lighting from this light
  11964. * adds only specular lighting from this light
  11965. * adds dynamic shadows
  11966. */
  11967. static readonly LIGHTMAP_SPECULAR: number;
  11968. /**
  11969. * material.lightmapTexture as only lighting
  11970. * no light calculation from this light
  11971. * only adds dynamic shadows from this light
  11972. */
  11973. static readonly LIGHTMAP_SHADOWSONLY: number;
  11974. /**
  11975. * Each light type uses the default quantity according to its type:
  11976. * point/spot lights use luminous intensity
  11977. * directional lights use illuminance
  11978. */
  11979. static readonly INTENSITYMODE_AUTOMATIC: number;
  11980. /**
  11981. * lumen (lm)
  11982. */
  11983. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11984. /**
  11985. * candela (lm/sr)
  11986. */
  11987. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11988. /**
  11989. * lux (lm/m^2)
  11990. */
  11991. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11992. /**
  11993. * nit (cd/m^2)
  11994. */
  11995. static readonly INTENSITYMODE_LUMINANCE: number;
  11996. /**
  11997. * Light type const id of the point light.
  11998. */
  11999. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12000. /**
  12001. * Light type const id of the directional light.
  12002. */
  12003. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12004. /**
  12005. * Light type const id of the spot light.
  12006. */
  12007. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12008. /**
  12009. * Light type const id of the hemispheric light.
  12010. */
  12011. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12012. /**
  12013. * Diffuse gives the basic color to an object.
  12014. */
  12015. diffuse: Color3;
  12016. /**
  12017. * Specular produces a highlight color on an object.
  12018. * Note: This is note affecting PBR materials.
  12019. */
  12020. specular: Color3;
  12021. /**
  12022. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12023. * falling off base on range or angle.
  12024. * This can be set to any values in Light.FALLOFF_x.
  12025. *
  12026. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  12027. * other types of materials.
  12028. */
  12029. falloffType: number;
  12030. /**
  12031. * Strength of the light.
  12032. * Note: By default it is define in the framework own unit.
  12033. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12034. */
  12035. intensity: number;
  12036. private _range;
  12037. protected _inverseSquaredRange: number;
  12038. /**
  12039. * Defines how far from the source the light is impacting in scene units.
  12040. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12041. */
  12042. /**
  12043. * Defines how far from the source the light is impacting in scene units.
  12044. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12045. */
  12046. range: number;
  12047. /**
  12048. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12049. * of light.
  12050. */
  12051. private _photometricScale;
  12052. private _intensityMode;
  12053. /**
  12054. * Gets the photometric scale used to interpret the intensity.
  12055. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12056. */
  12057. /**
  12058. * Sets the photometric scale used to interpret the intensity.
  12059. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12060. */
  12061. intensityMode: number;
  12062. private _radius;
  12063. /**
  12064. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12065. */
  12066. /**
  12067. * sets the light radius used by PBR Materials to simulate soft area lights.
  12068. */
  12069. radius: number;
  12070. private _renderPriority;
  12071. /**
  12072. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12073. * exceeding the number allowed of the materials.
  12074. */
  12075. renderPriority: number;
  12076. private _shadowEnabled;
  12077. /**
  12078. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12079. * the current shadow generator.
  12080. */
  12081. /**
  12082. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12083. * the current shadow generator.
  12084. */
  12085. shadowEnabled: boolean;
  12086. private _includedOnlyMeshes;
  12087. /**
  12088. * Gets the only meshes impacted by this light.
  12089. */
  12090. /**
  12091. * Sets the only meshes impacted by this light.
  12092. */
  12093. includedOnlyMeshes: AbstractMesh[];
  12094. private _excludedMeshes;
  12095. /**
  12096. * Gets the meshes not impacted by this light.
  12097. */
  12098. /**
  12099. * Sets the meshes not impacted by this light.
  12100. */
  12101. excludedMeshes: AbstractMesh[];
  12102. private _excludeWithLayerMask;
  12103. /**
  12104. * Gets the layer id use to find what meshes are not impacted by the light.
  12105. * Inactive if 0
  12106. */
  12107. /**
  12108. * Sets the layer id use to find what meshes are not impacted by the light.
  12109. * Inactive if 0
  12110. */
  12111. excludeWithLayerMask: number;
  12112. private _includeOnlyWithLayerMask;
  12113. /**
  12114. * Gets the layer id use to find what meshes are impacted by the light.
  12115. * Inactive if 0
  12116. */
  12117. /**
  12118. * Sets the layer id use to find what meshes are impacted by the light.
  12119. * Inactive if 0
  12120. */
  12121. includeOnlyWithLayerMask: number;
  12122. private _lightmapMode;
  12123. /**
  12124. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12125. */
  12126. /**
  12127. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12128. */
  12129. lightmapMode: number;
  12130. /**
  12131. * Shadow generator associted to the light.
  12132. * @hidden Internal use only.
  12133. */
  12134. _shadowGenerator: Nullable<IShadowGenerator>;
  12135. /**
  12136. * @hidden Internal use only.
  12137. */
  12138. _excludedMeshesIds: string[];
  12139. /**
  12140. * @hidden Internal use only.
  12141. */
  12142. _includedOnlyMeshesIds: string[];
  12143. /**
  12144. * The current light unifom buffer.
  12145. * @hidden Internal use only.
  12146. */
  12147. _uniformBuffer: UniformBuffer;
  12148. /**
  12149. * Creates a Light object in the scene.
  12150. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12151. * @param name The firendly name of the light
  12152. * @param scene The scene the light belongs too
  12153. */
  12154. constructor(name: string, scene: Scene);
  12155. protected abstract _buildUniformLayout(): void;
  12156. /**
  12157. * Sets the passed Effect "effect" with the Light information.
  12158. * @param effect The effect to update
  12159. * @param lightIndex The index of the light in the effect to update
  12160. * @returns The light
  12161. */
  12162. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12163. /**
  12164. * Returns the string "Light".
  12165. * @returns the class name
  12166. */
  12167. getClassName(): string;
  12168. /** @hidden */
  12169. readonly _isLight: boolean;
  12170. /**
  12171. * Converts the light information to a readable string for debug purpose.
  12172. * @param fullDetails Supports for multiple levels of logging within scene loading
  12173. * @returns the human readable light info
  12174. */
  12175. toString(fullDetails?: boolean): string;
  12176. /** @hidden */
  12177. protected _syncParentEnabledState(): void;
  12178. /**
  12179. * Set the enabled state of this node.
  12180. * @param value - the new enabled state
  12181. */
  12182. setEnabled(value: boolean): void;
  12183. /**
  12184. * Returns the Light associated shadow generator if any.
  12185. * @return the associated shadow generator.
  12186. */
  12187. getShadowGenerator(): Nullable<IShadowGenerator>;
  12188. /**
  12189. * Returns a Vector3, the absolute light position in the World.
  12190. * @returns the world space position of the light
  12191. */
  12192. getAbsolutePosition(): Vector3;
  12193. /**
  12194. * Specifies if the light will affect the passed mesh.
  12195. * @param mesh The mesh to test against the light
  12196. * @return true the mesh is affected otherwise, false.
  12197. */
  12198. canAffectMesh(mesh: AbstractMesh): boolean;
  12199. /**
  12200. * Sort function to order lights for rendering.
  12201. * @param a First Light object to compare to second.
  12202. * @param b Second Light object to compare first.
  12203. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12204. */
  12205. static CompareLightsPriority(a: Light, b: Light): number;
  12206. /**
  12207. * Releases resources associated with this node.
  12208. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12209. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12210. */
  12211. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12212. /**
  12213. * Returns the light type ID (integer).
  12214. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12215. */
  12216. getTypeID(): number;
  12217. /**
  12218. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12219. * @returns the scaled intensity in intensity mode unit
  12220. */
  12221. getScaledIntensity(): number;
  12222. /**
  12223. * Returns a new Light object, named "name", from the current one.
  12224. * @param name The name of the cloned light
  12225. * @returns the new created light
  12226. */
  12227. clone(name: string): Nullable<Light>;
  12228. /**
  12229. * Serializes the current light into a Serialization object.
  12230. * @returns the serialized object.
  12231. */
  12232. serialize(): any;
  12233. /**
  12234. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12235. * This new light is named "name" and added to the passed scene.
  12236. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12237. * @param name The friendly name of the light
  12238. * @param scene The scene the new light will belong to
  12239. * @returns the constructor function
  12240. */
  12241. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12242. /**
  12243. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12244. * @param parsedLight The JSON representation of the light
  12245. * @param scene The scene to create the parsed light in
  12246. * @returns the created light after parsing
  12247. */
  12248. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12249. private _hookArrayForExcluded;
  12250. private _hookArrayForIncludedOnly;
  12251. private _resyncMeshes;
  12252. /**
  12253. * Forces the meshes to update their light related information in their rendering used effects
  12254. * @hidden Internal Use Only
  12255. */
  12256. _markMeshesAsLightDirty(): void;
  12257. /**
  12258. * Recomputes the cached photometric scale if needed.
  12259. */
  12260. private _computePhotometricScale;
  12261. /**
  12262. * Returns the Photometric Scale according to the light type and intensity mode.
  12263. */
  12264. private _getPhotometricScale;
  12265. /**
  12266. * Reorder the light in the scene according to their defined priority.
  12267. * @hidden Internal Use Only
  12268. */
  12269. _reorderLightsInScene(): void;
  12270. /**
  12271. * Prepares the list of defines specific to the light type.
  12272. * @param defines the list of defines
  12273. * @param lightIndex defines the index of the light for the effect
  12274. */
  12275. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12276. }
  12277. }
  12278. declare module "babylonjs/Meshes/instancedMesh" {
  12279. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  12280. import { Vector3, Matrix } from "babylonjs/Maths/math";
  12281. import { Camera } from "babylonjs/Cameras/camera";
  12282. import { Node } from "babylonjs/node";
  12283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12284. import { Mesh } from "babylonjs/Meshes/mesh";
  12285. import { Material } from "babylonjs/Materials/material";
  12286. import { Skeleton } from "babylonjs/Bones/skeleton";
  12287. import { Light } from "babylonjs/Lights/light";
  12288. /**
  12289. * Creates an instance based on a source mesh.
  12290. */
  12291. export class InstancedMesh extends AbstractMesh {
  12292. private _sourceMesh;
  12293. private _currentLOD;
  12294. /** @hidden */
  12295. _indexInSourceMeshInstanceArray: number;
  12296. constructor(name: string, source: Mesh);
  12297. /**
  12298. * Returns the string "InstancedMesh".
  12299. */
  12300. getClassName(): string;
  12301. /** Gets the list of lights affecting that mesh */
  12302. readonly lightSources: Light[];
  12303. _resyncLightSources(): void;
  12304. _resyncLighSource(light: Light): void;
  12305. _removeLightSource(light: Light): void;
  12306. /**
  12307. * If the source mesh receives shadows
  12308. */
  12309. readonly receiveShadows: boolean;
  12310. /**
  12311. * The material of the source mesh
  12312. */
  12313. readonly material: Nullable<Material>;
  12314. /**
  12315. * Visibility of the source mesh
  12316. */
  12317. readonly visibility: number;
  12318. /**
  12319. * Skeleton of the source mesh
  12320. */
  12321. readonly skeleton: Nullable<Skeleton>;
  12322. /**
  12323. * Rendering ground id of the source mesh
  12324. */
  12325. renderingGroupId: number;
  12326. /**
  12327. * Returns the total number of vertices (integer).
  12328. */
  12329. getTotalVertices(): number;
  12330. /**
  12331. * Returns a positive integer : the total number of indices in this mesh geometry.
  12332. * @returns the numner of indices or zero if the mesh has no geometry.
  12333. */
  12334. getTotalIndices(): number;
  12335. /**
  12336. * The source mesh of the instance
  12337. */
  12338. readonly sourceMesh: Mesh;
  12339. /**
  12340. * Is this node ready to be used/rendered
  12341. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12342. * @return {boolean} is it ready
  12343. */
  12344. isReady(completeCheck?: boolean): boolean;
  12345. /**
  12346. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12347. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12348. * @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.
  12349. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12350. */
  12351. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12352. /**
  12353. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12354. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12355. * The `data` are either a numeric array either a Float32Array.
  12356. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12357. * 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).
  12358. * Note that a new underlying VertexBuffer object is created each call.
  12359. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12360. *
  12361. * Possible `kind` values :
  12362. * - VertexBuffer.PositionKind
  12363. * - VertexBuffer.UVKind
  12364. * - VertexBuffer.UV2Kind
  12365. * - VertexBuffer.UV3Kind
  12366. * - VertexBuffer.UV4Kind
  12367. * - VertexBuffer.UV5Kind
  12368. * - VertexBuffer.UV6Kind
  12369. * - VertexBuffer.ColorKind
  12370. * - VertexBuffer.MatricesIndicesKind
  12371. * - VertexBuffer.MatricesIndicesExtraKind
  12372. * - VertexBuffer.MatricesWeightsKind
  12373. * - VertexBuffer.MatricesWeightsExtraKind
  12374. *
  12375. * Returns the Mesh.
  12376. */
  12377. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12378. /**
  12379. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12380. * If the mesh has no geometry, it is simply returned as it is.
  12381. * The `data` are either a numeric array either a Float32Array.
  12382. * No new underlying VertexBuffer object is created.
  12383. * 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.
  12384. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12385. *
  12386. * Possible `kind` values :
  12387. * - VertexBuffer.PositionKind
  12388. * - VertexBuffer.UVKind
  12389. * - VertexBuffer.UV2Kind
  12390. * - VertexBuffer.UV3Kind
  12391. * - VertexBuffer.UV4Kind
  12392. * - VertexBuffer.UV5Kind
  12393. * - VertexBuffer.UV6Kind
  12394. * - VertexBuffer.ColorKind
  12395. * - VertexBuffer.MatricesIndicesKind
  12396. * - VertexBuffer.MatricesIndicesExtraKind
  12397. * - VertexBuffer.MatricesWeightsKind
  12398. * - VertexBuffer.MatricesWeightsExtraKind
  12399. *
  12400. * Returns the Mesh.
  12401. */
  12402. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12403. /**
  12404. * Sets the mesh indices.
  12405. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12406. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12407. * This method creates a new index buffer each call.
  12408. * Returns the Mesh.
  12409. */
  12410. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12411. /**
  12412. * Boolean : True if the mesh owns the requested kind of data.
  12413. */
  12414. isVerticesDataPresent(kind: string): boolean;
  12415. /**
  12416. * Returns an array of indices (IndicesArray).
  12417. */
  12418. getIndices(): Nullable<IndicesArray>;
  12419. readonly _positions: Nullable<Vector3[]>;
  12420. /**
  12421. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12422. * This means the mesh underlying bounding box and sphere are recomputed.
  12423. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12424. * @returns the current mesh
  12425. */
  12426. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12427. /** @hidden */
  12428. _preActivate(): InstancedMesh;
  12429. /** @hidden */
  12430. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12431. /** @hidden */
  12432. _postActivate(): void;
  12433. getWorldMatrix(): Matrix;
  12434. readonly isAnInstance: boolean;
  12435. /**
  12436. * Returns the current associated LOD AbstractMesh.
  12437. */
  12438. getLOD(camera: Camera): AbstractMesh;
  12439. /** @hidden */
  12440. _syncSubMeshes(): InstancedMesh;
  12441. /** @hidden */
  12442. _generatePointsArray(): boolean;
  12443. /**
  12444. * Creates a new InstancedMesh from the current mesh.
  12445. * - name (string) : the cloned mesh name
  12446. * - newParent (optional Node) : the optional Node to parent the clone to.
  12447. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12448. *
  12449. * Returns the clone.
  12450. */
  12451. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12452. /**
  12453. * Disposes the InstancedMesh.
  12454. * Returns nothing.
  12455. */
  12456. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12457. }
  12458. }
  12459. declare module "babylonjs/Materials/shaderMaterial" {
  12460. import { Scene } from "babylonjs/scene";
  12461. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  12462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12463. import { Mesh } from "babylonjs/Meshes/mesh";
  12464. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  12465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12466. import { Texture } from "babylonjs/Materials/Textures/texture";
  12467. import { Material } from "babylonjs/Materials/material";
  12468. /**
  12469. * Defines the options associated with the creation of a shader material.
  12470. */
  12471. export interface IShaderMaterialOptions {
  12472. /**
  12473. * Does the material work in alpha blend mode
  12474. */
  12475. needAlphaBlending: boolean;
  12476. /**
  12477. * Does the material work in alpha test mode
  12478. */
  12479. needAlphaTesting: boolean;
  12480. /**
  12481. * The list of attribute names used in the shader
  12482. */
  12483. attributes: string[];
  12484. /**
  12485. * The list of unifrom names used in the shader
  12486. */
  12487. uniforms: string[];
  12488. /**
  12489. * The list of UBO names used in the shader
  12490. */
  12491. uniformBuffers: string[];
  12492. /**
  12493. * The list of sampler names used in the shader
  12494. */
  12495. samplers: string[];
  12496. /**
  12497. * The list of defines used in the shader
  12498. */
  12499. defines: string[];
  12500. }
  12501. /**
  12502. * 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.
  12503. *
  12504. * This returned material effects how the mesh will look based on the code in the shaders.
  12505. *
  12506. * @see http://doc.babylonjs.com/how_to/shader_material
  12507. */
  12508. export class ShaderMaterial extends Material {
  12509. private _shaderPath;
  12510. private _options;
  12511. private _textures;
  12512. private _textureArrays;
  12513. private _floats;
  12514. private _ints;
  12515. private _floatsArrays;
  12516. private _colors3;
  12517. private _colors3Arrays;
  12518. private _colors4;
  12519. private _colors4Arrays;
  12520. private _vectors2;
  12521. private _vectors3;
  12522. private _vectors4;
  12523. private _matrices;
  12524. private _matrices3x3;
  12525. private _matrices2x2;
  12526. private _vectors2Arrays;
  12527. private _vectors3Arrays;
  12528. private _vectors4Arrays;
  12529. private _cachedWorldViewMatrix;
  12530. private _cachedWorldViewProjectionMatrix;
  12531. private _renderId;
  12532. /**
  12533. * Instantiate a new shader material.
  12534. * 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.
  12535. * This returned material effects how the mesh will look based on the code in the shaders.
  12536. * @see http://doc.babylonjs.com/how_to/shader_material
  12537. * @param name Define the name of the material in the scene
  12538. * @param scene Define the scene the material belongs to
  12539. * @param shaderPath Defines the route to the shader code in one of three ways:
  12540. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12541. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12542. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12543. * @param options Define the options used to create the shader
  12544. */
  12545. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12546. /**
  12547. * Gets the options used to compile the shader.
  12548. * They can be modified to trigger a new compilation
  12549. */
  12550. readonly options: IShaderMaterialOptions;
  12551. /**
  12552. * Gets the current class name of the material e.g. "ShaderMaterial"
  12553. * Mainly use in serialization.
  12554. * @returns the class name
  12555. */
  12556. getClassName(): string;
  12557. /**
  12558. * Specifies if the material will require alpha blending
  12559. * @returns a boolean specifying if alpha blending is needed
  12560. */
  12561. needAlphaBlending(): boolean;
  12562. /**
  12563. * Specifies if this material should be rendered in alpha test mode
  12564. * @returns a boolean specifying if an alpha test is needed.
  12565. */
  12566. needAlphaTesting(): boolean;
  12567. private _checkUniform;
  12568. /**
  12569. * Set a texture in the shader.
  12570. * @param name Define the name of the uniform samplers as defined in the shader
  12571. * @param texture Define the texture to bind to this sampler
  12572. * @return the material itself allowing "fluent" like uniform updates
  12573. */
  12574. setTexture(name: string, texture: Texture): ShaderMaterial;
  12575. /**
  12576. * Set a texture array in the shader.
  12577. * @param name Define the name of the uniform sampler array as defined in the shader
  12578. * @param textures Define the list of textures to bind to this sampler
  12579. * @return the material itself allowing "fluent" like uniform updates
  12580. */
  12581. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12582. /**
  12583. * Set a float in the shader.
  12584. * @param name Define the name of the uniform as defined in the shader
  12585. * @param value Define the value to give to the uniform
  12586. * @return the material itself allowing "fluent" like uniform updates
  12587. */
  12588. setFloat(name: string, value: number): ShaderMaterial;
  12589. /**
  12590. * Set a int in the shader.
  12591. * @param name Define the name of the uniform as defined in the shader
  12592. * @param value Define the value to give to the uniform
  12593. * @return the material itself allowing "fluent" like uniform updates
  12594. */
  12595. setInt(name: string, value: number): ShaderMaterial;
  12596. /**
  12597. * Set an array of floats in the shader.
  12598. * @param name Define the name of the uniform as defined in the shader
  12599. * @param value Define the value to give to the uniform
  12600. * @return the material itself allowing "fluent" like uniform updates
  12601. */
  12602. setFloats(name: string, value: number[]): ShaderMaterial;
  12603. /**
  12604. * Set a vec3 in the shader from a Color3.
  12605. * @param name Define the name of the uniform as defined in the shader
  12606. * @param value Define the value to give to the uniform
  12607. * @return the material itself allowing "fluent" like uniform updates
  12608. */
  12609. setColor3(name: string, value: Color3): ShaderMaterial;
  12610. /**
  12611. * Set a vec3 array in the shader from a Color3 array.
  12612. * @param name Define the name of the uniform as defined in the shader
  12613. * @param value Define the value to give to the uniform
  12614. * @return the material itself allowing "fluent" like uniform updates
  12615. */
  12616. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12617. /**
  12618. * Set a vec4 in the shader from a Color4.
  12619. * @param name Define the name of the uniform as defined in the shader
  12620. * @param value Define the value to give to the uniform
  12621. * @return the material itself allowing "fluent" like uniform updates
  12622. */
  12623. setColor4(name: string, value: Color4): ShaderMaterial;
  12624. /**
  12625. * Set a vec4 array in the shader from a Color4 array.
  12626. * @param name Define the name of the uniform as defined in the shader
  12627. * @param value Define the value to give to the uniform
  12628. * @return the material itself allowing "fluent" like uniform updates
  12629. */
  12630. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12631. /**
  12632. * Set a vec2 in the shader from a Vector2.
  12633. * @param name Define the name of the uniform as defined in the shader
  12634. * @param value Define the value to give to the uniform
  12635. * @return the material itself allowing "fluent" like uniform updates
  12636. */
  12637. setVector2(name: string, value: Vector2): ShaderMaterial;
  12638. /**
  12639. * Set a vec3 in the shader from a Vector3.
  12640. * @param name Define the name of the uniform as defined in the shader
  12641. * @param value Define the value to give to the uniform
  12642. * @return the material itself allowing "fluent" like uniform updates
  12643. */
  12644. setVector3(name: string, value: Vector3): ShaderMaterial;
  12645. /**
  12646. * Set a vec4 in the shader from a Vector4.
  12647. * @param name Define the name of the uniform as defined in the shader
  12648. * @param value Define the value to give to the uniform
  12649. * @return the material itself allowing "fluent" like uniform updates
  12650. */
  12651. setVector4(name: string, value: Vector4): ShaderMaterial;
  12652. /**
  12653. * Set a mat4 in the shader from a Matrix.
  12654. * @param name Define the name of the uniform as defined in the shader
  12655. * @param value Define the value to give to the uniform
  12656. * @return the material itself allowing "fluent" like uniform updates
  12657. */
  12658. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12659. /**
  12660. * Set a mat3 in the shader from a Float32Array.
  12661. * @param name Define the name of the uniform as defined in the shader
  12662. * @param value Define the value to give to the uniform
  12663. * @return the material itself allowing "fluent" like uniform updates
  12664. */
  12665. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12666. /**
  12667. * Set a mat2 in the shader from a Float32Array.
  12668. * @param name Define the name of the uniform as defined in the shader
  12669. * @param value Define the value to give to the uniform
  12670. * @return the material itself allowing "fluent" like uniform updates
  12671. */
  12672. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12673. /**
  12674. * Set a vec2 array in the shader from a number array.
  12675. * @param name Define the name of the uniform as defined in the shader
  12676. * @param value Define the value to give to the uniform
  12677. * @return the material itself allowing "fluent" like uniform updates
  12678. */
  12679. setArray2(name: string, value: number[]): ShaderMaterial;
  12680. /**
  12681. * Set a vec3 array in the shader from a number array.
  12682. * @param name Define the name of the uniform as defined in the shader
  12683. * @param value Define the value to give to the uniform
  12684. * @return the material itself allowing "fluent" like uniform updates
  12685. */
  12686. setArray3(name: string, value: number[]): ShaderMaterial;
  12687. /**
  12688. * Set a vec4 array in the shader from a number array.
  12689. * @param name Define the name of the uniform as defined in the shader
  12690. * @param value Define the value to give to the uniform
  12691. * @return the material itself allowing "fluent" like uniform updates
  12692. */
  12693. setArray4(name: string, value: number[]): ShaderMaterial;
  12694. private _checkCache;
  12695. /**
  12696. * Specifies that the submesh is ready to be used
  12697. * @param mesh defines the mesh to check
  12698. * @param subMesh defines which submesh to check
  12699. * @param useInstances specifies that instances should be used
  12700. * @returns a boolean indicating that the submesh is ready or not
  12701. */
  12702. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12703. /**
  12704. * Checks if the material is ready to render the requested mesh
  12705. * @param mesh Define the mesh to render
  12706. * @param useInstances Define whether or not the material is used with instances
  12707. * @returns true if ready, otherwise false
  12708. */
  12709. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12710. /**
  12711. * Binds the world matrix to the material
  12712. * @param world defines the world transformation matrix
  12713. */
  12714. bindOnlyWorldMatrix(world: Matrix): void;
  12715. /**
  12716. * Binds the material to the mesh
  12717. * @param world defines the world transformation matrix
  12718. * @param mesh defines the mesh to bind the material to
  12719. */
  12720. bind(world: Matrix, mesh?: Mesh): void;
  12721. /**
  12722. * Gets the active textures from the material
  12723. * @returns an array of textures
  12724. */
  12725. getActiveTextures(): BaseTexture[];
  12726. /**
  12727. * Specifies if the material uses a texture
  12728. * @param texture defines the texture to check against the material
  12729. * @returns a boolean specifying if the material uses the texture
  12730. */
  12731. hasTexture(texture: BaseTexture): boolean;
  12732. /**
  12733. * Makes a duplicate of the material, and gives it a new name
  12734. * @param name defines the new name for the duplicated material
  12735. * @returns the cloned material
  12736. */
  12737. clone(name: string): ShaderMaterial;
  12738. /**
  12739. * Disposes the material
  12740. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12741. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12742. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12743. */
  12744. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12745. /**
  12746. * Serializes this material in a JSON representation
  12747. * @returns the serialized material object
  12748. */
  12749. serialize(): any;
  12750. /**
  12751. * Creates a shader material from parsed shader material data
  12752. * @param source defines the JSON represnetation of the material
  12753. * @param scene defines the hosting scene
  12754. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12755. * @returns a new material
  12756. */
  12757. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12758. }
  12759. }
  12760. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  12761. /** @hidden */
  12762. export var clipPlaneFragmentDeclaration: {
  12763. name: string;
  12764. shader: string;
  12765. };
  12766. }
  12767. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  12768. /** @hidden */
  12769. export var clipPlaneFragment: {
  12770. name: string;
  12771. shader: string;
  12772. };
  12773. }
  12774. declare module "babylonjs/Shaders/color.fragment" {
  12775. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12776. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12777. /** @hidden */
  12778. export var colorPixelShader: {
  12779. name: string;
  12780. shader: string;
  12781. };
  12782. }
  12783. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  12784. /** @hidden */
  12785. export var clipPlaneVertexDeclaration: {
  12786. name: string;
  12787. shader: string;
  12788. };
  12789. }
  12790. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  12791. /** @hidden */
  12792. export var clipPlaneVertex: {
  12793. name: string;
  12794. shader: string;
  12795. };
  12796. }
  12797. declare module "babylonjs/Shaders/color.vertex" {
  12798. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  12799. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12800. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  12801. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  12802. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  12803. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12804. /** @hidden */
  12805. export var colorVertexShader: {
  12806. name: string;
  12807. shader: string;
  12808. };
  12809. }
  12810. declare module "babylonjs/Meshes/linesMesh" {
  12811. import { Nullable } from "babylonjs/types";
  12812. import { Scene } from "babylonjs/scene";
  12813. import { Color3 } from "babylonjs/Maths/math";
  12814. import { Node } from "babylonjs/node";
  12815. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12816. import { Mesh } from "babylonjs/Meshes/mesh";
  12817. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  12818. import { Effect } from "babylonjs/Materials/effect";
  12819. import { Material } from "babylonjs/Materials/material";
  12820. import "babylonjs/Shaders/color.fragment";
  12821. import "babylonjs/Shaders/color.vertex";
  12822. /**
  12823. * Line mesh
  12824. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12825. */
  12826. export class LinesMesh extends Mesh {
  12827. /**
  12828. * If vertex color should be applied to the mesh
  12829. */
  12830. readonly useVertexColor?: boolean | undefined;
  12831. /**
  12832. * If vertex alpha should be applied to the mesh
  12833. */
  12834. readonly useVertexAlpha?: boolean | undefined;
  12835. /**
  12836. * Color of the line (Default: White)
  12837. */
  12838. color: Color3;
  12839. /**
  12840. * Alpha of the line (Default: 1)
  12841. */
  12842. alpha: number;
  12843. /**
  12844. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12845. * This margin is expressed in world space coordinates, so its value may vary.
  12846. * Default value is 0.1
  12847. */
  12848. intersectionThreshold: number;
  12849. private _colorShader;
  12850. private color4;
  12851. /**
  12852. * Creates a new LinesMesh
  12853. * @param name defines the name
  12854. * @param scene defines the hosting scene
  12855. * @param parent defines the parent mesh if any
  12856. * @param source defines the optional source LinesMesh used to clone data from
  12857. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12858. * When false, achieved by calling a clone(), also passing False.
  12859. * This will make creation of children, recursive.
  12860. * @param useVertexColor defines if this LinesMesh supports vertex color
  12861. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12862. */
  12863. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12864. /**
  12865. * If vertex color should be applied to the mesh
  12866. */
  12867. useVertexColor?: boolean | undefined,
  12868. /**
  12869. * If vertex alpha should be applied to the mesh
  12870. */
  12871. useVertexAlpha?: boolean | undefined);
  12872. private _addClipPlaneDefine;
  12873. private _removeClipPlaneDefine;
  12874. isReady(): boolean;
  12875. /**
  12876. * Returns the string "LineMesh"
  12877. */
  12878. getClassName(): string;
  12879. /**
  12880. * @hidden
  12881. */
  12882. /**
  12883. * @hidden
  12884. */
  12885. material: Material;
  12886. /**
  12887. * @hidden
  12888. */
  12889. readonly checkCollisions: boolean;
  12890. /** @hidden */
  12891. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12892. /** @hidden */
  12893. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12894. /**
  12895. * Disposes of the line mesh
  12896. * @param doNotRecurse If children should be disposed
  12897. */
  12898. dispose(doNotRecurse?: boolean): void;
  12899. /**
  12900. * Returns a new LineMesh object cloned from the current one.
  12901. */
  12902. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12903. /**
  12904. * Creates a new InstancedLinesMesh object from the mesh model.
  12905. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12906. * @param name defines the name of the new instance
  12907. * @returns a new InstancedLinesMesh
  12908. */
  12909. createInstance(name: string): InstancedLinesMesh;
  12910. }
  12911. /**
  12912. * Creates an instance based on a source LinesMesh
  12913. */
  12914. export class InstancedLinesMesh extends InstancedMesh {
  12915. /**
  12916. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12917. * This margin is expressed in world space coordinates, so its value may vary.
  12918. * Initilized with the intersectionThreshold value of the source LinesMesh
  12919. */
  12920. intersectionThreshold: number;
  12921. constructor(name: string, source: LinesMesh);
  12922. /**
  12923. * Returns the string "InstancedLinesMesh".
  12924. */
  12925. getClassName(): string;
  12926. }
  12927. }
  12928. declare module "babylonjs/Meshes/groundMesh" {
  12929. import { Scene } from "babylonjs/scene";
  12930. import { Vector3 } from "babylonjs/Maths/math";
  12931. import { Mesh } from "babylonjs/Meshes/mesh";
  12932. /**
  12933. * Mesh representing the gorund
  12934. */
  12935. export class GroundMesh extends Mesh {
  12936. /** If octree should be generated */
  12937. generateOctree: boolean;
  12938. private _heightQuads;
  12939. /** @hidden */
  12940. _subdivisionsX: number;
  12941. /** @hidden */
  12942. _subdivisionsY: number;
  12943. /** @hidden */
  12944. _width: number;
  12945. /** @hidden */
  12946. _height: number;
  12947. /** @hidden */
  12948. _minX: number;
  12949. /** @hidden */
  12950. _maxX: number;
  12951. /** @hidden */
  12952. _minZ: number;
  12953. /** @hidden */
  12954. _maxZ: number;
  12955. constructor(name: string, scene: Scene);
  12956. /**
  12957. * "GroundMesh"
  12958. * @returns "GroundMesh"
  12959. */
  12960. getClassName(): string;
  12961. /**
  12962. * The minimum of x and y subdivisions
  12963. */
  12964. readonly subdivisions: number;
  12965. /**
  12966. * X subdivisions
  12967. */
  12968. readonly subdivisionsX: number;
  12969. /**
  12970. * Y subdivisions
  12971. */
  12972. readonly subdivisionsY: number;
  12973. /**
  12974. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12975. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12976. * @param chunksCount the number of subdivisions for x and y
  12977. * @param octreeBlocksSize (Default: 32)
  12978. */
  12979. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12980. /**
  12981. * Returns a height (y) value in the Worl system :
  12982. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12983. * @param x x coordinate
  12984. * @param z z coordinate
  12985. * @returns the ground y position if (x, z) are outside the ground surface.
  12986. */
  12987. getHeightAtCoordinates(x: number, z: number): number;
  12988. /**
  12989. * Returns a normalized vector (Vector3) orthogonal to the ground
  12990. * at the ground coordinates (x, z) expressed in the World system.
  12991. * @param x x coordinate
  12992. * @param z z coordinate
  12993. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12994. */
  12995. getNormalAtCoordinates(x: number, z: number): Vector3;
  12996. /**
  12997. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12998. * at the ground coordinates (x, z) expressed in the World system.
  12999. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  13000. * @param x x coordinate
  13001. * @param z z coordinate
  13002. * @param ref vector to store the result
  13003. * @returns the GroundMesh.
  13004. */
  13005. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  13006. /**
  13007. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  13008. * if the ground has been updated.
  13009. * This can be used in the render loop.
  13010. * @returns the GroundMesh.
  13011. */
  13012. updateCoordinateHeights(): GroundMesh;
  13013. private _getFacetAt;
  13014. private _initHeightQuads;
  13015. private _computeHeightQuads;
  13016. /**
  13017. * Serializes this ground mesh
  13018. * @param serializationObject object to write serialization to
  13019. */
  13020. serialize(serializationObject: any): void;
  13021. /**
  13022. * Parses a serialized ground mesh
  13023. * @param parsedMesh the serialized mesh
  13024. * @param scene the scene to create the ground mesh in
  13025. * @returns the created ground mesh
  13026. */
  13027. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  13028. }
  13029. }
  13030. declare module "babylonjs/Physics/physicsJoint" {
  13031. import { Vector3 } from "babylonjs/Maths/math";
  13032. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  13033. /**
  13034. * Interface for Physics-Joint data
  13035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13036. */
  13037. export interface PhysicsJointData {
  13038. /**
  13039. * The main pivot of the joint
  13040. */
  13041. mainPivot?: Vector3;
  13042. /**
  13043. * The connected pivot of the joint
  13044. */
  13045. connectedPivot?: Vector3;
  13046. /**
  13047. * The main axis of the joint
  13048. */
  13049. mainAxis?: Vector3;
  13050. /**
  13051. * The connected axis of the joint
  13052. */
  13053. connectedAxis?: Vector3;
  13054. /**
  13055. * The collision of the joint
  13056. */
  13057. collision?: boolean;
  13058. /**
  13059. * Native Oimo/Cannon/Energy data
  13060. */
  13061. nativeParams?: any;
  13062. }
  13063. /**
  13064. * This is a holder class for the physics joint created by the physics plugin
  13065. * It holds a set of functions to control the underlying joint
  13066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13067. */
  13068. export class PhysicsJoint {
  13069. /**
  13070. * The type of the physics joint
  13071. */
  13072. type: number;
  13073. /**
  13074. * The data for the physics joint
  13075. */
  13076. jointData: PhysicsJointData;
  13077. private _physicsJoint;
  13078. protected _physicsPlugin: IPhysicsEnginePlugin;
  13079. /**
  13080. * Initializes the physics joint
  13081. * @param type The type of the physics joint
  13082. * @param jointData The data for the physics joint
  13083. */
  13084. constructor(
  13085. /**
  13086. * The type of the physics joint
  13087. */
  13088. type: number,
  13089. /**
  13090. * The data for the physics joint
  13091. */
  13092. jointData: PhysicsJointData);
  13093. /**
  13094. * Gets the physics joint
  13095. */
  13096. /**
  13097. * Sets the physics joint
  13098. */
  13099. physicsJoint: any;
  13100. /**
  13101. * Sets the physics plugin
  13102. */
  13103. physicsPlugin: IPhysicsEnginePlugin;
  13104. /**
  13105. * Execute a function that is physics-plugin specific.
  13106. * @param {Function} func the function that will be executed.
  13107. * It accepts two parameters: the physics world and the physics joint
  13108. */
  13109. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  13110. /**
  13111. * Distance-Joint type
  13112. */
  13113. static DistanceJoint: number;
  13114. /**
  13115. * Hinge-Joint type
  13116. */
  13117. static HingeJoint: number;
  13118. /**
  13119. * Ball-and-Socket joint type
  13120. */
  13121. static BallAndSocketJoint: number;
  13122. /**
  13123. * Wheel-Joint type
  13124. */
  13125. static WheelJoint: number;
  13126. /**
  13127. * Slider-Joint type
  13128. */
  13129. static SliderJoint: number;
  13130. /**
  13131. * Prismatic-Joint type
  13132. */
  13133. static PrismaticJoint: number;
  13134. /**
  13135. * Universal-Joint type
  13136. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  13137. */
  13138. static UniversalJoint: number;
  13139. /**
  13140. * Hinge-Joint 2 type
  13141. */
  13142. static Hinge2Joint: number;
  13143. /**
  13144. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  13145. */
  13146. static PointToPointJoint: number;
  13147. /**
  13148. * Spring-Joint type
  13149. */
  13150. static SpringJoint: number;
  13151. /**
  13152. * Lock-Joint type
  13153. */
  13154. static LockJoint: number;
  13155. }
  13156. /**
  13157. * A class representing a physics distance joint
  13158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13159. */
  13160. export class DistanceJoint extends PhysicsJoint {
  13161. /**
  13162. *
  13163. * @param jointData The data for the Distance-Joint
  13164. */
  13165. constructor(jointData: DistanceJointData);
  13166. /**
  13167. * Update the predefined distance.
  13168. * @param maxDistance The maximum preferred distance
  13169. * @param minDistance The minimum preferred distance
  13170. */
  13171. updateDistance(maxDistance: number, minDistance?: number): void;
  13172. }
  13173. /**
  13174. * Represents a Motor-Enabled Joint
  13175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13176. */
  13177. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  13178. /**
  13179. * Initializes the Motor-Enabled Joint
  13180. * @param type The type of the joint
  13181. * @param jointData The physica joint data for the joint
  13182. */
  13183. constructor(type: number, jointData: PhysicsJointData);
  13184. /**
  13185. * Set the motor values.
  13186. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13187. * @param force the force to apply
  13188. * @param maxForce max force for this motor.
  13189. */
  13190. setMotor(force?: number, maxForce?: number): void;
  13191. /**
  13192. * Set the motor's limits.
  13193. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13194. * @param upperLimit The upper limit of the motor
  13195. * @param lowerLimit The lower limit of the motor
  13196. */
  13197. setLimit(upperLimit: number, lowerLimit?: number): void;
  13198. }
  13199. /**
  13200. * This class represents a single physics Hinge-Joint
  13201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13202. */
  13203. export class HingeJoint extends MotorEnabledJoint {
  13204. /**
  13205. * Initializes the Hinge-Joint
  13206. * @param jointData The joint data for the Hinge-Joint
  13207. */
  13208. constructor(jointData: PhysicsJointData);
  13209. /**
  13210. * Set the motor values.
  13211. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13212. * @param {number} force the force to apply
  13213. * @param {number} maxForce max force for this motor.
  13214. */
  13215. setMotor(force?: number, maxForce?: number): void;
  13216. /**
  13217. * Set the motor's limits.
  13218. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13219. * @param upperLimit The upper limit of the motor
  13220. * @param lowerLimit The lower limit of the motor
  13221. */
  13222. setLimit(upperLimit: number, lowerLimit?: number): void;
  13223. }
  13224. /**
  13225. * This class represents a dual hinge physics joint (same as wheel joint)
  13226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13227. */
  13228. export class Hinge2Joint extends MotorEnabledJoint {
  13229. /**
  13230. * Initializes the Hinge2-Joint
  13231. * @param jointData The joint data for the Hinge2-Joint
  13232. */
  13233. constructor(jointData: PhysicsJointData);
  13234. /**
  13235. * Set the motor values.
  13236. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13237. * @param {number} targetSpeed the speed the motor is to reach
  13238. * @param {number} maxForce max force for this motor.
  13239. * @param {motorIndex} the motor's index, 0 or 1.
  13240. */
  13241. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13242. /**
  13243. * Set the motor limits.
  13244. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13245. * @param {number} upperLimit the upper limit
  13246. * @param {number} lowerLimit lower limit
  13247. * @param {motorIndex} the motor's index, 0 or 1.
  13248. */
  13249. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13250. }
  13251. /**
  13252. * Interface for a motor enabled joint
  13253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13254. */
  13255. export interface IMotorEnabledJoint {
  13256. /**
  13257. * Physics joint
  13258. */
  13259. physicsJoint: any;
  13260. /**
  13261. * Sets the motor of the motor-enabled joint
  13262. * @param force The force of the motor
  13263. * @param maxForce The maximum force of the motor
  13264. * @param motorIndex The index of the motor
  13265. */
  13266. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13267. /**
  13268. * Sets the limit of the motor
  13269. * @param upperLimit The upper limit of the motor
  13270. * @param lowerLimit The lower limit of the motor
  13271. * @param motorIndex The index of the motor
  13272. */
  13273. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13274. }
  13275. /**
  13276. * Joint data for a Distance-Joint
  13277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13278. */
  13279. export interface DistanceJointData extends PhysicsJointData {
  13280. /**
  13281. * Max distance the 2 joint objects can be apart
  13282. */
  13283. maxDistance: number;
  13284. }
  13285. /**
  13286. * Joint data from a spring joint
  13287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13288. */
  13289. export interface SpringJointData extends PhysicsJointData {
  13290. /**
  13291. * Length of the spring
  13292. */
  13293. length: number;
  13294. /**
  13295. * Stiffness of the spring
  13296. */
  13297. stiffness: number;
  13298. /**
  13299. * Damping of the spring
  13300. */
  13301. damping: number;
  13302. /** this callback will be called when applying the force to the impostors. */
  13303. forceApplicationCallback: () => void;
  13304. }
  13305. }
  13306. declare module "babylonjs/Physics/physicsRaycastResult" {
  13307. import { Vector3 } from "babylonjs/Maths/math";
  13308. /**
  13309. * Holds the data for the raycast result
  13310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13311. */
  13312. export class PhysicsRaycastResult {
  13313. private _hasHit;
  13314. private _hitDistance;
  13315. private _hitNormalWorld;
  13316. private _hitPointWorld;
  13317. private _rayFromWorld;
  13318. private _rayToWorld;
  13319. /**
  13320. * Gets if there was a hit
  13321. */
  13322. readonly hasHit: boolean;
  13323. /**
  13324. * Gets the distance from the hit
  13325. */
  13326. readonly hitDistance: number;
  13327. /**
  13328. * Gets the hit normal/direction in the world
  13329. */
  13330. readonly hitNormalWorld: Vector3;
  13331. /**
  13332. * Gets the hit point in the world
  13333. */
  13334. readonly hitPointWorld: Vector3;
  13335. /**
  13336. * Gets the ray "start point" of the ray in the world
  13337. */
  13338. readonly rayFromWorld: Vector3;
  13339. /**
  13340. * Gets the ray "end point" of the ray in the world
  13341. */
  13342. readonly rayToWorld: Vector3;
  13343. /**
  13344. * Sets the hit data (normal & point in world space)
  13345. * @param hitNormalWorld defines the normal in world space
  13346. * @param hitPointWorld defines the point in world space
  13347. */
  13348. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13349. /**
  13350. * Sets the distance from the start point to the hit point
  13351. * @param distance
  13352. */
  13353. setHitDistance(distance: number): void;
  13354. /**
  13355. * Calculates the distance manually
  13356. */
  13357. calculateHitDistance(): void;
  13358. /**
  13359. * Resets all the values to default
  13360. * @param from The from point on world space
  13361. * @param to The to point on world space
  13362. */
  13363. reset(from?: Vector3, to?: Vector3): void;
  13364. }
  13365. /**
  13366. * Interface for the size containing width and height
  13367. */
  13368. interface IXYZ {
  13369. /**
  13370. * X
  13371. */
  13372. x: number;
  13373. /**
  13374. * Y
  13375. */
  13376. y: number;
  13377. /**
  13378. * Z
  13379. */
  13380. z: number;
  13381. }
  13382. }
  13383. declare module "babylonjs/Physics/IPhysicsEngine" {
  13384. import { Nullable } from "babylonjs/types";
  13385. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  13386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13387. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  13388. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  13389. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  13390. /**
  13391. * Interface used to describe a physics joint
  13392. */
  13393. export interface PhysicsImpostorJoint {
  13394. /** Defines the main impostor to which the joint is linked */
  13395. mainImpostor: PhysicsImpostor;
  13396. /** Defines the impostor that is connected to the main impostor using this joint */
  13397. connectedImpostor: PhysicsImpostor;
  13398. /** Defines the joint itself */
  13399. joint: PhysicsJoint;
  13400. }
  13401. /** @hidden */
  13402. export interface IPhysicsEnginePlugin {
  13403. world: any;
  13404. name: string;
  13405. setGravity(gravity: Vector3): void;
  13406. setTimeStep(timeStep: number): void;
  13407. getTimeStep(): number;
  13408. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13409. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13410. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13411. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13412. removePhysicsBody(impostor: PhysicsImpostor): void;
  13413. generateJoint(joint: PhysicsImpostorJoint): void;
  13414. removeJoint(joint: PhysicsImpostorJoint): void;
  13415. isSupported(): boolean;
  13416. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13417. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13418. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13419. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13420. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13421. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13422. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13423. getBodyMass(impostor: PhysicsImpostor): number;
  13424. getBodyFriction(impostor: PhysicsImpostor): number;
  13425. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13426. getBodyRestitution(impostor: PhysicsImpostor): number;
  13427. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13428. getBodyPressure?(impostor: PhysicsImpostor): number;
  13429. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13430. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13431. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13432. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13433. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13434. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13435. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13436. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13437. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13438. sleepBody(impostor: PhysicsImpostor): void;
  13439. wakeUpBody(impostor: PhysicsImpostor): void;
  13440. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13441. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13442. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13443. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13444. getRadius(impostor: PhysicsImpostor): number;
  13445. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13446. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13447. dispose(): void;
  13448. }
  13449. /**
  13450. * Interface used to define a physics engine
  13451. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13452. */
  13453. export interface IPhysicsEngine {
  13454. /**
  13455. * Gets the gravity vector used by the simulation
  13456. */
  13457. gravity: Vector3;
  13458. /**
  13459. * Sets the gravity vector used by the simulation
  13460. * @param gravity defines the gravity vector to use
  13461. */
  13462. setGravity(gravity: Vector3): void;
  13463. /**
  13464. * Set the time step of the physics engine.
  13465. * Default is 1/60.
  13466. * To slow it down, enter 1/600 for example.
  13467. * To speed it up, 1/30
  13468. * @param newTimeStep the new timestep to apply to this world.
  13469. */
  13470. setTimeStep(newTimeStep: number): void;
  13471. /**
  13472. * Get the time step of the physics engine.
  13473. * @returns the current time step
  13474. */
  13475. getTimeStep(): number;
  13476. /**
  13477. * Release all resources
  13478. */
  13479. dispose(): void;
  13480. /**
  13481. * Gets the name of the current physics plugin
  13482. * @returns the name of the plugin
  13483. */
  13484. getPhysicsPluginName(): string;
  13485. /**
  13486. * Adding a new impostor for the impostor tracking.
  13487. * This will be done by the impostor itself.
  13488. * @param impostor the impostor to add
  13489. */
  13490. addImpostor(impostor: PhysicsImpostor): void;
  13491. /**
  13492. * Remove an impostor from the engine.
  13493. * This impostor and its mesh will not longer be updated by the physics engine.
  13494. * @param impostor the impostor to remove
  13495. */
  13496. removeImpostor(impostor: PhysicsImpostor): void;
  13497. /**
  13498. * Add a joint to the physics engine
  13499. * @param mainImpostor defines the main impostor to which the joint is added.
  13500. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13501. * @param joint defines the joint that will connect both impostors.
  13502. */
  13503. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13504. /**
  13505. * Removes a joint from the simulation
  13506. * @param mainImpostor defines the impostor used with the joint
  13507. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13508. * @param joint defines the joint to remove
  13509. */
  13510. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13511. /**
  13512. * Gets the current plugin used to run the simulation
  13513. * @returns current plugin
  13514. */
  13515. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13516. /**
  13517. * Gets the list of physic impostors
  13518. * @returns an array of PhysicsImpostor
  13519. */
  13520. getImpostors(): Array<PhysicsImpostor>;
  13521. /**
  13522. * Gets the impostor for a physics enabled object
  13523. * @param object defines the object impersonated by the impostor
  13524. * @returns the PhysicsImpostor or null if not found
  13525. */
  13526. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13527. /**
  13528. * Gets the impostor for a physics body object
  13529. * @param body defines physics body used by the impostor
  13530. * @returns the PhysicsImpostor or null if not found
  13531. */
  13532. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13533. /**
  13534. * Does a raycast in the physics world
  13535. * @param from when should the ray start?
  13536. * @param to when should the ray end?
  13537. * @returns PhysicsRaycastResult
  13538. */
  13539. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13540. /**
  13541. * Called by the scene. No need to call it.
  13542. * @param delta defines the timespam between frames
  13543. */
  13544. _step(delta: number): void;
  13545. }
  13546. }
  13547. declare module "babylonjs/Physics/physicsImpostor" {
  13548. import { Nullable, IndicesArray } from "babylonjs/types";
  13549. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  13550. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13552. import { Scene } from "babylonjs/scene";
  13553. import { Bone } from "babylonjs/Bones/bone";
  13554. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  13555. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  13556. /**
  13557. * The interface for the physics imposter parameters
  13558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13559. */
  13560. export interface PhysicsImpostorParameters {
  13561. /**
  13562. * The mass of the physics imposter
  13563. */
  13564. mass: number;
  13565. /**
  13566. * The friction of the physics imposter
  13567. */
  13568. friction?: number;
  13569. /**
  13570. * The coefficient of restitution of the physics imposter
  13571. */
  13572. restitution?: number;
  13573. /**
  13574. * The native options of the physics imposter
  13575. */
  13576. nativeOptions?: any;
  13577. /**
  13578. * Specifies if the parent should be ignored
  13579. */
  13580. ignoreParent?: boolean;
  13581. /**
  13582. * Specifies if bi-directional transformations should be disabled
  13583. */
  13584. disableBidirectionalTransformation?: boolean;
  13585. /**
  13586. * The pressure inside the physics imposter, soft object only
  13587. */
  13588. pressure?: number;
  13589. /**
  13590. * The stiffness the physics imposter, soft object only
  13591. */
  13592. stiffness?: number;
  13593. /**
  13594. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13595. */
  13596. velocityIterations?: number;
  13597. /**
  13598. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13599. */
  13600. positionIterations?: number;
  13601. /**
  13602. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13603. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13604. * Add to fix multiple points
  13605. */
  13606. fixedPoints?: number;
  13607. /**
  13608. * The collision margin around a soft object
  13609. */
  13610. margin?: number;
  13611. /**
  13612. * The collision margin around a soft object
  13613. */
  13614. damping?: number;
  13615. /**
  13616. * The path for a rope based on an extrusion
  13617. */
  13618. path?: any;
  13619. /**
  13620. * The shape of an extrusion used for a rope based on an extrusion
  13621. */
  13622. shape?: any;
  13623. }
  13624. /**
  13625. * Interface for a physics-enabled object
  13626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13627. */
  13628. export interface IPhysicsEnabledObject {
  13629. /**
  13630. * The position of the physics-enabled object
  13631. */
  13632. position: Vector3;
  13633. /**
  13634. * The rotation of the physics-enabled object
  13635. */
  13636. rotationQuaternion: Nullable<Quaternion>;
  13637. /**
  13638. * The scale of the physics-enabled object
  13639. */
  13640. scaling: Vector3;
  13641. /**
  13642. * The rotation of the physics-enabled object
  13643. */
  13644. rotation?: Vector3;
  13645. /**
  13646. * The parent of the physics-enabled object
  13647. */
  13648. parent?: any;
  13649. /**
  13650. * The bounding info of the physics-enabled object
  13651. * @returns The bounding info of the physics-enabled object
  13652. */
  13653. getBoundingInfo(): BoundingInfo;
  13654. /**
  13655. * Computes the world matrix
  13656. * @param force Specifies if the world matrix should be computed by force
  13657. * @returns A world matrix
  13658. */
  13659. computeWorldMatrix(force: boolean): Matrix;
  13660. /**
  13661. * Gets the world matrix
  13662. * @returns A world matrix
  13663. */
  13664. getWorldMatrix?(): Matrix;
  13665. /**
  13666. * Gets the child meshes
  13667. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13668. * @returns An array of abstract meshes
  13669. */
  13670. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13671. /**
  13672. * Gets the vertex data
  13673. * @param kind The type of vertex data
  13674. * @returns A nullable array of numbers, or a float32 array
  13675. */
  13676. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13677. /**
  13678. * Gets the indices from the mesh
  13679. * @returns A nullable array of index arrays
  13680. */
  13681. getIndices?(): Nullable<IndicesArray>;
  13682. /**
  13683. * Gets the scene from the mesh
  13684. * @returns the indices array or null
  13685. */
  13686. getScene?(): Scene;
  13687. /**
  13688. * Gets the absolute position from the mesh
  13689. * @returns the absolute position
  13690. */
  13691. getAbsolutePosition(): Vector3;
  13692. /**
  13693. * Gets the absolute pivot point from the mesh
  13694. * @returns the absolute pivot point
  13695. */
  13696. getAbsolutePivotPoint(): Vector3;
  13697. /**
  13698. * Rotates the mesh
  13699. * @param axis The axis of rotation
  13700. * @param amount The amount of rotation
  13701. * @param space The space of the rotation
  13702. * @returns The rotation transform node
  13703. */
  13704. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13705. /**
  13706. * Translates the mesh
  13707. * @param axis The axis of translation
  13708. * @param distance The distance of translation
  13709. * @param space The space of the translation
  13710. * @returns The transform node
  13711. */
  13712. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13713. /**
  13714. * Sets the absolute position of the mesh
  13715. * @param absolutePosition The absolute position of the mesh
  13716. * @returns The transform node
  13717. */
  13718. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13719. /**
  13720. * Gets the class name of the mesh
  13721. * @returns The class name
  13722. */
  13723. getClassName(): string;
  13724. }
  13725. /**
  13726. * Represents a physics imposter
  13727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13728. */
  13729. export class PhysicsImpostor {
  13730. /**
  13731. * The physics-enabled object used as the physics imposter
  13732. */
  13733. object: IPhysicsEnabledObject;
  13734. /**
  13735. * The type of the physics imposter
  13736. */
  13737. type: number;
  13738. private _options;
  13739. private _scene?;
  13740. /**
  13741. * The default object size of the imposter
  13742. */
  13743. static DEFAULT_OBJECT_SIZE: Vector3;
  13744. /**
  13745. * The identity quaternion of the imposter
  13746. */
  13747. static IDENTITY_QUATERNION: Quaternion;
  13748. /** @hidden */
  13749. _pluginData: any;
  13750. private _physicsEngine;
  13751. private _physicsBody;
  13752. private _bodyUpdateRequired;
  13753. private _onBeforePhysicsStepCallbacks;
  13754. private _onAfterPhysicsStepCallbacks;
  13755. /** @hidden */
  13756. _onPhysicsCollideCallbacks: Array<{
  13757. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13758. otherImpostors: Array<PhysicsImpostor>;
  13759. }>;
  13760. private _deltaPosition;
  13761. private _deltaRotation;
  13762. private _deltaRotationConjugated;
  13763. /** @hidden */
  13764. _isFromLine: boolean;
  13765. private _parent;
  13766. private _isDisposed;
  13767. private static _tmpVecs;
  13768. private static _tmpQuat;
  13769. /**
  13770. * Specifies if the physics imposter is disposed
  13771. */
  13772. readonly isDisposed: boolean;
  13773. /**
  13774. * Gets the mass of the physics imposter
  13775. */
  13776. mass: number;
  13777. /**
  13778. * Gets the coefficient of friction
  13779. */
  13780. /**
  13781. * Sets the coefficient of friction
  13782. */
  13783. friction: number;
  13784. /**
  13785. * Gets the coefficient of restitution
  13786. */
  13787. /**
  13788. * Sets the coefficient of restitution
  13789. */
  13790. restitution: number;
  13791. /**
  13792. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13793. */
  13794. /**
  13795. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13796. */
  13797. pressure: number;
  13798. /**
  13799. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13800. */
  13801. /**
  13802. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13803. */
  13804. stiffness: number;
  13805. /**
  13806. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13807. */
  13808. /**
  13809. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13810. */
  13811. velocityIterations: number;
  13812. /**
  13813. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13814. */
  13815. /**
  13816. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13817. */
  13818. positionIterations: number;
  13819. /**
  13820. * The unique id of the physics imposter
  13821. * set by the physics engine when adding this impostor to the array
  13822. */
  13823. uniqueId: number;
  13824. /**
  13825. * @hidden
  13826. */
  13827. soft: boolean;
  13828. /**
  13829. * @hidden
  13830. */
  13831. segments: number;
  13832. private _joints;
  13833. /**
  13834. * Initializes the physics imposter
  13835. * @param object The physics-enabled object used as the physics imposter
  13836. * @param type The type of the physics imposter
  13837. * @param _options The options for the physics imposter
  13838. * @param _scene The Babylon scene
  13839. */
  13840. constructor(
  13841. /**
  13842. * The physics-enabled object used as the physics imposter
  13843. */
  13844. object: IPhysicsEnabledObject,
  13845. /**
  13846. * The type of the physics imposter
  13847. */
  13848. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13849. /**
  13850. * This function will completly initialize this impostor.
  13851. * It will create a new body - but only if this mesh has no parent.
  13852. * If it has, this impostor will not be used other than to define the impostor
  13853. * of the child mesh.
  13854. * @hidden
  13855. */
  13856. _init(): void;
  13857. private _getPhysicsParent;
  13858. /**
  13859. * Should a new body be generated.
  13860. * @returns boolean specifying if body initialization is required
  13861. */
  13862. isBodyInitRequired(): boolean;
  13863. /**
  13864. * Sets the updated scaling
  13865. * @param updated Specifies if the scaling is updated
  13866. */
  13867. setScalingUpdated(): void;
  13868. /**
  13869. * Force a regeneration of this or the parent's impostor's body.
  13870. * Use under cautious - This will remove all joints already implemented.
  13871. */
  13872. forceUpdate(): void;
  13873. /**
  13874. * Gets the body that holds this impostor. Either its own, or its parent.
  13875. */
  13876. /**
  13877. * Set the physics body. Used mainly by the physics engine/plugin
  13878. */
  13879. physicsBody: any;
  13880. /**
  13881. * Get the parent of the physics imposter
  13882. * @returns Physics imposter or null
  13883. */
  13884. /**
  13885. * Sets the parent of the physics imposter
  13886. */
  13887. parent: Nullable<PhysicsImpostor>;
  13888. /**
  13889. * Resets the update flags
  13890. */
  13891. resetUpdateFlags(): void;
  13892. /**
  13893. * Gets the object extend size
  13894. * @returns the object extend size
  13895. */
  13896. getObjectExtendSize(): Vector3;
  13897. /**
  13898. * Gets the object center
  13899. * @returns The object center
  13900. */
  13901. getObjectCenter(): Vector3;
  13902. /**
  13903. * Get a specific parametes from the options parameter
  13904. * @param paramName The object parameter name
  13905. * @returns The object parameter
  13906. */
  13907. getParam(paramName: string): any;
  13908. /**
  13909. * Sets a specific parameter in the options given to the physics plugin
  13910. * @param paramName The parameter name
  13911. * @param value The value of the parameter
  13912. */
  13913. setParam(paramName: string, value: number): void;
  13914. /**
  13915. * Specifically change the body's mass option. Won't recreate the physics body object
  13916. * @param mass The mass of the physics imposter
  13917. */
  13918. setMass(mass: number): void;
  13919. /**
  13920. * Gets the linear velocity
  13921. * @returns linear velocity or null
  13922. */
  13923. getLinearVelocity(): Nullable<Vector3>;
  13924. /**
  13925. * Sets the linear velocity
  13926. * @param velocity linear velocity or null
  13927. */
  13928. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13929. /**
  13930. * Gets the angular velocity
  13931. * @returns angular velocity or null
  13932. */
  13933. getAngularVelocity(): Nullable<Vector3>;
  13934. /**
  13935. * Sets the angular velocity
  13936. * @param velocity The velocity or null
  13937. */
  13938. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13939. /**
  13940. * Execute a function with the physics plugin native code
  13941. * Provide a function the will have two variables - the world object and the physics body object
  13942. * @param func The function to execute with the physics plugin native code
  13943. */
  13944. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13945. /**
  13946. * Register a function that will be executed before the physics world is stepping forward
  13947. * @param func The function to execute before the physics world is stepped forward
  13948. */
  13949. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13950. /**
  13951. * Unregister a function that will be executed before the physics world is stepping forward
  13952. * @param func The function to execute before the physics world is stepped forward
  13953. */
  13954. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13955. /**
  13956. * Register a function that will be executed after the physics step
  13957. * @param func The function to execute after physics step
  13958. */
  13959. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13960. /**
  13961. * Unregisters a function that will be executed after the physics step
  13962. * @param func The function to execute after physics step
  13963. */
  13964. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13965. /**
  13966. * register a function that will be executed when this impostor collides against a different body
  13967. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13968. * @param func Callback that is executed on collision
  13969. */
  13970. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13971. /**
  13972. * Unregisters the physics imposter on contact
  13973. * @param collideAgainst The physics object to collide against
  13974. * @param func Callback to execute on collision
  13975. */
  13976. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13977. private _tmpQuat;
  13978. private _tmpQuat2;
  13979. /**
  13980. * Get the parent rotation
  13981. * @returns The parent rotation
  13982. */
  13983. getParentsRotation(): Quaternion;
  13984. /**
  13985. * this function is executed by the physics engine.
  13986. */
  13987. beforeStep: () => void;
  13988. /**
  13989. * this function is executed by the physics engine
  13990. */
  13991. afterStep: () => void;
  13992. /**
  13993. * Legacy collision detection event support
  13994. */
  13995. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13996. /**
  13997. * event and body object due to cannon's event-based architecture.
  13998. */
  13999. onCollide: (e: {
  14000. body: any;
  14001. }) => void;
  14002. /**
  14003. * Apply a force
  14004. * @param force The force to apply
  14005. * @param contactPoint The contact point for the force
  14006. * @returns The physics imposter
  14007. */
  14008. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14009. /**
  14010. * Apply an impulse
  14011. * @param force The impulse force
  14012. * @param contactPoint The contact point for the impulse force
  14013. * @returns The physics imposter
  14014. */
  14015. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14016. /**
  14017. * A help function to create a joint
  14018. * @param otherImpostor A physics imposter used to create a joint
  14019. * @param jointType The type of joint
  14020. * @param jointData The data for the joint
  14021. * @returns The physics imposter
  14022. */
  14023. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  14024. /**
  14025. * Add a joint to this impostor with a different impostor
  14026. * @param otherImpostor A physics imposter used to add a joint
  14027. * @param joint The joint to add
  14028. * @returns The physics imposter
  14029. */
  14030. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  14031. /**
  14032. * Add an anchor to a cloth impostor
  14033. * @param otherImpostor rigid impostor to anchor to
  14034. * @param width ratio across width from 0 to 1
  14035. * @param height ratio up height from 0 to 1
  14036. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  14037. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  14038. * @returns impostor the soft imposter
  14039. */
  14040. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14041. /**
  14042. * Add a hook to a rope impostor
  14043. * @param otherImpostor rigid impostor to anchor to
  14044. * @param length ratio across rope from 0 to 1
  14045. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  14046. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  14047. * @returns impostor the rope imposter
  14048. */
  14049. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14050. /**
  14051. * Will keep this body still, in a sleep mode.
  14052. * @returns the physics imposter
  14053. */
  14054. sleep(): PhysicsImpostor;
  14055. /**
  14056. * Wake the body up.
  14057. * @returns The physics imposter
  14058. */
  14059. wakeUp(): PhysicsImpostor;
  14060. /**
  14061. * Clones the physics imposter
  14062. * @param newObject The physics imposter clones to this physics-enabled object
  14063. * @returns A nullable physics imposter
  14064. */
  14065. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  14066. /**
  14067. * Disposes the physics imposter
  14068. */
  14069. dispose(): void;
  14070. /**
  14071. * Sets the delta position
  14072. * @param position The delta position amount
  14073. */
  14074. setDeltaPosition(position: Vector3): void;
  14075. /**
  14076. * Sets the delta rotation
  14077. * @param rotation The delta rotation amount
  14078. */
  14079. setDeltaRotation(rotation: Quaternion): void;
  14080. /**
  14081. * Gets the box size of the physics imposter and stores the result in the input parameter
  14082. * @param result Stores the box size
  14083. * @returns The physics imposter
  14084. */
  14085. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  14086. /**
  14087. * Gets the radius of the physics imposter
  14088. * @returns Radius of the physics imposter
  14089. */
  14090. getRadius(): number;
  14091. /**
  14092. * Sync a bone with this impostor
  14093. * @param bone The bone to sync to the impostor.
  14094. * @param boneMesh The mesh that the bone is influencing.
  14095. * @param jointPivot The pivot of the joint / bone in local space.
  14096. * @param distToJoint Optional distance from the impostor to the joint.
  14097. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14098. */
  14099. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  14100. /**
  14101. * Sync impostor to a bone
  14102. * @param bone The bone that the impostor will be synced to.
  14103. * @param boneMesh The mesh that the bone is influencing.
  14104. * @param jointPivot The pivot of the joint / bone in local space.
  14105. * @param distToJoint Optional distance from the impostor to the joint.
  14106. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14107. * @param boneAxis Optional vector3 axis the bone is aligned with
  14108. */
  14109. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  14110. /**
  14111. * No-Imposter type
  14112. */
  14113. static NoImpostor: number;
  14114. /**
  14115. * Sphere-Imposter type
  14116. */
  14117. static SphereImpostor: number;
  14118. /**
  14119. * Box-Imposter type
  14120. */
  14121. static BoxImpostor: number;
  14122. /**
  14123. * Plane-Imposter type
  14124. */
  14125. static PlaneImpostor: number;
  14126. /**
  14127. * Mesh-imposter type
  14128. */
  14129. static MeshImpostor: number;
  14130. /**
  14131. * Capsule-Impostor type (Ammo.js plugin only)
  14132. */
  14133. static CapsuleImpostor: number;
  14134. /**
  14135. * Cylinder-Imposter type
  14136. */
  14137. static CylinderImpostor: number;
  14138. /**
  14139. * Particle-Imposter type
  14140. */
  14141. static ParticleImpostor: number;
  14142. /**
  14143. * Heightmap-Imposter type
  14144. */
  14145. static HeightmapImpostor: number;
  14146. /**
  14147. * ConvexHull-Impostor type (Ammo.js plugin only)
  14148. */
  14149. static ConvexHullImpostor: number;
  14150. /**
  14151. * Rope-Imposter type
  14152. */
  14153. static RopeImpostor: number;
  14154. /**
  14155. * Cloth-Imposter type
  14156. */
  14157. static ClothImpostor: number;
  14158. /**
  14159. * Softbody-Imposter type
  14160. */
  14161. static SoftbodyImpostor: number;
  14162. }
  14163. }
  14164. declare module "babylonjs/Meshes/mesh" {
  14165. import { Observable } from "babylonjs/Misc/observable";
  14166. import { IAnimatable } from "babylonjs/Misc/tools";
  14167. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  14168. import { Camera } from "babylonjs/Cameras/camera";
  14169. import { Scene } from "babylonjs/scene";
  14170. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  14171. import { Engine } from "babylonjs/Engines/engine";
  14172. import { Node } from "babylonjs/node";
  14173. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  14174. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  14175. import { Buffer } from "babylonjs/Meshes/buffer";
  14176. import { Geometry } from "babylonjs/Meshes/geometry";
  14177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14178. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14179. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  14180. import { Effect } from "babylonjs/Materials/effect";
  14181. import { Material } from "babylonjs/Materials/material";
  14182. import { Skeleton } from "babylonjs/Bones/skeleton";
  14183. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  14184. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  14185. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  14186. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  14187. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  14188. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  14189. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  14190. /**
  14191. * @hidden
  14192. **/
  14193. export class _CreationDataStorage {
  14194. closePath?: boolean;
  14195. closeArray?: boolean;
  14196. idx: number[];
  14197. dashSize: number;
  14198. gapSize: number;
  14199. path3D: Path3D;
  14200. pathArray: Vector3[][];
  14201. arc: number;
  14202. radius: number;
  14203. cap: number;
  14204. tessellation: number;
  14205. }
  14206. /**
  14207. * @hidden
  14208. **/
  14209. class _InstanceDataStorage {
  14210. visibleInstances: any;
  14211. batchCache: _InstancesBatch;
  14212. instancesBufferSize: number;
  14213. instancesBuffer: Nullable<Buffer>;
  14214. instancesData: Float32Array;
  14215. overridenInstanceCount: number;
  14216. isFrozen: boolean;
  14217. previousBatch: Nullable<_InstancesBatch>;
  14218. hardwareInstancedRendering: boolean;
  14219. sideOrientation: number;
  14220. }
  14221. /**
  14222. * @hidden
  14223. **/
  14224. export class _InstancesBatch {
  14225. mustReturn: boolean;
  14226. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  14227. renderSelf: boolean[];
  14228. hardwareInstancedRendering: boolean[];
  14229. }
  14230. /**
  14231. * Class used to represent renderable models
  14232. */
  14233. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14234. /**
  14235. * Mesh side orientation : usually the external or front surface
  14236. */
  14237. static readonly FRONTSIDE: number;
  14238. /**
  14239. * Mesh side orientation : usually the internal or back surface
  14240. */
  14241. static readonly BACKSIDE: number;
  14242. /**
  14243. * Mesh side orientation : both internal and external or front and back surfaces
  14244. */
  14245. static readonly DOUBLESIDE: number;
  14246. /**
  14247. * Mesh side orientation : by default, `FRONTSIDE`
  14248. */
  14249. static readonly DEFAULTSIDE: number;
  14250. /**
  14251. * Mesh cap setting : no cap
  14252. */
  14253. static readonly NO_CAP: number;
  14254. /**
  14255. * Mesh cap setting : one cap at the beginning of the mesh
  14256. */
  14257. static readonly CAP_START: number;
  14258. /**
  14259. * Mesh cap setting : one cap at the end of the mesh
  14260. */
  14261. static readonly CAP_END: number;
  14262. /**
  14263. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14264. */
  14265. static readonly CAP_ALL: number;
  14266. /**
  14267. * Mesh pattern setting : no flip or rotate
  14268. */
  14269. static readonly NO_FLIP: number;
  14270. /**
  14271. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14272. */
  14273. static readonly FLIP_TILE: number;
  14274. /**
  14275. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14276. */
  14277. static readonly ROTATE_TILE: number;
  14278. /**
  14279. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14280. */
  14281. static readonly FLIP_ROW: number;
  14282. /**
  14283. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14284. */
  14285. static readonly ROTATE_ROW: number;
  14286. /**
  14287. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14288. */
  14289. static readonly FLIP_N_ROTATE_TILE: number;
  14290. /**
  14291. * Mesh pattern setting : rotate pattern and rotate
  14292. */
  14293. static readonly FLIP_N_ROTATE_ROW: number;
  14294. /**
  14295. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14296. */
  14297. static readonly CENTER: number;
  14298. /**
  14299. * Mesh tile positioning : part tiles on left
  14300. */
  14301. static readonly LEFT: number;
  14302. /**
  14303. * Mesh tile positioning : part tiles on right
  14304. */
  14305. static readonly RIGHT: number;
  14306. /**
  14307. * Mesh tile positioning : part tiles on top
  14308. */
  14309. static readonly TOP: number;
  14310. /**
  14311. * Mesh tile positioning : part tiles on bottom
  14312. */
  14313. static readonly BOTTOM: number;
  14314. /**
  14315. * Gets the default side orientation.
  14316. * @param orientation the orientation to value to attempt to get
  14317. * @returns the default orientation
  14318. * @hidden
  14319. */
  14320. static _GetDefaultSideOrientation(orientation?: number): number;
  14321. private _internalMeshDataInfo;
  14322. /**
  14323. * An event triggered before rendering the mesh
  14324. */
  14325. readonly onBeforeRenderObservable: Observable<Mesh>;
  14326. /**
  14327. * An event triggered before binding the mesh
  14328. */
  14329. readonly onBeforeBindObservable: Observable<Mesh>;
  14330. /**
  14331. * An event triggered after rendering the mesh
  14332. */
  14333. readonly onAfterRenderObservable: Observable<Mesh>;
  14334. /**
  14335. * An event triggered before drawing the mesh
  14336. */
  14337. readonly onBeforeDrawObservable: Observable<Mesh>;
  14338. private _onBeforeDrawObserver;
  14339. /**
  14340. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14341. */
  14342. onBeforeDraw: () => void;
  14343. /**
  14344. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14345. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14346. */
  14347. delayLoadState: number;
  14348. /**
  14349. * Gets the list of instances created from this mesh
  14350. * it is not supposed to be modified manually.
  14351. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14352. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14353. */
  14354. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  14355. /**
  14356. * Gets the file containing delay loading data for this mesh
  14357. */
  14358. delayLoadingFile: string;
  14359. /** @hidden */
  14360. _binaryInfo: any;
  14361. /**
  14362. * User defined function used to change how LOD level selection is done
  14363. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14364. */
  14365. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14366. /**
  14367. * Gets or sets the morph target manager
  14368. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14369. */
  14370. morphTargetManager: Nullable<MorphTargetManager>;
  14371. /** @hidden */
  14372. _creationDataStorage: Nullable<_CreationDataStorage>;
  14373. /** @hidden */
  14374. _geometry: Nullable<Geometry>;
  14375. /** @hidden */
  14376. _delayInfo: Array<string>;
  14377. /** @hidden */
  14378. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14379. /** @hidden */
  14380. _instanceDataStorage: _InstanceDataStorage;
  14381. private _effectiveMaterial;
  14382. /** @hidden */
  14383. _shouldGenerateFlatShading: boolean;
  14384. /** @hidden */
  14385. _originalBuilderSideOrientation: number;
  14386. /**
  14387. * Use this property to change the original side orientation defined at construction time
  14388. */
  14389. overrideMaterialSideOrientation: Nullable<number>;
  14390. /**
  14391. * Gets the source mesh (the one used to clone this one from)
  14392. */
  14393. readonly source: Nullable<Mesh>;
  14394. /**
  14395. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14396. */
  14397. isUnIndexed: boolean;
  14398. /**
  14399. * @constructor
  14400. * @param name The value used by scene.getMeshByName() to do a lookup.
  14401. * @param scene The scene to add this mesh to.
  14402. * @param parent The parent of this mesh, if it has one
  14403. * @param source An optional Mesh from which geometry is shared, cloned.
  14404. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14405. * When false, achieved by calling a clone(), also passing False.
  14406. * This will make creation of children, recursive.
  14407. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14408. */
  14409. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14410. /**
  14411. * Gets the class name
  14412. * @returns the string "Mesh".
  14413. */
  14414. getClassName(): string;
  14415. /** @hidden */
  14416. readonly _isMesh: boolean;
  14417. /**
  14418. * Returns a description of this mesh
  14419. * @param fullDetails define if full details about this mesh must be used
  14420. * @returns a descriptive string representing this mesh
  14421. */
  14422. toString(fullDetails?: boolean): string;
  14423. /** @hidden */
  14424. _unBindEffect(): void;
  14425. /**
  14426. * Gets a boolean indicating if this mesh has LOD
  14427. */
  14428. readonly hasLODLevels: boolean;
  14429. /**
  14430. * Gets the list of MeshLODLevel associated with the current mesh
  14431. * @returns an array of MeshLODLevel
  14432. */
  14433. getLODLevels(): MeshLODLevel[];
  14434. private _sortLODLevels;
  14435. /**
  14436. * Add a mesh as LOD level triggered at the given distance.
  14437. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14438. * @param distance The distance from the center of the object to show this level
  14439. * @param mesh The mesh to be added as LOD level (can be null)
  14440. * @return This mesh (for chaining)
  14441. */
  14442. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14443. /**
  14444. * Returns the LOD level mesh at the passed distance or null if not found.
  14445. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14446. * @param distance The distance from the center of the object to show this level
  14447. * @returns a Mesh or `null`
  14448. */
  14449. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14450. /**
  14451. * Remove a mesh from the LOD array
  14452. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14453. * @param mesh defines the mesh to be removed
  14454. * @return This mesh (for chaining)
  14455. */
  14456. removeLODLevel(mesh: Mesh): Mesh;
  14457. /**
  14458. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14459. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14460. * @param camera defines the camera to use to compute distance
  14461. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14462. * @return This mesh (for chaining)
  14463. */
  14464. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14465. /**
  14466. * Gets the mesh internal Geometry object
  14467. */
  14468. readonly geometry: Nullable<Geometry>;
  14469. /**
  14470. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14471. * @returns the total number of vertices
  14472. */
  14473. getTotalVertices(): number;
  14474. /**
  14475. * Returns the content of an associated vertex buffer
  14476. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14477. * - VertexBuffer.PositionKind
  14478. * - VertexBuffer.UVKind
  14479. * - VertexBuffer.UV2Kind
  14480. * - VertexBuffer.UV3Kind
  14481. * - VertexBuffer.UV4Kind
  14482. * - VertexBuffer.UV5Kind
  14483. * - VertexBuffer.UV6Kind
  14484. * - VertexBuffer.ColorKind
  14485. * - VertexBuffer.MatricesIndicesKind
  14486. * - VertexBuffer.MatricesIndicesExtraKind
  14487. * - VertexBuffer.MatricesWeightsKind
  14488. * - VertexBuffer.MatricesWeightsExtraKind
  14489. * @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
  14490. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14491. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14492. */
  14493. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14494. /**
  14495. * Returns the mesh VertexBuffer object from the requested `kind`
  14496. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14497. * - VertexBuffer.PositionKind
  14498. * - VertexBuffer.NormalKind
  14499. * - VertexBuffer.UVKind
  14500. * - VertexBuffer.UV2Kind
  14501. * - VertexBuffer.UV3Kind
  14502. * - VertexBuffer.UV4Kind
  14503. * - VertexBuffer.UV5Kind
  14504. * - VertexBuffer.UV6Kind
  14505. * - VertexBuffer.ColorKind
  14506. * - VertexBuffer.MatricesIndicesKind
  14507. * - VertexBuffer.MatricesIndicesExtraKind
  14508. * - VertexBuffer.MatricesWeightsKind
  14509. * - VertexBuffer.MatricesWeightsExtraKind
  14510. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14511. */
  14512. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14513. /**
  14514. * Tests if a specific vertex buffer is associated with this mesh
  14515. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14516. * - VertexBuffer.PositionKind
  14517. * - VertexBuffer.NormalKind
  14518. * - VertexBuffer.UVKind
  14519. * - VertexBuffer.UV2Kind
  14520. * - VertexBuffer.UV3Kind
  14521. * - VertexBuffer.UV4Kind
  14522. * - VertexBuffer.UV5Kind
  14523. * - VertexBuffer.UV6Kind
  14524. * - VertexBuffer.ColorKind
  14525. * - VertexBuffer.MatricesIndicesKind
  14526. * - VertexBuffer.MatricesIndicesExtraKind
  14527. * - VertexBuffer.MatricesWeightsKind
  14528. * - VertexBuffer.MatricesWeightsExtraKind
  14529. * @returns a boolean
  14530. */
  14531. isVerticesDataPresent(kind: string): boolean;
  14532. /**
  14533. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14534. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14535. * - VertexBuffer.PositionKind
  14536. * - VertexBuffer.UVKind
  14537. * - VertexBuffer.UV2Kind
  14538. * - VertexBuffer.UV3Kind
  14539. * - VertexBuffer.UV4Kind
  14540. * - VertexBuffer.UV5Kind
  14541. * - VertexBuffer.UV6Kind
  14542. * - VertexBuffer.ColorKind
  14543. * - VertexBuffer.MatricesIndicesKind
  14544. * - VertexBuffer.MatricesIndicesExtraKind
  14545. * - VertexBuffer.MatricesWeightsKind
  14546. * - VertexBuffer.MatricesWeightsExtraKind
  14547. * @returns a boolean
  14548. */
  14549. isVertexBufferUpdatable(kind: string): boolean;
  14550. /**
  14551. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14552. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14553. * - VertexBuffer.PositionKind
  14554. * - VertexBuffer.NormalKind
  14555. * - VertexBuffer.UVKind
  14556. * - VertexBuffer.UV2Kind
  14557. * - VertexBuffer.UV3Kind
  14558. * - VertexBuffer.UV4Kind
  14559. * - VertexBuffer.UV5Kind
  14560. * - VertexBuffer.UV6Kind
  14561. * - VertexBuffer.ColorKind
  14562. * - VertexBuffer.MatricesIndicesKind
  14563. * - VertexBuffer.MatricesIndicesExtraKind
  14564. * - VertexBuffer.MatricesWeightsKind
  14565. * - VertexBuffer.MatricesWeightsExtraKind
  14566. * @returns an array of strings
  14567. */
  14568. getVerticesDataKinds(): string[];
  14569. /**
  14570. * Returns a positive integer : the total number of indices in this mesh geometry.
  14571. * @returns the numner of indices or zero if the mesh has no geometry.
  14572. */
  14573. getTotalIndices(): number;
  14574. /**
  14575. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14576. * @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.
  14577. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14578. * @returns the indices array or an empty array if the mesh has no geometry
  14579. */
  14580. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14581. readonly isBlocked: boolean;
  14582. /**
  14583. * Determine if the current mesh is ready to be rendered
  14584. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14585. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14586. * @returns true if all associated assets are ready (material, textures, shaders)
  14587. */
  14588. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14589. /**
  14590. * 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.
  14591. */
  14592. readonly areNormalsFrozen: boolean;
  14593. /**
  14594. * 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.
  14595. * @returns the current mesh
  14596. */
  14597. freezeNormals(): Mesh;
  14598. /**
  14599. * 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
  14600. * @returns the current mesh
  14601. */
  14602. unfreezeNormals(): Mesh;
  14603. /**
  14604. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14605. */
  14606. overridenInstanceCount: number;
  14607. /** @hidden */
  14608. _preActivate(): Mesh;
  14609. /** @hidden */
  14610. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14611. /** @hidden */
  14612. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14613. /**
  14614. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14615. * This means the mesh underlying bounding box and sphere are recomputed.
  14616. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14617. * @returns the current mesh
  14618. */
  14619. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14620. /** @hidden */
  14621. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14622. /**
  14623. * This function will subdivide the mesh into multiple submeshes
  14624. * @param count defines the expected number of submeshes
  14625. */
  14626. subdivide(count: number): void;
  14627. /**
  14628. * Copy a FloatArray into a specific associated vertex buffer
  14629. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14630. * - VertexBuffer.PositionKind
  14631. * - VertexBuffer.UVKind
  14632. * - VertexBuffer.UV2Kind
  14633. * - VertexBuffer.UV3Kind
  14634. * - VertexBuffer.UV4Kind
  14635. * - VertexBuffer.UV5Kind
  14636. * - VertexBuffer.UV6Kind
  14637. * - VertexBuffer.ColorKind
  14638. * - VertexBuffer.MatricesIndicesKind
  14639. * - VertexBuffer.MatricesIndicesExtraKind
  14640. * - VertexBuffer.MatricesWeightsKind
  14641. * - VertexBuffer.MatricesWeightsExtraKind
  14642. * @param data defines the data source
  14643. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14644. * @param stride defines the data stride size (can be null)
  14645. * @returns the current mesh
  14646. */
  14647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14648. /**
  14649. * Flags an associated vertex buffer as updatable
  14650. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14651. * - VertexBuffer.PositionKind
  14652. * - VertexBuffer.UVKind
  14653. * - VertexBuffer.UV2Kind
  14654. * - VertexBuffer.UV3Kind
  14655. * - VertexBuffer.UV4Kind
  14656. * - VertexBuffer.UV5Kind
  14657. * - VertexBuffer.UV6Kind
  14658. * - VertexBuffer.ColorKind
  14659. * - VertexBuffer.MatricesIndicesKind
  14660. * - VertexBuffer.MatricesIndicesExtraKind
  14661. * - VertexBuffer.MatricesWeightsKind
  14662. * - VertexBuffer.MatricesWeightsExtraKind
  14663. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14664. */
  14665. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14666. /**
  14667. * Sets the mesh global Vertex Buffer
  14668. * @param buffer defines the buffer to use
  14669. * @returns the current mesh
  14670. */
  14671. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14672. /**
  14673. * Update a specific associated vertex buffer
  14674. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14675. * - VertexBuffer.PositionKind
  14676. * - VertexBuffer.UVKind
  14677. * - VertexBuffer.UV2Kind
  14678. * - VertexBuffer.UV3Kind
  14679. * - VertexBuffer.UV4Kind
  14680. * - VertexBuffer.UV5Kind
  14681. * - VertexBuffer.UV6Kind
  14682. * - VertexBuffer.ColorKind
  14683. * - VertexBuffer.MatricesIndicesKind
  14684. * - VertexBuffer.MatricesIndicesExtraKind
  14685. * - VertexBuffer.MatricesWeightsKind
  14686. * - VertexBuffer.MatricesWeightsExtraKind
  14687. * @param data defines the data source
  14688. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14689. * @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)
  14690. * @returns the current mesh
  14691. */
  14692. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14693. /**
  14694. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14695. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14696. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14697. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14698. * @returns the current mesh
  14699. */
  14700. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14701. /**
  14702. * Creates a un-shared specific occurence of the geometry for the mesh.
  14703. * @returns the current mesh
  14704. */
  14705. makeGeometryUnique(): Mesh;
  14706. /**
  14707. * Set the index buffer of this mesh
  14708. * @param indices defines the source data
  14709. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14710. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14711. * @returns the current mesh
  14712. */
  14713. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14714. /**
  14715. * Update the current index buffer
  14716. * @param indices defines the source data
  14717. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14718. * @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)
  14719. * @returns the current mesh
  14720. */
  14721. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14722. /**
  14723. * Invert the geometry to move from a right handed system to a left handed one.
  14724. * @returns the current mesh
  14725. */
  14726. toLeftHanded(): Mesh;
  14727. /** @hidden */
  14728. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14729. /** @hidden */
  14730. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14731. /**
  14732. * Registers for this mesh a javascript function called just before the rendering process
  14733. * @param func defines the function to call before rendering this mesh
  14734. * @returns the current mesh
  14735. */
  14736. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14737. /**
  14738. * Disposes a previously registered javascript function called before the rendering
  14739. * @param func defines the function to remove
  14740. * @returns the current mesh
  14741. */
  14742. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14743. /**
  14744. * Registers for this mesh a javascript function called just after the rendering is complete
  14745. * @param func defines the function to call after rendering this mesh
  14746. * @returns the current mesh
  14747. */
  14748. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14749. /**
  14750. * Disposes a previously registered javascript function called after the rendering.
  14751. * @param func defines the function to remove
  14752. * @returns the current mesh
  14753. */
  14754. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14755. /** @hidden */
  14756. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14757. /** @hidden */
  14758. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14759. /** @hidden */
  14760. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14761. /** @hidden */
  14762. _rebuild(): void;
  14763. /** @hidden */
  14764. _freeze(): void;
  14765. /** @hidden */
  14766. _unFreeze(): void;
  14767. /**
  14768. * 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
  14769. * @param subMesh defines the subMesh to render
  14770. * @param enableAlphaMode defines if alpha mode can be changed
  14771. * @returns the current mesh
  14772. */
  14773. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14774. private _onBeforeDraw;
  14775. /**
  14776. * Renormalize the mesh and patch it up if there are no weights
  14777. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14778. * However in the case of zero weights then we set just a single influence to 1.
  14779. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14780. */
  14781. cleanMatrixWeights(): void;
  14782. private normalizeSkinFourWeights;
  14783. private normalizeSkinWeightsAndExtra;
  14784. /**
  14785. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14786. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14787. * the user know there was an issue with importing the mesh
  14788. * @returns a validation object with skinned, valid and report string
  14789. */
  14790. validateSkinning(): {
  14791. skinned: boolean;
  14792. valid: boolean;
  14793. report: string;
  14794. };
  14795. /** @hidden */
  14796. _checkDelayState(): Mesh;
  14797. private _queueLoad;
  14798. /**
  14799. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14800. * A mesh is in the frustum if its bounding box intersects the frustum
  14801. * @param frustumPlanes defines the frustum to test
  14802. * @returns true if the mesh is in the frustum planes
  14803. */
  14804. isInFrustum(frustumPlanes: Plane[]): boolean;
  14805. /**
  14806. * Sets the mesh material by the material or multiMaterial `id` property
  14807. * @param id is a string identifying the material or the multiMaterial
  14808. * @returns the current mesh
  14809. */
  14810. setMaterialByID(id: string): Mesh;
  14811. /**
  14812. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14813. * @returns an array of IAnimatable
  14814. */
  14815. getAnimatables(): IAnimatable[];
  14816. /**
  14817. * Modifies the mesh geometry according to the passed transformation matrix.
  14818. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14819. * The mesh normals are modified using the same transformation.
  14820. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14821. * @param transform defines the transform matrix to use
  14822. * @see http://doc.babylonjs.com/resources/baking_transformations
  14823. * @returns the current mesh
  14824. */
  14825. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14826. /**
  14827. * Modifies the mesh geometry according to its own current World Matrix.
  14828. * The mesh World Matrix is then reset.
  14829. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14830. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14831. * @see http://doc.babylonjs.com/resources/baking_transformations
  14832. * @returns the current mesh
  14833. */
  14834. bakeCurrentTransformIntoVertices(): Mesh;
  14835. /** @hidden */
  14836. readonly _positions: Nullable<Vector3[]>;
  14837. /** @hidden */
  14838. _resetPointsArrayCache(): Mesh;
  14839. /** @hidden */
  14840. _generatePointsArray(): boolean;
  14841. /**
  14842. * Returns a new Mesh object generated from the current mesh properties.
  14843. * This method must not get confused with createInstance()
  14844. * @param name is a string, the name given to the new mesh
  14845. * @param newParent can be any Node object (default `null`)
  14846. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14847. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14848. * @returns a new mesh
  14849. */
  14850. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14851. /**
  14852. * Releases resources associated with this mesh.
  14853. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14854. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14855. */
  14856. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14857. /**
  14858. * Modifies the mesh geometry according to a displacement map.
  14859. * 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.
  14860. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14861. * @param url is a string, the URL from the image file is to be downloaded.
  14862. * @param minHeight is the lower limit of the displacement.
  14863. * @param maxHeight is the upper limit of the displacement.
  14864. * @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.
  14865. * @param uvOffset is an optional vector2 used to offset UV.
  14866. * @param uvScale is an optional vector2 used to scale UV.
  14867. * @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.
  14868. * @returns the Mesh.
  14869. */
  14870. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14871. /**
  14872. * Modifies the mesh geometry according to a displacementMap buffer.
  14873. * 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.
  14874. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14875. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14876. * @param heightMapWidth is the width of the buffer image.
  14877. * @param heightMapHeight is the height of the buffer image.
  14878. * @param minHeight is the lower limit of the displacement.
  14879. * @param maxHeight is the upper limit of the displacement.
  14880. * @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.
  14881. * @param uvOffset is an optional vector2 used to offset UV.
  14882. * @param uvScale is an optional vector2 used to scale UV.
  14883. * @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.
  14884. * @returns the Mesh.
  14885. */
  14886. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14887. /**
  14888. * Modify the mesh to get a flat shading rendering.
  14889. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14890. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14891. * @returns current mesh
  14892. */
  14893. convertToFlatShadedMesh(): Mesh;
  14894. /**
  14895. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14896. * In other words, more vertices, no more indices and a single bigger VBO.
  14897. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14898. * @returns current mesh
  14899. */
  14900. convertToUnIndexedMesh(): Mesh;
  14901. /**
  14902. * Inverses facet orientations.
  14903. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14904. * @param flipNormals will also inverts the normals
  14905. * @returns current mesh
  14906. */
  14907. flipFaces(flipNormals?: boolean): Mesh;
  14908. /**
  14909. * Increase the number of facets and hence vertices in a mesh
  14910. * Vertex normals are interpolated from existing vertex normals
  14911. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14912. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14913. */
  14914. increaseVertices(numberPerEdge: number): void;
  14915. /**
  14916. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14917. * This will undo any application of covertToFlatShadedMesh
  14918. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14919. */
  14920. forceSharedVertices(): void;
  14921. /** @hidden */
  14922. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14923. /** @hidden */
  14924. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14925. /**
  14926. * Creates a new InstancedMesh object from the mesh model.
  14927. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14928. * @param name defines the name of the new instance
  14929. * @returns a new InstancedMesh
  14930. */
  14931. createInstance(name: string): InstancedMesh;
  14932. /**
  14933. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14934. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14935. * @returns the current mesh
  14936. */
  14937. synchronizeInstances(): Mesh;
  14938. /**
  14939. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14940. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14941. * This should be used together with the simplification to avoid disappearing triangles.
  14942. * @param successCallback an optional success callback to be called after the optimization finished.
  14943. * @returns the current mesh
  14944. */
  14945. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14946. /**
  14947. * Serialize current mesh
  14948. * @param serializationObject defines the object which will receive the serialization data
  14949. */
  14950. serialize(serializationObject: any): void;
  14951. /** @hidden */
  14952. _syncGeometryWithMorphTargetManager(): void;
  14953. /** @hidden */
  14954. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14955. /**
  14956. * Returns a new Mesh object parsed from the source provided.
  14957. * @param parsedMesh is the source
  14958. * @param scene defines the hosting scene
  14959. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14960. * @returns a new Mesh
  14961. */
  14962. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14963. /**
  14964. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14965. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14966. * @param name defines the name of the mesh to create
  14967. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14968. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14969. * @param closePath creates a seam between the first and the last points of each path of the path array
  14970. * @param offset is taken in account only if the `pathArray` is containing a single path
  14971. * @param scene defines the hosting scene
  14972. * @param updatable defines if the mesh must be flagged as updatable
  14973. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14974. * @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)
  14975. * @returns a new Mesh
  14976. */
  14977. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14978. /**
  14979. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14980. * @param name defines the name of the mesh to create
  14981. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14982. * @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
  14983. * @param scene defines the hosting scene
  14984. * @param updatable defines if the mesh must be flagged as updatable
  14985. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14986. * @returns a new Mesh
  14987. */
  14988. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14989. /**
  14990. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14991. * @param name defines the name of the mesh to create
  14992. * @param size sets the size (float) of each box side (default 1)
  14993. * @param scene defines the hosting scene
  14994. * @param updatable defines if the mesh must be flagged as updatable
  14995. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14996. * @returns a new Mesh
  14997. */
  14998. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14999. /**
  15000. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  15001. * @param name defines the name of the mesh to create
  15002. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  15003. * @param diameter sets the diameter size (float) of the sphere (default 1)
  15004. * @param scene defines the hosting scene
  15005. * @param updatable defines if the mesh must be flagged as updatable
  15006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15007. * @returns a new Mesh
  15008. */
  15009. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15010. /**
  15011. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  15012. * @param name defines the name of the mesh to create
  15013. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  15014. * @param diameter sets the diameter size (float) of the sphere (default 1)
  15015. * @param scene defines the hosting scene
  15016. * @returns a new Mesh
  15017. */
  15018. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  15019. /**
  15020. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  15021. * @param name defines the name of the mesh to create
  15022. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  15023. * @param diameterTop set the top cap diameter (floats, default 1)
  15024. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  15025. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  15026. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  15027. * @param scene defines the hosting scene
  15028. * @param updatable defines if the mesh must be flagged as updatable
  15029. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15030. * @returns a new Mesh
  15031. */
  15032. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  15033. /**
  15034. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  15035. * @param name defines the name of the mesh to create
  15036. * @param diameter sets the diameter size (float) of the torus (default 1)
  15037. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  15038. * @param tessellation sets the number of torus sides (postive integer, default 16)
  15039. * @param scene defines the hosting scene
  15040. * @param updatable defines if the mesh must be flagged as updatable
  15041. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15042. * @returns a new Mesh
  15043. */
  15044. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15045. /**
  15046. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  15047. * @param name defines the name of the mesh to create
  15048. * @param radius sets the global radius size (float) of the torus knot (default 2)
  15049. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  15050. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  15051. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  15052. * @param p the number of windings on X axis (positive integers, default 2)
  15053. * @param q the number of windings on Y axis (positive integers, default 3)
  15054. * @param scene defines the hosting scene
  15055. * @param updatable defines if the mesh must be flagged as updatable
  15056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15057. * @returns a new Mesh
  15058. */
  15059. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15060. /**
  15061. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  15062. * @param name defines the name of the mesh to create
  15063. * @param points is an array successive Vector3
  15064. * @param scene defines the hosting scene
  15065. * @param updatable defines if the mesh must be flagged as updatable
  15066. * @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).
  15067. * @returns a new Mesh
  15068. */
  15069. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  15070. /**
  15071. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  15072. * @param name defines the name of the mesh to create
  15073. * @param points is an array successive Vector3
  15074. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  15075. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  15076. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  15077. * @param scene defines the hosting scene
  15078. * @param updatable defines if the mesh must be flagged as updatable
  15079. * @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)
  15080. * @returns a new Mesh
  15081. */
  15082. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  15083. /**
  15084. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  15085. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  15086. * 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.
  15087. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15088. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15089. * Remember you can only change the shape positions, not their number when updating a polygon.
  15090. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  15091. * @param name defines the name of the mesh to create
  15092. * @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
  15093. * @param scene defines the hosting scene
  15094. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15095. * @param updatable defines if the mesh must be flagged as updatable
  15096. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15097. * @param earcutInjection can be used to inject your own earcut reference
  15098. * @returns a new Mesh
  15099. */
  15100. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15101. /**
  15102. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  15103. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  15104. * @param name defines the name of the mesh to create
  15105. * @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
  15106. * @param depth defines the height of extrusion
  15107. * @param scene defines the hosting scene
  15108. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15109. * @param updatable defines if the mesh must be flagged as updatable
  15110. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15111. * @param earcutInjection can be used to inject your own earcut reference
  15112. * @returns a new Mesh
  15113. */
  15114. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15115. /**
  15116. * Creates an extruded shape mesh.
  15117. * 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
  15118. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15119. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15120. * @param name defines the name of the mesh to create
  15121. * @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
  15122. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15123. * @param scale is the value to scale the shape
  15124. * @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
  15125. * @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
  15126. * @param scene defines the hosting scene
  15127. * @param updatable defines if the mesh must be flagged as updatable
  15128. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15129. * @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)
  15130. * @returns a new Mesh
  15131. */
  15132. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15133. /**
  15134. * Creates an custom extruded shape mesh.
  15135. * The custom extrusion is a parametric shape.
  15136. * It has no predefined shape. Its final shape will depend on the input parameters.
  15137. * Please consider using the same method from the MeshBuilder class instead
  15138. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15139. * @param name defines the name of the mesh to create
  15140. * @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
  15141. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15142. * @param scaleFunction is a custom Javascript function called on each path point
  15143. * @param rotationFunction is a custom Javascript function called on each path point
  15144. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  15145. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  15146. * @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
  15147. * @param scene defines the hosting scene
  15148. * @param updatable defines if the mesh must be flagged as updatable
  15149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15150. * @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)
  15151. * @returns a new Mesh
  15152. */
  15153. 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;
  15154. /**
  15155. * Creates lathe mesh.
  15156. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15157. * Please consider using the same method from the MeshBuilder class instead
  15158. * @param name defines the name of the mesh to create
  15159. * @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
  15160. * @param radius is the radius value of the lathe
  15161. * @param tessellation is the side number of the lathe.
  15162. * @param scene defines the hosting scene
  15163. * @param updatable defines if the mesh must be flagged as updatable
  15164. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15165. * @returns a new Mesh
  15166. */
  15167. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15168. /**
  15169. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  15170. * @param name defines the name of the mesh to create
  15171. * @param size sets the size (float) of both sides of the plane at once (default 1)
  15172. * @param scene defines the hosting scene
  15173. * @param updatable defines if the mesh must be flagged as updatable
  15174. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15175. * @returns a new Mesh
  15176. */
  15177. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15178. /**
  15179. * Creates a ground mesh.
  15180. * Please consider using the same method from the MeshBuilder class instead
  15181. * @param name defines the name of the mesh to create
  15182. * @param width set the width of the ground
  15183. * @param height set the height of the ground
  15184. * @param subdivisions sets the number of subdivisions per side
  15185. * @param scene defines the hosting scene
  15186. * @param updatable defines if the mesh must be flagged as updatable
  15187. * @returns a new Mesh
  15188. */
  15189. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15190. /**
  15191. * Creates a tiled ground mesh.
  15192. * Please consider using the same method from the MeshBuilder class instead
  15193. * @param name defines the name of the mesh to create
  15194. * @param xmin set the ground minimum X coordinate
  15195. * @param zmin set the ground minimum Y coordinate
  15196. * @param xmax set the ground maximum X coordinate
  15197. * @param zmax set the ground maximum Z coordinate
  15198. * @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
  15199. * @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
  15200. * @param scene defines the hosting scene
  15201. * @param updatable defines if the mesh must be flagged as updatable
  15202. * @returns a new Mesh
  15203. */
  15204. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15205. w: number;
  15206. h: number;
  15207. }, precision: {
  15208. w: number;
  15209. h: number;
  15210. }, scene: Scene, updatable?: boolean): Mesh;
  15211. /**
  15212. * Creates a ground mesh from a height map.
  15213. * Please consider using the same method from the MeshBuilder class instead
  15214. * @see http://doc.babylonjs.com/babylon101/height_map
  15215. * @param name defines the name of the mesh to create
  15216. * @param url sets the URL of the height map image resource
  15217. * @param width set the ground width size
  15218. * @param height set the ground height size
  15219. * @param subdivisions sets the number of subdivision per side
  15220. * @param minHeight is the minimum altitude on the ground
  15221. * @param maxHeight is the maximum altitude on the ground
  15222. * @param scene defines the hosting scene
  15223. * @param updatable defines if the mesh must be flagged as updatable
  15224. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  15225. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  15226. * @returns a new Mesh
  15227. */
  15228. 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;
  15229. /**
  15230. * Creates a tube mesh.
  15231. * The tube is a parametric shape.
  15232. * It has no predefined shape. Its final shape will depend on the input parameters.
  15233. * Please consider using the same method from the MeshBuilder class instead
  15234. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15235. * @param name defines the name of the mesh to create
  15236. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  15237. * @param radius sets the tube radius size
  15238. * @param tessellation is the number of sides on the tubular surface
  15239. * @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
  15240. * @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
  15241. * @param scene defines the hosting scene
  15242. * @param updatable defines if the mesh must be flagged as updatable
  15243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15244. * @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)
  15245. * @returns a new Mesh
  15246. */
  15247. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15248. (i: number, distance: number): number;
  15249. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15250. /**
  15251. * Creates a polyhedron mesh.
  15252. * Please consider using the same method from the MeshBuilder class instead.
  15253. * * 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
  15254. * * The parameter `size` (positive float, default 1) sets the polygon size
  15255. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  15256. * * 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`
  15257. * * 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
  15258. * * 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)`)
  15259. * * 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
  15260. * * 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
  15261. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15262. * * If you create a double-sided mesh, you can choose what parts of 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
  15263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15264. * @param name defines the name of the mesh to create
  15265. * @param options defines the options used to create the mesh
  15266. * @param scene defines the hosting scene
  15267. * @returns a new Mesh
  15268. */
  15269. static CreatePolyhedron(name: string, options: {
  15270. type?: number;
  15271. size?: number;
  15272. sizeX?: number;
  15273. sizeY?: number;
  15274. sizeZ?: number;
  15275. custom?: any;
  15276. faceUV?: Vector4[];
  15277. faceColors?: Color4[];
  15278. updatable?: boolean;
  15279. sideOrientation?: number;
  15280. }, scene: Scene): Mesh;
  15281. /**
  15282. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15283. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15284. * * 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`)
  15285. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15286. * * 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
  15287. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15288. * * If you create a double-sided mesh, you can choose what parts of 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
  15289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15290. * @param name defines the name of the mesh
  15291. * @param options defines the options used to create the mesh
  15292. * @param scene defines the hosting scene
  15293. * @returns a new Mesh
  15294. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15295. */
  15296. static CreateIcoSphere(name: string, options: {
  15297. radius?: number;
  15298. flat?: boolean;
  15299. subdivisions?: number;
  15300. sideOrientation?: number;
  15301. updatable?: boolean;
  15302. }, scene: Scene): Mesh;
  15303. /**
  15304. * Creates a decal mesh.
  15305. * Please consider using the same method from the MeshBuilder class instead.
  15306. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15307. * @param name defines the name of the mesh
  15308. * @param sourceMesh defines the mesh receiving the decal
  15309. * @param position sets the position of the decal in world coordinates
  15310. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15311. * @param size sets the decal scaling
  15312. * @param angle sets the angle to rotate the decal
  15313. * @returns a new Mesh
  15314. */
  15315. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15316. /**
  15317. * Prepare internal position array for software CPU skinning
  15318. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15319. */
  15320. setPositionsForCPUSkinning(): Float32Array;
  15321. /**
  15322. * Prepare internal normal array for software CPU skinning
  15323. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15324. */
  15325. setNormalsForCPUSkinning(): Float32Array;
  15326. /**
  15327. * Updates the vertex buffer by applying transformation from the bones
  15328. * @param skeleton defines the skeleton to apply to current mesh
  15329. * @returns the current mesh
  15330. */
  15331. applySkeleton(skeleton: Skeleton): Mesh;
  15332. /**
  15333. * 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
  15334. * @param meshes defines the list of meshes to scan
  15335. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15336. */
  15337. static MinMax(meshes: AbstractMesh[]): {
  15338. min: Vector3;
  15339. max: Vector3;
  15340. };
  15341. /**
  15342. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15343. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15344. * @returns a vector3
  15345. */
  15346. static Center(meshesOrMinMaxVector: {
  15347. min: Vector3;
  15348. max: Vector3;
  15349. } | AbstractMesh[]): Vector3;
  15350. /**
  15351. * Merge the array of meshes into a single mesh for performance reasons.
  15352. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15353. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15354. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15355. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15356. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15357. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15358. * @returns a new mesh
  15359. */
  15360. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15361. /** @hidden */
  15362. addInstance(instance: InstancedMesh): void;
  15363. /** @hidden */
  15364. removeInstance(instance: InstancedMesh): void;
  15365. }
  15366. }
  15367. declare module "babylonjs/Actions/action" {
  15368. import { Observable } from "babylonjs/Misc/observable";
  15369. import { Condition } from "babylonjs/Actions/condition";
  15370. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15371. import { ActionManager } from "babylonjs/Actions/actionManager";
  15372. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15373. /**
  15374. * Interface used to define Action
  15375. */
  15376. export interface IAction {
  15377. /**
  15378. * Trigger for the action
  15379. */
  15380. trigger: number;
  15381. /** Options of the trigger */
  15382. triggerOptions: any;
  15383. /**
  15384. * Gets the trigger parameters
  15385. * @returns the trigger parameters
  15386. */
  15387. getTriggerParameter(): any;
  15388. /**
  15389. * Internal only - executes current action event
  15390. * @hidden
  15391. */
  15392. _executeCurrent(evt?: ActionEvent): void;
  15393. /**
  15394. * Serialize placeholder for child classes
  15395. * @param parent of child
  15396. * @returns the serialized object
  15397. */
  15398. serialize(parent: any): any;
  15399. /**
  15400. * Internal only
  15401. * @hidden
  15402. */
  15403. _prepare(): void;
  15404. /**
  15405. * Internal only - manager for action
  15406. * @hidden
  15407. */
  15408. _actionManager: AbstractActionManager;
  15409. /**
  15410. * Adds action to chain of actions, may be a DoNothingAction
  15411. * @param action defines the next action to execute
  15412. * @returns The action passed in
  15413. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15414. */
  15415. then(action: IAction): IAction;
  15416. }
  15417. /**
  15418. * The action to be carried out following a trigger
  15419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15420. */
  15421. export class Action implements IAction {
  15422. /** the trigger, with or without parameters, for the action */
  15423. triggerOptions: any;
  15424. /**
  15425. * Trigger for the action
  15426. */
  15427. trigger: number;
  15428. /**
  15429. * Internal only - manager for action
  15430. * @hidden
  15431. */
  15432. _actionManager: ActionManager;
  15433. private _nextActiveAction;
  15434. private _child;
  15435. private _condition?;
  15436. private _triggerParameter;
  15437. /**
  15438. * An event triggered prior to action being executed.
  15439. */
  15440. onBeforeExecuteObservable: Observable<Action>;
  15441. /**
  15442. * Creates a new Action
  15443. * @param triggerOptions the trigger, with or without parameters, for the action
  15444. * @param condition an optional determinant of action
  15445. */
  15446. constructor(
  15447. /** the trigger, with or without parameters, for the action */
  15448. triggerOptions: any, condition?: Condition);
  15449. /**
  15450. * Internal only
  15451. * @hidden
  15452. */
  15453. _prepare(): void;
  15454. /**
  15455. * Gets the trigger parameters
  15456. * @returns the trigger parameters
  15457. */
  15458. getTriggerParameter(): any;
  15459. /**
  15460. * Internal only - executes current action event
  15461. * @hidden
  15462. */
  15463. _executeCurrent(evt?: ActionEvent): void;
  15464. /**
  15465. * Execute placeholder for child classes
  15466. * @param evt optional action event
  15467. */
  15468. execute(evt?: ActionEvent): void;
  15469. /**
  15470. * Skips to next active action
  15471. */
  15472. skipToNextActiveAction(): void;
  15473. /**
  15474. * Adds action to chain of actions, may be a DoNothingAction
  15475. * @param action defines the next action to execute
  15476. * @returns The action passed in
  15477. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15478. */
  15479. then(action: Action): Action;
  15480. /**
  15481. * Internal only
  15482. * @hidden
  15483. */
  15484. _getProperty(propertyPath: string): string;
  15485. /**
  15486. * Internal only
  15487. * @hidden
  15488. */
  15489. _getEffectiveTarget(target: any, propertyPath: string): any;
  15490. /**
  15491. * Serialize placeholder for child classes
  15492. * @param parent of child
  15493. * @returns the serialized object
  15494. */
  15495. serialize(parent: any): any;
  15496. /**
  15497. * Internal only called by serialize
  15498. * @hidden
  15499. */
  15500. protected _serialize(serializedAction: any, parent?: any): any;
  15501. /**
  15502. * Internal only
  15503. * @hidden
  15504. */
  15505. static _SerializeValueAsString: (value: any) => string;
  15506. /**
  15507. * Internal only
  15508. * @hidden
  15509. */
  15510. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  15511. name: string;
  15512. targetType: string;
  15513. value: string;
  15514. };
  15515. }
  15516. }
  15517. declare module "babylonjs/Actions/condition" {
  15518. import { ActionManager } from "babylonjs/Actions/actionManager";
  15519. /**
  15520. * A Condition applied to an Action
  15521. */
  15522. export class Condition {
  15523. /**
  15524. * Internal only - manager for action
  15525. * @hidden
  15526. */
  15527. _actionManager: ActionManager;
  15528. /**
  15529. * Internal only
  15530. * @hidden
  15531. */
  15532. _evaluationId: number;
  15533. /**
  15534. * Internal only
  15535. * @hidden
  15536. */
  15537. _currentResult: boolean;
  15538. /**
  15539. * Creates a new Condition
  15540. * @param actionManager the manager of the action the condition is applied to
  15541. */
  15542. constructor(actionManager: ActionManager);
  15543. /**
  15544. * Check if the current condition is valid
  15545. * @returns a boolean
  15546. */
  15547. isValid(): boolean;
  15548. /**
  15549. * Internal only
  15550. * @hidden
  15551. */
  15552. _getProperty(propertyPath: string): string;
  15553. /**
  15554. * Internal only
  15555. * @hidden
  15556. */
  15557. _getEffectiveTarget(target: any, propertyPath: string): any;
  15558. /**
  15559. * Serialize placeholder for child classes
  15560. * @returns the serialized object
  15561. */
  15562. serialize(): any;
  15563. /**
  15564. * Internal only
  15565. * @hidden
  15566. */
  15567. protected _serialize(serializedCondition: any): any;
  15568. }
  15569. /**
  15570. * Defines specific conditional operators as extensions of Condition
  15571. */
  15572. export class ValueCondition extends Condition {
  15573. /** path to specify the property of the target the conditional operator uses */
  15574. propertyPath: string;
  15575. /** the value compared by the conditional operator against the current value of the property */
  15576. value: any;
  15577. /** the conditional operator, default ValueCondition.IsEqual */
  15578. operator: number;
  15579. /**
  15580. * Internal only
  15581. * @hidden
  15582. */
  15583. private static _IsEqual;
  15584. /**
  15585. * Internal only
  15586. * @hidden
  15587. */
  15588. private static _IsDifferent;
  15589. /**
  15590. * Internal only
  15591. * @hidden
  15592. */
  15593. private static _IsGreater;
  15594. /**
  15595. * Internal only
  15596. * @hidden
  15597. */
  15598. private static _IsLesser;
  15599. /**
  15600. * returns the number for IsEqual
  15601. */
  15602. static readonly IsEqual: number;
  15603. /**
  15604. * Returns the number for IsDifferent
  15605. */
  15606. static readonly IsDifferent: number;
  15607. /**
  15608. * Returns the number for IsGreater
  15609. */
  15610. static readonly IsGreater: number;
  15611. /**
  15612. * Returns the number for IsLesser
  15613. */
  15614. static readonly IsLesser: number;
  15615. /**
  15616. * Internal only The action manager for the condition
  15617. * @hidden
  15618. */
  15619. _actionManager: ActionManager;
  15620. /**
  15621. * Internal only
  15622. * @hidden
  15623. */
  15624. private _target;
  15625. /**
  15626. * Internal only
  15627. * @hidden
  15628. */
  15629. private _effectiveTarget;
  15630. /**
  15631. * Internal only
  15632. * @hidden
  15633. */
  15634. private _property;
  15635. /**
  15636. * Creates a new ValueCondition
  15637. * @param actionManager manager for the action the condition applies to
  15638. * @param target for the action
  15639. * @param propertyPath path to specify the property of the target the conditional operator uses
  15640. * @param value the value compared by the conditional operator against the current value of the property
  15641. * @param operator the conditional operator, default ValueCondition.IsEqual
  15642. */
  15643. constructor(actionManager: ActionManager, target: any,
  15644. /** path to specify the property of the target the conditional operator uses */
  15645. propertyPath: string,
  15646. /** the value compared by the conditional operator against the current value of the property */
  15647. value: any,
  15648. /** the conditional operator, default ValueCondition.IsEqual */
  15649. operator?: number);
  15650. /**
  15651. * Compares the given value with the property value for the specified conditional operator
  15652. * @returns the result of the comparison
  15653. */
  15654. isValid(): boolean;
  15655. /**
  15656. * Serialize the ValueCondition into a JSON compatible object
  15657. * @returns serialization object
  15658. */
  15659. serialize(): any;
  15660. /**
  15661. * Gets the name of the conditional operator for the ValueCondition
  15662. * @param operator the conditional operator
  15663. * @returns the name
  15664. */
  15665. static GetOperatorName(operator: number): string;
  15666. }
  15667. /**
  15668. * Defines a predicate condition as an extension of Condition
  15669. */
  15670. export class PredicateCondition extends Condition {
  15671. /** defines the predicate function used to validate the condition */
  15672. predicate: () => boolean;
  15673. /**
  15674. * Internal only - manager for action
  15675. * @hidden
  15676. */
  15677. _actionManager: ActionManager;
  15678. /**
  15679. * Creates a new PredicateCondition
  15680. * @param actionManager manager for the action the condition applies to
  15681. * @param predicate defines the predicate function used to validate the condition
  15682. */
  15683. constructor(actionManager: ActionManager,
  15684. /** defines the predicate function used to validate the condition */
  15685. predicate: () => boolean);
  15686. /**
  15687. * @returns the validity of the predicate condition
  15688. */
  15689. isValid(): boolean;
  15690. }
  15691. /**
  15692. * Defines a state condition as an extension of Condition
  15693. */
  15694. export class StateCondition extends Condition {
  15695. /** Value to compare with target state */
  15696. value: string;
  15697. /**
  15698. * Internal only - manager for action
  15699. * @hidden
  15700. */
  15701. _actionManager: ActionManager;
  15702. /**
  15703. * Internal only
  15704. * @hidden
  15705. */
  15706. private _target;
  15707. /**
  15708. * Creates a new StateCondition
  15709. * @param actionManager manager for the action the condition applies to
  15710. * @param target of the condition
  15711. * @param value to compare with target state
  15712. */
  15713. constructor(actionManager: ActionManager, target: any,
  15714. /** Value to compare with target state */
  15715. value: string);
  15716. /**
  15717. * Gets a boolean indicating if the current condition is met
  15718. * @returns the validity of the state
  15719. */
  15720. isValid(): boolean;
  15721. /**
  15722. * Serialize the StateCondition into a JSON compatible object
  15723. * @returns serialization object
  15724. */
  15725. serialize(): any;
  15726. }
  15727. }
  15728. declare module "babylonjs/Actions/directActions" {
  15729. import { Action } from "babylonjs/Actions/action";
  15730. import { Condition } from "babylonjs/Actions/condition";
  15731. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15732. /**
  15733. * This defines an action responsible to toggle a boolean once triggered.
  15734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15735. */
  15736. export class SwitchBooleanAction extends Action {
  15737. /**
  15738. * The path to the boolean property in the target object
  15739. */
  15740. propertyPath: string;
  15741. private _target;
  15742. private _effectiveTarget;
  15743. private _property;
  15744. /**
  15745. * Instantiate the action
  15746. * @param triggerOptions defines the trigger options
  15747. * @param target defines the object containing the boolean
  15748. * @param propertyPath defines the path to the boolean property in the target object
  15749. * @param condition defines the trigger related conditions
  15750. */
  15751. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15752. /** @hidden */
  15753. _prepare(): void;
  15754. /**
  15755. * Execute the action toggle the boolean value.
  15756. */
  15757. execute(): void;
  15758. /**
  15759. * Serializes the actions and its related information.
  15760. * @param parent defines the object to serialize in
  15761. * @returns the serialized object
  15762. */
  15763. serialize(parent: any): any;
  15764. }
  15765. /**
  15766. * This defines an action responsible to set a the state field of the target
  15767. * to a desired value once triggered.
  15768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15769. */
  15770. export class SetStateAction extends Action {
  15771. /**
  15772. * The value to store in the state field.
  15773. */
  15774. value: string;
  15775. private _target;
  15776. /**
  15777. * Instantiate the action
  15778. * @param triggerOptions defines the trigger options
  15779. * @param target defines the object containing the state property
  15780. * @param value defines the value to store in the state field
  15781. * @param condition defines the trigger related conditions
  15782. */
  15783. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15784. /**
  15785. * Execute the action and store the value on the target state property.
  15786. */
  15787. execute(): void;
  15788. /**
  15789. * Serializes the actions and its related information.
  15790. * @param parent defines the object to serialize in
  15791. * @returns the serialized object
  15792. */
  15793. serialize(parent: any): any;
  15794. }
  15795. /**
  15796. * This defines an action responsible to set a property of the target
  15797. * to a desired value once triggered.
  15798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15799. */
  15800. export class SetValueAction extends Action {
  15801. /**
  15802. * The path of the property to set in the target.
  15803. */
  15804. propertyPath: string;
  15805. /**
  15806. * The value to set in the property
  15807. */
  15808. value: any;
  15809. private _target;
  15810. private _effectiveTarget;
  15811. private _property;
  15812. /**
  15813. * Instantiate the action
  15814. * @param triggerOptions defines the trigger options
  15815. * @param target defines the object containing the property
  15816. * @param propertyPath defines the path of the property to set in the target
  15817. * @param value defines the value to set in the property
  15818. * @param condition defines the trigger related conditions
  15819. */
  15820. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15821. /** @hidden */
  15822. _prepare(): void;
  15823. /**
  15824. * Execute the action and set the targetted property to the desired value.
  15825. */
  15826. execute(): void;
  15827. /**
  15828. * Serializes the actions and its related information.
  15829. * @param parent defines the object to serialize in
  15830. * @returns the serialized object
  15831. */
  15832. serialize(parent: any): any;
  15833. }
  15834. /**
  15835. * This defines an action responsible to increment the target value
  15836. * to a desired value once triggered.
  15837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15838. */
  15839. export class IncrementValueAction extends Action {
  15840. /**
  15841. * The path of the property to increment in the target.
  15842. */
  15843. propertyPath: string;
  15844. /**
  15845. * The value we should increment the property by.
  15846. */
  15847. value: any;
  15848. private _target;
  15849. private _effectiveTarget;
  15850. private _property;
  15851. /**
  15852. * Instantiate the action
  15853. * @param triggerOptions defines the trigger options
  15854. * @param target defines the object containing the property
  15855. * @param propertyPath defines the path of the property to increment in the target
  15856. * @param value defines the value value we should increment the property by
  15857. * @param condition defines the trigger related conditions
  15858. */
  15859. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15860. /** @hidden */
  15861. _prepare(): void;
  15862. /**
  15863. * Execute the action and increment the target of the value amount.
  15864. */
  15865. execute(): void;
  15866. /**
  15867. * Serializes the actions and its related information.
  15868. * @param parent defines the object to serialize in
  15869. * @returns the serialized object
  15870. */
  15871. serialize(parent: any): any;
  15872. }
  15873. /**
  15874. * This defines an action responsible to start an animation once triggered.
  15875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15876. */
  15877. export class PlayAnimationAction extends Action {
  15878. /**
  15879. * Where the animation should start (animation frame)
  15880. */
  15881. from: number;
  15882. /**
  15883. * Where the animation should stop (animation frame)
  15884. */
  15885. to: number;
  15886. /**
  15887. * Define if the animation should loop or stop after the first play.
  15888. */
  15889. loop?: boolean;
  15890. private _target;
  15891. /**
  15892. * Instantiate the action
  15893. * @param triggerOptions defines the trigger options
  15894. * @param target defines the target animation or animation name
  15895. * @param from defines from where the animation should start (animation frame)
  15896. * @param end defines where the animation should stop (animation frame)
  15897. * @param loop defines if the animation should loop or stop after the first play
  15898. * @param condition defines the trigger related conditions
  15899. */
  15900. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15901. /** @hidden */
  15902. _prepare(): void;
  15903. /**
  15904. * Execute the action and play the animation.
  15905. */
  15906. execute(): void;
  15907. /**
  15908. * Serializes the actions and its related information.
  15909. * @param parent defines the object to serialize in
  15910. * @returns the serialized object
  15911. */
  15912. serialize(parent: any): any;
  15913. }
  15914. /**
  15915. * This defines an action responsible to stop an animation once triggered.
  15916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15917. */
  15918. export class StopAnimationAction extends Action {
  15919. private _target;
  15920. /**
  15921. * Instantiate the action
  15922. * @param triggerOptions defines the trigger options
  15923. * @param target defines the target animation or animation name
  15924. * @param condition defines the trigger related conditions
  15925. */
  15926. constructor(triggerOptions: any, target: any, condition?: Condition);
  15927. /** @hidden */
  15928. _prepare(): void;
  15929. /**
  15930. * Execute the action and stop the animation.
  15931. */
  15932. execute(): void;
  15933. /**
  15934. * Serializes the actions and its related information.
  15935. * @param parent defines the object to serialize in
  15936. * @returns the serialized object
  15937. */
  15938. serialize(parent: any): any;
  15939. }
  15940. /**
  15941. * This defines an action responsible that does nothing once triggered.
  15942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15943. */
  15944. export class DoNothingAction extends Action {
  15945. /**
  15946. * Instantiate the action
  15947. * @param triggerOptions defines the trigger options
  15948. * @param condition defines the trigger related conditions
  15949. */
  15950. constructor(triggerOptions?: any, condition?: Condition);
  15951. /**
  15952. * Execute the action and do nothing.
  15953. */
  15954. execute(): void;
  15955. /**
  15956. * Serializes the actions and its related information.
  15957. * @param parent defines the object to serialize in
  15958. * @returns the serialized object
  15959. */
  15960. serialize(parent: any): any;
  15961. }
  15962. /**
  15963. * This defines an action responsible to trigger several actions once triggered.
  15964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15965. */
  15966. export class CombineAction extends Action {
  15967. /**
  15968. * The list of aggregated animations to run.
  15969. */
  15970. children: Action[];
  15971. /**
  15972. * Instantiate the action
  15973. * @param triggerOptions defines the trigger options
  15974. * @param children defines the list of aggregated animations to run
  15975. * @param condition defines the trigger related conditions
  15976. */
  15977. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15978. /** @hidden */
  15979. _prepare(): void;
  15980. /**
  15981. * Execute the action and executes all the aggregated actions.
  15982. */
  15983. execute(evt: ActionEvent): void;
  15984. /**
  15985. * Serializes the actions and its related information.
  15986. * @param parent defines the object to serialize in
  15987. * @returns the serialized object
  15988. */
  15989. serialize(parent: any): any;
  15990. }
  15991. /**
  15992. * This defines an action responsible to run code (external event) once triggered.
  15993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15994. */
  15995. export class ExecuteCodeAction extends Action {
  15996. /**
  15997. * The callback function to run.
  15998. */
  15999. func: (evt: ActionEvent) => void;
  16000. /**
  16001. * Instantiate the action
  16002. * @param triggerOptions defines the trigger options
  16003. * @param func defines the callback function to run
  16004. * @param condition defines the trigger related conditions
  16005. */
  16006. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  16007. /**
  16008. * Execute the action and run the attached code.
  16009. */
  16010. execute(evt: ActionEvent): void;
  16011. }
  16012. /**
  16013. * This defines an action responsible to set the parent property of the target once triggered.
  16014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16015. */
  16016. export class SetParentAction extends Action {
  16017. private _parent;
  16018. private _target;
  16019. /**
  16020. * Instantiate the action
  16021. * @param triggerOptions defines the trigger options
  16022. * @param target defines the target containing the parent property
  16023. * @param parent defines from where the animation should start (animation frame)
  16024. * @param condition defines the trigger related conditions
  16025. */
  16026. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  16027. /** @hidden */
  16028. _prepare(): void;
  16029. /**
  16030. * Execute the action and set the parent property.
  16031. */
  16032. execute(): void;
  16033. /**
  16034. * Serializes the actions and its related information.
  16035. * @param parent defines the object to serialize in
  16036. * @returns the serialized object
  16037. */
  16038. serialize(parent: any): any;
  16039. }
  16040. }
  16041. declare module "babylonjs/Actions/actionManager" {
  16042. import { Nullable } from "babylonjs/types";
  16043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16044. import { Scene } from "babylonjs/scene";
  16045. import { IAction } from "babylonjs/Actions/action";
  16046. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  16047. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  16048. /**
  16049. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  16050. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  16051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16052. */
  16053. export class ActionManager extends AbstractActionManager {
  16054. /**
  16055. * Nothing
  16056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16057. */
  16058. static readonly NothingTrigger: number;
  16059. /**
  16060. * On pick
  16061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16062. */
  16063. static readonly OnPickTrigger: number;
  16064. /**
  16065. * On left pick
  16066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16067. */
  16068. static readonly OnLeftPickTrigger: number;
  16069. /**
  16070. * On right pick
  16071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16072. */
  16073. static readonly OnRightPickTrigger: number;
  16074. /**
  16075. * On center pick
  16076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16077. */
  16078. static readonly OnCenterPickTrigger: number;
  16079. /**
  16080. * On pick down
  16081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16082. */
  16083. static readonly OnPickDownTrigger: number;
  16084. /**
  16085. * On double pick
  16086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16087. */
  16088. static readonly OnDoublePickTrigger: number;
  16089. /**
  16090. * On pick up
  16091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16092. */
  16093. static readonly OnPickUpTrigger: number;
  16094. /**
  16095. * On pick out.
  16096. * This trigger will only be raised if you also declared a OnPickDown
  16097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16098. */
  16099. static readonly OnPickOutTrigger: number;
  16100. /**
  16101. * On long press
  16102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16103. */
  16104. static readonly OnLongPressTrigger: number;
  16105. /**
  16106. * On pointer over
  16107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16108. */
  16109. static readonly OnPointerOverTrigger: number;
  16110. /**
  16111. * On pointer out
  16112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16113. */
  16114. static readonly OnPointerOutTrigger: number;
  16115. /**
  16116. * On every frame
  16117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16118. */
  16119. static readonly OnEveryFrameTrigger: number;
  16120. /**
  16121. * On intersection enter
  16122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16123. */
  16124. static readonly OnIntersectionEnterTrigger: number;
  16125. /**
  16126. * On intersection exit
  16127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16128. */
  16129. static readonly OnIntersectionExitTrigger: number;
  16130. /**
  16131. * On key down
  16132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16133. */
  16134. static readonly OnKeyDownTrigger: number;
  16135. /**
  16136. * On key up
  16137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16138. */
  16139. static readonly OnKeyUpTrigger: number;
  16140. private _scene;
  16141. /**
  16142. * Creates a new action manager
  16143. * @param scene defines the hosting scene
  16144. */
  16145. constructor(scene: Scene);
  16146. /**
  16147. * Releases all associated resources
  16148. */
  16149. dispose(): void;
  16150. /**
  16151. * Gets hosting scene
  16152. * @returns the hosting scene
  16153. */
  16154. getScene(): Scene;
  16155. /**
  16156. * Does this action manager handles actions of any of the given triggers
  16157. * @param triggers defines the triggers to be tested
  16158. * @return a boolean indicating whether one (or more) of the triggers is handled
  16159. */
  16160. hasSpecificTriggers(triggers: number[]): boolean;
  16161. /**
  16162. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  16163. * speed.
  16164. * @param triggerA defines the trigger to be tested
  16165. * @param triggerB defines the trigger to be tested
  16166. * @return a boolean indicating whether one (or more) of the triggers is handled
  16167. */
  16168. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  16169. /**
  16170. * Does this action manager handles actions of a given trigger
  16171. * @param trigger defines the trigger to be tested
  16172. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  16173. * @return whether the trigger is handled
  16174. */
  16175. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  16176. /**
  16177. * Does this action manager has pointer triggers
  16178. */
  16179. readonly hasPointerTriggers: boolean;
  16180. /**
  16181. * Does this action manager has pick triggers
  16182. */
  16183. readonly hasPickTriggers: boolean;
  16184. /**
  16185. * Registers an action to this action manager
  16186. * @param action defines the action to be registered
  16187. * @return the action amended (prepared) after registration
  16188. */
  16189. registerAction(action: IAction): Nullable<IAction>;
  16190. /**
  16191. * Unregisters an action to this action manager
  16192. * @param action defines the action to be unregistered
  16193. * @return a boolean indicating whether the action has been unregistered
  16194. */
  16195. unregisterAction(action: IAction): Boolean;
  16196. /**
  16197. * Process a specific trigger
  16198. * @param trigger defines the trigger to process
  16199. * @param evt defines the event details to be processed
  16200. */
  16201. processTrigger(trigger: number, evt?: IActionEvent): void;
  16202. /** @hidden */
  16203. _getEffectiveTarget(target: any, propertyPath: string): any;
  16204. /** @hidden */
  16205. _getProperty(propertyPath: string): string;
  16206. /**
  16207. * Serialize this manager to a JSON object
  16208. * @param name defines the property name to store this manager
  16209. * @returns a JSON representation of this manager
  16210. */
  16211. serialize(name: string): any;
  16212. /**
  16213. * Creates a new ActionManager from a JSON data
  16214. * @param parsedActions defines the JSON data to read from
  16215. * @param object defines the hosting mesh
  16216. * @param scene defines the hosting scene
  16217. */
  16218. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  16219. /**
  16220. * Get a trigger name by index
  16221. * @param trigger defines the trigger index
  16222. * @returns a trigger name
  16223. */
  16224. static GetTriggerName(trigger: number): string;
  16225. }
  16226. }
  16227. declare module "babylonjs/Culling/ray" {
  16228. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  16229. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  16230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16231. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16232. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  16233. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  16234. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  16235. /**
  16236. * Class representing a ray with position and direction
  16237. */
  16238. export class Ray {
  16239. /** origin point */
  16240. origin: Vector3;
  16241. /** direction */
  16242. direction: Vector3;
  16243. /** length of the ray */
  16244. length: number;
  16245. private static readonly TmpVector3;
  16246. private _tmpRay;
  16247. /**
  16248. * Creates a new ray
  16249. * @param origin origin point
  16250. * @param direction direction
  16251. * @param length length of the ray
  16252. */
  16253. constructor(
  16254. /** origin point */
  16255. origin: Vector3,
  16256. /** direction */
  16257. direction: Vector3,
  16258. /** length of the ray */
  16259. length?: number);
  16260. /**
  16261. * Checks if the ray intersects a box
  16262. * @param minimum bound of the box
  16263. * @param maximum bound of the box
  16264. * @param intersectionTreshold extra extend to be added to the box in all direction
  16265. * @returns if the box was hit
  16266. */
  16267. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  16268. /**
  16269. * Checks if the ray intersects a box
  16270. * @param box the bounding box to check
  16271. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  16272. * @returns if the box was hit
  16273. */
  16274. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  16275. /**
  16276. * If the ray hits a sphere
  16277. * @param sphere the bounding sphere to check
  16278. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  16279. * @returns true if it hits the sphere
  16280. */
  16281. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  16282. /**
  16283. * If the ray hits a triange
  16284. * @param vertex0 triangle vertex
  16285. * @param vertex1 triangle vertex
  16286. * @param vertex2 triangle vertex
  16287. * @returns intersection information if hit
  16288. */
  16289. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  16290. /**
  16291. * Checks if ray intersects a plane
  16292. * @param plane the plane to check
  16293. * @returns the distance away it was hit
  16294. */
  16295. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16296. /**
  16297. * Checks if ray intersects a mesh
  16298. * @param mesh the mesh to check
  16299. * @param fastCheck if only the bounding box should checked
  16300. * @returns picking info of the intersecton
  16301. */
  16302. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16303. /**
  16304. * Checks if ray intersects a mesh
  16305. * @param meshes the meshes to check
  16306. * @param fastCheck if only the bounding box should checked
  16307. * @param results array to store result in
  16308. * @returns Array of picking infos
  16309. */
  16310. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16311. private _comparePickingInfo;
  16312. private static smallnum;
  16313. private static rayl;
  16314. /**
  16315. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16316. * @param sega the first point of the segment to test the intersection against
  16317. * @param segb the second point of the segment to test the intersection against
  16318. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16319. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16320. */
  16321. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16322. /**
  16323. * Update the ray from viewport position
  16324. * @param x position
  16325. * @param y y position
  16326. * @param viewportWidth viewport width
  16327. * @param viewportHeight viewport height
  16328. * @param world world matrix
  16329. * @param view view matrix
  16330. * @param projection projection matrix
  16331. * @returns this ray updated
  16332. */
  16333. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16334. /**
  16335. * Creates a ray with origin and direction of 0,0,0
  16336. * @returns the new ray
  16337. */
  16338. static Zero(): Ray;
  16339. /**
  16340. * Creates a new ray from screen space and viewport
  16341. * @param x position
  16342. * @param y y position
  16343. * @param viewportWidth viewport width
  16344. * @param viewportHeight viewport height
  16345. * @param world world matrix
  16346. * @param view view matrix
  16347. * @param projection projection matrix
  16348. * @returns new ray
  16349. */
  16350. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16351. /**
  16352. * 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
  16353. * transformed to the given world matrix.
  16354. * @param origin The origin point
  16355. * @param end The end point
  16356. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16357. * @returns the new ray
  16358. */
  16359. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16360. /**
  16361. * Transforms a ray by a matrix
  16362. * @param ray ray to transform
  16363. * @param matrix matrix to apply
  16364. * @returns the resulting new ray
  16365. */
  16366. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16367. /**
  16368. * Transforms a ray by a matrix
  16369. * @param ray ray to transform
  16370. * @param matrix matrix to apply
  16371. * @param result ray to store result in
  16372. */
  16373. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16374. /**
  16375. * Unproject a ray from screen space to object space
  16376. * @param sourceX defines the screen space x coordinate to use
  16377. * @param sourceY defines the screen space y coordinate to use
  16378. * @param viewportWidth defines the current width of the viewport
  16379. * @param viewportHeight defines the current height of the viewport
  16380. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16381. * @param view defines the view matrix to use
  16382. * @param projection defines the projection matrix to use
  16383. */
  16384. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16385. }
  16386. /**
  16387. * Type used to define predicate used to select faces when a mesh intersection is detected
  16388. */
  16389. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16390. module "babylonjs/scene" {
  16391. interface Scene {
  16392. /** @hidden */
  16393. _tempPickingRay: Nullable<Ray>;
  16394. /** @hidden */
  16395. _cachedRayForTransform: Ray;
  16396. /** @hidden */
  16397. _pickWithRayInverseMatrix: Matrix;
  16398. /** @hidden */
  16399. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16400. /** @hidden */
  16401. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16402. }
  16403. }
  16404. }
  16405. declare module "babylonjs/Sprites/spriteSceneComponent" {
  16406. import { Nullable } from "babylonjs/types";
  16407. import { Observable } from "babylonjs/Misc/observable";
  16408. import { Scene } from "babylonjs/scene";
  16409. import { Sprite } from "babylonjs/Sprites/sprite";
  16410. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16411. import { Ray } from "babylonjs/Culling/ray";
  16412. import { Camera } from "babylonjs/Cameras/camera";
  16413. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16414. import { ISceneComponent } from "babylonjs/sceneComponent";
  16415. module "babylonjs/scene" {
  16416. interface Scene {
  16417. /** @hidden */
  16418. _pointerOverSprite: Nullable<Sprite>;
  16419. /** @hidden */
  16420. _pickedDownSprite: Nullable<Sprite>;
  16421. /** @hidden */
  16422. _tempSpritePickingRay: Nullable<Ray>;
  16423. /**
  16424. * All of the sprite managers added to this scene
  16425. * @see http://doc.babylonjs.com/babylon101/sprites
  16426. */
  16427. spriteManagers: Array<ISpriteManager>;
  16428. /**
  16429. * An event triggered when sprites rendering is about to start
  16430. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16431. */
  16432. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16433. /**
  16434. * An event triggered when sprites rendering is done
  16435. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16436. */
  16437. onAfterSpritesRenderingObservable: Observable<Scene>;
  16438. /** @hidden */
  16439. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16440. /** Launch a ray to try to pick a sprite in the scene
  16441. * @param x position on screen
  16442. * @param y position on screen
  16443. * @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
  16444. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16445. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16446. * @returns a PickingInfo
  16447. */
  16448. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16449. /** Use the given ray to pick a sprite in the scene
  16450. * @param ray The ray (in world space) to use to pick meshes
  16451. * @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
  16452. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16453. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16454. * @returns a PickingInfo
  16455. */
  16456. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16457. /**
  16458. * Force the sprite under the pointer
  16459. * @param sprite defines the sprite to use
  16460. */
  16461. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16462. /**
  16463. * Gets the sprite under the pointer
  16464. * @returns a Sprite or null if no sprite is under the pointer
  16465. */
  16466. getPointerOverSprite(): Nullable<Sprite>;
  16467. }
  16468. }
  16469. /**
  16470. * Defines the sprite scene component responsible to manage sprites
  16471. * in a given scene.
  16472. */
  16473. export class SpriteSceneComponent implements ISceneComponent {
  16474. /**
  16475. * The component name helpfull to identify the component in the list of scene components.
  16476. */
  16477. readonly name: string;
  16478. /**
  16479. * The scene the component belongs to.
  16480. */
  16481. scene: Scene;
  16482. /** @hidden */
  16483. private _spritePredicate;
  16484. /**
  16485. * Creates a new instance of the component for the given scene
  16486. * @param scene Defines the scene to register the component in
  16487. */
  16488. constructor(scene: Scene);
  16489. /**
  16490. * Registers the component in a given scene
  16491. */
  16492. register(): void;
  16493. /**
  16494. * Rebuilds the elements related to this component in case of
  16495. * context lost for instance.
  16496. */
  16497. rebuild(): void;
  16498. /**
  16499. * Disposes the component and the associated ressources.
  16500. */
  16501. dispose(): void;
  16502. private _pickSpriteButKeepRay;
  16503. private _pointerMove;
  16504. private _pointerDown;
  16505. private _pointerUp;
  16506. }
  16507. }
  16508. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  16509. /** @hidden */
  16510. export var fogFragmentDeclaration: {
  16511. name: string;
  16512. shader: string;
  16513. };
  16514. }
  16515. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  16516. /** @hidden */
  16517. export var fogFragment: {
  16518. name: string;
  16519. shader: string;
  16520. };
  16521. }
  16522. declare module "babylonjs/Shaders/sprites.fragment" {
  16523. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  16524. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  16525. /** @hidden */
  16526. export var spritesPixelShader: {
  16527. name: string;
  16528. shader: string;
  16529. };
  16530. }
  16531. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  16532. /** @hidden */
  16533. export var fogVertexDeclaration: {
  16534. name: string;
  16535. shader: string;
  16536. };
  16537. }
  16538. declare module "babylonjs/Shaders/sprites.vertex" {
  16539. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  16540. /** @hidden */
  16541. export var spritesVertexShader: {
  16542. name: string;
  16543. shader: string;
  16544. };
  16545. }
  16546. declare module "babylonjs/Sprites/spriteManager" {
  16547. import { IDisposable, Scene } from "babylonjs/scene";
  16548. import { Nullable } from "babylonjs/types";
  16549. import { Observable } from "babylonjs/Misc/observable";
  16550. import { Sprite } from "babylonjs/Sprites/sprite";
  16551. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16552. import { Camera } from "babylonjs/Cameras/camera";
  16553. import { Texture } from "babylonjs/Materials/Textures/texture";
  16554. import "babylonjs/Shaders/sprites.fragment";
  16555. import "babylonjs/Shaders/sprites.vertex";
  16556. import { Ray } from "babylonjs/Culling/ray";
  16557. /**
  16558. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16559. */
  16560. export interface ISpriteManager extends IDisposable {
  16561. /**
  16562. * Restricts the camera to viewing objects with the same layerMask.
  16563. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16564. */
  16565. layerMask: number;
  16566. /**
  16567. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16568. */
  16569. isPickable: boolean;
  16570. /**
  16571. * Specifies the rendering group id for this mesh (0 by default)
  16572. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16573. */
  16574. renderingGroupId: number;
  16575. /**
  16576. * Defines the list of sprites managed by the manager.
  16577. */
  16578. sprites: Array<Sprite>;
  16579. /**
  16580. * Tests the intersection of a sprite with a specific ray.
  16581. * @param ray The ray we are sending to test the collision
  16582. * @param camera The camera space we are sending rays in
  16583. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16584. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16585. * @returns picking info or null.
  16586. */
  16587. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16588. /**
  16589. * Renders the list of sprites on screen.
  16590. */
  16591. render(): void;
  16592. }
  16593. /**
  16594. * Class used to manage multiple sprites on the same spritesheet
  16595. * @see http://doc.babylonjs.com/babylon101/sprites
  16596. */
  16597. export class SpriteManager implements ISpriteManager {
  16598. /** defines the manager's name */
  16599. name: string;
  16600. /** Gets the list of sprites */
  16601. sprites: Sprite[];
  16602. /** Gets or sets the rendering group id (0 by default) */
  16603. renderingGroupId: number;
  16604. /** Gets or sets camera layer mask */
  16605. layerMask: number;
  16606. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16607. fogEnabled: boolean;
  16608. /** Gets or sets a boolean indicating if the sprites are pickable */
  16609. isPickable: boolean;
  16610. /** Defines the default width of a cell in the spritesheet */
  16611. cellWidth: number;
  16612. /** Defines the default height of a cell in the spritesheet */
  16613. cellHeight: number;
  16614. /**
  16615. * An event triggered when the manager is disposed.
  16616. */
  16617. onDisposeObservable: Observable<SpriteManager>;
  16618. private _onDisposeObserver;
  16619. /**
  16620. * Callback called when the manager is disposed
  16621. */
  16622. onDispose: () => void;
  16623. private _capacity;
  16624. private _spriteTexture;
  16625. private _epsilon;
  16626. private _scene;
  16627. private _vertexData;
  16628. private _buffer;
  16629. private _vertexBuffers;
  16630. private _indexBuffer;
  16631. private _effectBase;
  16632. private _effectFog;
  16633. /**
  16634. * Gets or sets the spritesheet texture
  16635. */
  16636. texture: Texture;
  16637. /**
  16638. * Creates a new sprite manager
  16639. * @param name defines the manager's name
  16640. * @param imgUrl defines the sprite sheet url
  16641. * @param capacity defines the maximum allowed number of sprites
  16642. * @param cellSize defines the size of a sprite cell
  16643. * @param scene defines the hosting scene
  16644. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16645. * @param samplingMode defines the smapling mode to use with spritesheet
  16646. */
  16647. constructor(
  16648. /** defines the manager's name */
  16649. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16650. private _appendSpriteVertex;
  16651. /**
  16652. * Intersects the sprites with a ray
  16653. * @param ray defines the ray to intersect with
  16654. * @param camera defines the current active camera
  16655. * @param predicate defines a predicate used to select candidate sprites
  16656. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16657. * @returns null if no hit or a PickingInfo
  16658. */
  16659. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16660. /**
  16661. * Render all child sprites
  16662. */
  16663. render(): void;
  16664. /**
  16665. * Release associated resources
  16666. */
  16667. dispose(): void;
  16668. }
  16669. }
  16670. declare module "babylonjs/Sprites/sprite" {
  16671. import { Vector3, Color4 } from "babylonjs/Maths/math";
  16672. import { Nullable } from "babylonjs/types";
  16673. import { ActionManager } from "babylonjs/Actions/actionManager";
  16674. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16675. /**
  16676. * Class used to represent a sprite
  16677. * @see http://doc.babylonjs.com/babylon101/sprites
  16678. */
  16679. export class Sprite {
  16680. /** defines the name */
  16681. name: string;
  16682. /** Gets or sets the current world position */
  16683. position: Vector3;
  16684. /** Gets or sets the main color */
  16685. color: Color4;
  16686. /** Gets or sets the width */
  16687. width: number;
  16688. /** Gets or sets the height */
  16689. height: number;
  16690. /** Gets or sets rotation angle */
  16691. angle: number;
  16692. /** Gets or sets the cell index in the sprite sheet */
  16693. cellIndex: number;
  16694. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16695. invertU: number;
  16696. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16697. invertV: number;
  16698. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16699. disposeWhenFinishedAnimating: boolean;
  16700. /** Gets the list of attached animations */
  16701. animations: Animation[];
  16702. /** Gets or sets a boolean indicating if the sprite can be picked */
  16703. isPickable: boolean;
  16704. /**
  16705. * Gets or sets the associated action manager
  16706. */
  16707. actionManager: Nullable<ActionManager>;
  16708. private _animationStarted;
  16709. private _loopAnimation;
  16710. private _fromIndex;
  16711. private _toIndex;
  16712. private _delay;
  16713. private _direction;
  16714. private _manager;
  16715. private _time;
  16716. private _onAnimationEnd;
  16717. /**
  16718. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16719. */
  16720. isVisible: boolean;
  16721. /**
  16722. * Gets or sets the sprite size
  16723. */
  16724. size: number;
  16725. /**
  16726. * Creates a new Sprite
  16727. * @param name defines the name
  16728. * @param manager defines the manager
  16729. */
  16730. constructor(
  16731. /** defines the name */
  16732. name: string, manager: ISpriteManager);
  16733. /**
  16734. * Starts an animation
  16735. * @param from defines the initial key
  16736. * @param to defines the end key
  16737. * @param loop defines if the animation must loop
  16738. * @param delay defines the start delay (in ms)
  16739. * @param onAnimationEnd defines a callback to call when animation ends
  16740. */
  16741. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16742. /** Stops current animation (if any) */
  16743. stopAnimation(): void;
  16744. /** @hidden */
  16745. _animate(deltaTime: number): void;
  16746. /** Release associated resources */
  16747. dispose(): void;
  16748. }
  16749. }
  16750. declare module "babylonjs/Collisions/pickingInfo" {
  16751. import { Nullable } from "babylonjs/types";
  16752. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  16753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16754. import { Sprite } from "babylonjs/Sprites/sprite";
  16755. import { Ray } from "babylonjs/Culling/ray";
  16756. /**
  16757. * Information about the result of picking within a scene
  16758. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16759. */
  16760. export class PickingInfo {
  16761. /** @hidden */
  16762. _pickingUnavailable: boolean;
  16763. /**
  16764. * If the pick collided with an object
  16765. */
  16766. hit: boolean;
  16767. /**
  16768. * Distance away where the pick collided
  16769. */
  16770. distance: number;
  16771. /**
  16772. * The location of pick collision
  16773. */
  16774. pickedPoint: Nullable<Vector3>;
  16775. /**
  16776. * The mesh corresponding the the pick collision
  16777. */
  16778. pickedMesh: Nullable<AbstractMesh>;
  16779. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16780. bu: number;
  16781. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16782. bv: number;
  16783. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16784. faceId: number;
  16785. /** Id of the the submesh that was picked */
  16786. subMeshId: number;
  16787. /** If a sprite was picked, this will be the sprite the pick collided with */
  16788. pickedSprite: Nullable<Sprite>;
  16789. /**
  16790. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16791. */
  16792. originMesh: Nullable<AbstractMesh>;
  16793. /**
  16794. * The ray that was used to perform the picking.
  16795. */
  16796. ray: Nullable<Ray>;
  16797. /**
  16798. * Gets the normal correspodning to the face the pick collided with
  16799. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16800. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16801. * @returns The normal correspodning to the face the pick collided with
  16802. */
  16803. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16804. /**
  16805. * Gets the texture coordinates of where the pick occured
  16806. * @returns the vector containing the coordnates of the texture
  16807. */
  16808. getTextureCoordinates(): Nullable<Vector2>;
  16809. }
  16810. }
  16811. declare module "babylonjs/Events/pointerEvents" {
  16812. import { Nullable } from "babylonjs/types";
  16813. import { Vector2 } from "babylonjs/Maths/math";
  16814. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16815. import { Ray } from "babylonjs/Culling/ray";
  16816. /**
  16817. * Gather the list of pointer event types as constants.
  16818. */
  16819. export class PointerEventTypes {
  16820. /**
  16821. * 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.
  16822. */
  16823. static readonly POINTERDOWN: number;
  16824. /**
  16825. * The pointerup event is fired when a pointer is no longer active.
  16826. */
  16827. static readonly POINTERUP: number;
  16828. /**
  16829. * The pointermove event is fired when a pointer changes coordinates.
  16830. */
  16831. static readonly POINTERMOVE: number;
  16832. /**
  16833. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16834. */
  16835. static readonly POINTERWHEEL: number;
  16836. /**
  16837. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16838. */
  16839. static readonly POINTERPICK: number;
  16840. /**
  16841. * The pointertap event is fired when a the object has been touched and released without drag.
  16842. */
  16843. static readonly POINTERTAP: number;
  16844. /**
  16845. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16846. */
  16847. static readonly POINTERDOUBLETAP: number;
  16848. }
  16849. /**
  16850. * Base class of pointer info types.
  16851. */
  16852. export class PointerInfoBase {
  16853. /**
  16854. * Defines the type of event (PointerEventTypes)
  16855. */
  16856. type: number;
  16857. /**
  16858. * Defines the related dom event
  16859. */
  16860. event: PointerEvent | MouseWheelEvent;
  16861. /**
  16862. * Instantiates the base class of pointers info.
  16863. * @param type Defines the type of event (PointerEventTypes)
  16864. * @param event Defines the related dom event
  16865. */
  16866. constructor(
  16867. /**
  16868. * Defines the type of event (PointerEventTypes)
  16869. */
  16870. type: number,
  16871. /**
  16872. * Defines the related dom event
  16873. */
  16874. event: PointerEvent | MouseWheelEvent);
  16875. }
  16876. /**
  16877. * This class is used to store pointer related info for the onPrePointerObservable event.
  16878. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16879. */
  16880. export class PointerInfoPre extends PointerInfoBase {
  16881. /**
  16882. * Ray from a pointer if availible (eg. 6dof controller)
  16883. */
  16884. ray: Nullable<Ray>;
  16885. /**
  16886. * Defines the local position of the pointer on the canvas.
  16887. */
  16888. localPosition: Vector2;
  16889. /**
  16890. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16891. */
  16892. skipOnPointerObservable: boolean;
  16893. /**
  16894. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16895. * @param type Defines the type of event (PointerEventTypes)
  16896. * @param event Defines the related dom event
  16897. * @param localX Defines the local x coordinates of the pointer when the event occured
  16898. * @param localY Defines the local y coordinates of the pointer when the event occured
  16899. */
  16900. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16901. }
  16902. /**
  16903. * This type contains all the data related to a pointer event in Babylon.js.
  16904. * 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.
  16905. */
  16906. export class PointerInfo extends PointerInfoBase {
  16907. /**
  16908. * Defines the picking info associated to the info (if any)\
  16909. */
  16910. pickInfo: Nullable<PickingInfo>;
  16911. /**
  16912. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16913. * @param type Defines the type of event (PointerEventTypes)
  16914. * @param event Defines the related dom event
  16915. * @param pickInfo Defines the picking info associated to the info (if any)\
  16916. */
  16917. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16918. /**
  16919. * Defines the picking info associated to the info (if any)\
  16920. */
  16921. pickInfo: Nullable<PickingInfo>);
  16922. }
  16923. /**
  16924. * Data relating to a touch event on the screen.
  16925. */
  16926. export interface PointerTouch {
  16927. /**
  16928. * X coordinate of touch.
  16929. */
  16930. x: number;
  16931. /**
  16932. * Y coordinate of touch.
  16933. */
  16934. y: number;
  16935. /**
  16936. * Id of touch. Unique for each finger.
  16937. */
  16938. pointerId: number;
  16939. /**
  16940. * Event type passed from DOM.
  16941. */
  16942. type: any;
  16943. }
  16944. }
  16945. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  16946. import { Observable } from "babylonjs/Misc/observable";
  16947. import { Nullable } from "babylonjs/types";
  16948. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16949. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16950. /**
  16951. * Manage the mouse inputs to control the movement of a free camera.
  16952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16953. */
  16954. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16955. /**
  16956. * Define if touch is enabled in the mouse input
  16957. */
  16958. touchEnabled: boolean;
  16959. /**
  16960. * Defines the camera the input is attached to.
  16961. */
  16962. camera: FreeCamera;
  16963. /**
  16964. * Defines the buttons associated with the input to handle camera move.
  16965. */
  16966. buttons: number[];
  16967. /**
  16968. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16969. */
  16970. angularSensibility: number;
  16971. private _pointerInput;
  16972. private _onMouseMove;
  16973. private _observer;
  16974. private previousPosition;
  16975. /**
  16976. * Observable for when a pointer move event occurs containing the move offset
  16977. */
  16978. onPointerMovedObservable: Observable<{
  16979. offsetX: number;
  16980. offsetY: number;
  16981. }>;
  16982. /**
  16983. * @hidden
  16984. * If the camera should be rotated automatically based on pointer movement
  16985. */
  16986. _allowCameraRotation: boolean;
  16987. /**
  16988. * Manage the mouse inputs to control the movement of a free camera.
  16989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16990. * @param touchEnabled Defines if touch is enabled or not
  16991. */
  16992. constructor(
  16993. /**
  16994. * Define if touch is enabled in the mouse input
  16995. */
  16996. touchEnabled?: boolean);
  16997. /**
  16998. * Attach the input controls to a specific dom element to get the input from.
  16999. * @param element Defines the element the controls should be listened from
  17000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17001. */
  17002. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17003. /**
  17004. * Called on JS contextmenu event.
  17005. * Override this method to provide functionality.
  17006. */
  17007. protected onContextMenu(evt: PointerEvent): void;
  17008. /**
  17009. * Detach the current controls from the specified dom element.
  17010. * @param element Defines the element to stop listening the inputs from
  17011. */
  17012. detachControl(element: Nullable<HTMLElement>): void;
  17013. /**
  17014. * Gets the class name of the current intput.
  17015. * @returns the class name
  17016. */
  17017. getClassName(): string;
  17018. /**
  17019. * Get the friendly name associated with the input class.
  17020. * @returns the input friendly name
  17021. */
  17022. getSimpleName(): string;
  17023. }
  17024. }
  17025. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  17026. import { Nullable } from "babylonjs/types";
  17027. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  17028. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17029. /**
  17030. * Manage the touch inputs to control the movement of a free camera.
  17031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17032. */
  17033. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  17034. /**
  17035. * Defines the camera the input is attached to.
  17036. */
  17037. camera: FreeCamera;
  17038. /**
  17039. * Defines the touch sensibility for rotation.
  17040. * The higher the faster.
  17041. */
  17042. touchAngularSensibility: number;
  17043. /**
  17044. * Defines the touch sensibility for move.
  17045. * The higher the faster.
  17046. */
  17047. touchMoveSensibility: number;
  17048. private _offsetX;
  17049. private _offsetY;
  17050. private _pointerPressed;
  17051. private _pointerInput;
  17052. private _observer;
  17053. private _onLostFocus;
  17054. /**
  17055. * Attach the input controls to a specific dom element to get the input from.
  17056. * @param element Defines the element the controls should be listened from
  17057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17058. */
  17059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17060. /**
  17061. * Detach the current controls from the specified dom element.
  17062. * @param element Defines the element to stop listening the inputs from
  17063. */
  17064. detachControl(element: Nullable<HTMLElement>): void;
  17065. /**
  17066. * Update the current camera state depending on the inputs that have been used this frame.
  17067. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  17068. */
  17069. checkInputs(): void;
  17070. /**
  17071. * Gets the class name of the current intput.
  17072. * @returns the class name
  17073. */
  17074. getClassName(): string;
  17075. /**
  17076. * Get the friendly name associated with the input class.
  17077. * @returns the input friendly name
  17078. */
  17079. getSimpleName(): string;
  17080. }
  17081. }
  17082. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  17083. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17084. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  17085. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  17086. import { Nullable } from "babylonjs/types";
  17087. /**
  17088. * Default Inputs manager for the FreeCamera.
  17089. * It groups all the default supported inputs for ease of use.
  17090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17091. */
  17092. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  17093. /**
  17094. * @hidden
  17095. */
  17096. _mouseInput: Nullable<FreeCameraMouseInput>;
  17097. /**
  17098. * Instantiates a new FreeCameraInputsManager.
  17099. * @param camera Defines the camera the inputs belong to
  17100. */
  17101. constructor(camera: FreeCamera);
  17102. /**
  17103. * Add keyboard input support to the input manager.
  17104. * @returns the current input manager
  17105. */
  17106. addKeyboard(): FreeCameraInputsManager;
  17107. /**
  17108. * Add mouse input support to the input manager.
  17109. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  17110. * @returns the current input manager
  17111. */
  17112. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  17113. /**
  17114. * Removes the mouse input support from the manager
  17115. * @returns the current input manager
  17116. */
  17117. removeMouse(): FreeCameraInputsManager;
  17118. /**
  17119. * Add touch input support to the input manager.
  17120. * @returns the current input manager
  17121. */
  17122. addTouch(): FreeCameraInputsManager;
  17123. /**
  17124. * Remove all attached input methods from a camera
  17125. */
  17126. clear(): void;
  17127. }
  17128. }
  17129. declare module "babylonjs/Cameras/freeCamera" {
  17130. import { Vector3 } from "babylonjs/Maths/math";
  17131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17132. import { Scene } from "babylonjs/scene";
  17133. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17134. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  17135. /**
  17136. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17137. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  17138. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17139. */
  17140. export class FreeCamera extends TargetCamera {
  17141. /**
  17142. * Define the collision ellipsoid of the camera.
  17143. * This is helpful to simulate a camera body like the player body around the camera
  17144. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  17145. */
  17146. ellipsoid: Vector3;
  17147. /**
  17148. * Define an offset for the position of the ellipsoid around the camera.
  17149. * This can be helpful to determine the center of the body near the gravity center of the body
  17150. * instead of its head.
  17151. */
  17152. ellipsoidOffset: Vector3;
  17153. /**
  17154. * Enable or disable collisions of the camera with the rest of the scene objects.
  17155. */
  17156. checkCollisions: boolean;
  17157. /**
  17158. * Enable or disable gravity on the camera.
  17159. */
  17160. applyGravity: boolean;
  17161. /**
  17162. * Define the input manager associated to the camera.
  17163. */
  17164. inputs: FreeCameraInputsManager;
  17165. /**
  17166. * Gets the input sensibility for a mouse input. (default is 2000.0)
  17167. * Higher values reduce sensitivity.
  17168. */
  17169. /**
  17170. * Sets the input sensibility for a mouse input. (default is 2000.0)
  17171. * Higher values reduce sensitivity.
  17172. */
  17173. angularSensibility: number;
  17174. /**
  17175. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  17176. */
  17177. keysUp: number[];
  17178. /**
  17179. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  17180. */
  17181. keysDown: number[];
  17182. /**
  17183. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  17184. */
  17185. keysLeft: number[];
  17186. /**
  17187. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  17188. */
  17189. keysRight: number[];
  17190. /**
  17191. * Event raised when the camera collide with a mesh in the scene.
  17192. */
  17193. onCollide: (collidedMesh: AbstractMesh) => void;
  17194. private _collider;
  17195. private _needMoveForGravity;
  17196. private _oldPosition;
  17197. private _diffPosition;
  17198. private _newPosition;
  17199. /** @hidden */
  17200. _localDirection: Vector3;
  17201. /** @hidden */
  17202. _transformedDirection: Vector3;
  17203. /**
  17204. * Instantiates a Free Camera.
  17205. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17206. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  17207. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17208. * @param name Define the name of the camera in the scene
  17209. * @param position Define the start position of the camera in the scene
  17210. * @param scene Define the scene the camera belongs to
  17211. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  17212. */
  17213. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  17214. /**
  17215. * Attached controls to the current camera.
  17216. * @param element Defines the element the controls should be listened from
  17217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17218. */
  17219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17220. /**
  17221. * Detach the current controls from the camera.
  17222. * The camera will stop reacting to inputs.
  17223. * @param element Defines the element to stop listening the inputs from
  17224. */
  17225. detachControl(element: HTMLElement): void;
  17226. private _collisionMask;
  17227. /**
  17228. * Define a collision mask to limit the list of object the camera can collide with
  17229. */
  17230. collisionMask: number;
  17231. /** @hidden */
  17232. _collideWithWorld(displacement: Vector3): void;
  17233. private _onCollisionPositionChange;
  17234. /** @hidden */
  17235. _checkInputs(): void;
  17236. /** @hidden */
  17237. _decideIfNeedsToMove(): boolean;
  17238. /** @hidden */
  17239. _updatePosition(): void;
  17240. /**
  17241. * Destroy the camera and release the current resources hold by it.
  17242. */
  17243. dispose(): void;
  17244. /**
  17245. * Gets the current object class name.
  17246. * @return the class name
  17247. */
  17248. getClassName(): string;
  17249. }
  17250. }
  17251. declare module "babylonjs/Gamepads/gamepad" {
  17252. import { Observable } from "babylonjs/Misc/observable";
  17253. /**
  17254. * Represents a gamepad control stick position
  17255. */
  17256. export class StickValues {
  17257. /**
  17258. * The x component of the control stick
  17259. */
  17260. x: number;
  17261. /**
  17262. * The y component of the control stick
  17263. */
  17264. y: number;
  17265. /**
  17266. * Initializes the gamepad x and y control stick values
  17267. * @param x The x component of the gamepad control stick value
  17268. * @param y The y component of the gamepad control stick value
  17269. */
  17270. constructor(
  17271. /**
  17272. * The x component of the control stick
  17273. */
  17274. x: number,
  17275. /**
  17276. * The y component of the control stick
  17277. */
  17278. y: number);
  17279. }
  17280. /**
  17281. * An interface which manages callbacks for gamepad button changes
  17282. */
  17283. export interface GamepadButtonChanges {
  17284. /**
  17285. * Called when a gamepad has been changed
  17286. */
  17287. changed: boolean;
  17288. /**
  17289. * Called when a gamepad press event has been triggered
  17290. */
  17291. pressChanged: boolean;
  17292. /**
  17293. * Called when a touch event has been triggered
  17294. */
  17295. touchChanged: boolean;
  17296. /**
  17297. * Called when a value has changed
  17298. */
  17299. valueChanged: boolean;
  17300. }
  17301. /**
  17302. * Represents a gamepad
  17303. */
  17304. export class Gamepad {
  17305. /**
  17306. * The id of the gamepad
  17307. */
  17308. id: string;
  17309. /**
  17310. * The index of the gamepad
  17311. */
  17312. index: number;
  17313. /**
  17314. * The browser gamepad
  17315. */
  17316. browserGamepad: any;
  17317. /**
  17318. * Specifies what type of gamepad this represents
  17319. */
  17320. type: number;
  17321. private _leftStick;
  17322. private _rightStick;
  17323. /** @hidden */
  17324. _isConnected: boolean;
  17325. private _leftStickAxisX;
  17326. private _leftStickAxisY;
  17327. private _rightStickAxisX;
  17328. private _rightStickAxisY;
  17329. /**
  17330. * Triggered when the left control stick has been changed
  17331. */
  17332. private _onleftstickchanged;
  17333. /**
  17334. * Triggered when the right control stick has been changed
  17335. */
  17336. private _onrightstickchanged;
  17337. /**
  17338. * Represents a gamepad controller
  17339. */
  17340. static GAMEPAD: number;
  17341. /**
  17342. * Represents a generic controller
  17343. */
  17344. static GENERIC: number;
  17345. /**
  17346. * Represents an XBox controller
  17347. */
  17348. static XBOX: number;
  17349. /**
  17350. * Represents a pose-enabled controller
  17351. */
  17352. static POSE_ENABLED: number;
  17353. /**
  17354. * Specifies whether the left control stick should be Y-inverted
  17355. */
  17356. protected _invertLeftStickY: boolean;
  17357. /**
  17358. * Specifies if the gamepad has been connected
  17359. */
  17360. readonly isConnected: boolean;
  17361. /**
  17362. * Initializes the gamepad
  17363. * @param id The id of the gamepad
  17364. * @param index The index of the gamepad
  17365. * @param browserGamepad The browser gamepad
  17366. * @param leftStickX The x component of the left joystick
  17367. * @param leftStickY The y component of the left joystick
  17368. * @param rightStickX The x component of the right joystick
  17369. * @param rightStickY The y component of the right joystick
  17370. */
  17371. constructor(
  17372. /**
  17373. * The id of the gamepad
  17374. */
  17375. id: string,
  17376. /**
  17377. * The index of the gamepad
  17378. */
  17379. index: number,
  17380. /**
  17381. * The browser gamepad
  17382. */
  17383. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17384. /**
  17385. * Callback triggered when the left joystick has changed
  17386. * @param callback
  17387. */
  17388. onleftstickchanged(callback: (values: StickValues) => void): void;
  17389. /**
  17390. * Callback triggered when the right joystick has changed
  17391. * @param callback
  17392. */
  17393. onrightstickchanged(callback: (values: StickValues) => void): void;
  17394. /**
  17395. * Gets the left joystick
  17396. */
  17397. /**
  17398. * Sets the left joystick values
  17399. */
  17400. leftStick: StickValues;
  17401. /**
  17402. * Gets the right joystick
  17403. */
  17404. /**
  17405. * Sets the right joystick value
  17406. */
  17407. rightStick: StickValues;
  17408. /**
  17409. * Updates the gamepad joystick positions
  17410. */
  17411. update(): void;
  17412. /**
  17413. * Disposes the gamepad
  17414. */
  17415. dispose(): void;
  17416. }
  17417. /**
  17418. * Represents a generic gamepad
  17419. */
  17420. export class GenericPad extends Gamepad {
  17421. private _buttons;
  17422. private _onbuttondown;
  17423. private _onbuttonup;
  17424. /**
  17425. * Observable triggered when a button has been pressed
  17426. */
  17427. onButtonDownObservable: Observable<number>;
  17428. /**
  17429. * Observable triggered when a button has been released
  17430. */
  17431. onButtonUpObservable: Observable<number>;
  17432. /**
  17433. * Callback triggered when a button has been pressed
  17434. * @param callback Called when a button has been pressed
  17435. */
  17436. onbuttondown(callback: (buttonPressed: number) => void): void;
  17437. /**
  17438. * Callback triggered when a button has been released
  17439. * @param callback Called when a button has been released
  17440. */
  17441. onbuttonup(callback: (buttonReleased: number) => void): void;
  17442. /**
  17443. * Initializes the generic gamepad
  17444. * @param id The id of the generic gamepad
  17445. * @param index The index of the generic gamepad
  17446. * @param browserGamepad The browser gamepad
  17447. */
  17448. constructor(id: string, index: number, browserGamepad: any);
  17449. private _setButtonValue;
  17450. /**
  17451. * Updates the generic gamepad
  17452. */
  17453. update(): void;
  17454. /**
  17455. * Disposes the generic gamepad
  17456. */
  17457. dispose(): void;
  17458. }
  17459. }
  17460. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  17461. import { Observable } from "babylonjs/Misc/observable";
  17462. import { Nullable } from "babylonjs/types";
  17463. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17464. import { TransformNode } from "babylonjs/Meshes/transformNode";
  17465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17466. import { Ray } from "babylonjs/Culling/ray";
  17467. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  17468. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  17469. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17470. /**
  17471. * Defines the types of pose enabled controllers that are supported
  17472. */
  17473. export enum PoseEnabledControllerType {
  17474. /**
  17475. * HTC Vive
  17476. */
  17477. VIVE = 0,
  17478. /**
  17479. * Oculus Rift
  17480. */
  17481. OCULUS = 1,
  17482. /**
  17483. * Windows mixed reality
  17484. */
  17485. WINDOWS = 2,
  17486. /**
  17487. * Samsung gear VR
  17488. */
  17489. GEAR_VR = 3,
  17490. /**
  17491. * Google Daydream
  17492. */
  17493. DAYDREAM = 4,
  17494. /**
  17495. * Generic
  17496. */
  17497. GENERIC = 5
  17498. }
  17499. /**
  17500. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17501. */
  17502. export interface MutableGamepadButton {
  17503. /**
  17504. * Value of the button/trigger
  17505. */
  17506. value: number;
  17507. /**
  17508. * If the button/trigger is currently touched
  17509. */
  17510. touched: boolean;
  17511. /**
  17512. * If the button/trigger is currently pressed
  17513. */
  17514. pressed: boolean;
  17515. }
  17516. /**
  17517. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17518. * @hidden
  17519. */
  17520. export interface ExtendedGamepadButton extends GamepadButton {
  17521. /**
  17522. * If the button/trigger is currently pressed
  17523. */
  17524. readonly pressed: boolean;
  17525. /**
  17526. * If the button/trigger is currently touched
  17527. */
  17528. readonly touched: boolean;
  17529. /**
  17530. * Value of the button/trigger
  17531. */
  17532. readonly value: number;
  17533. }
  17534. /** @hidden */
  17535. export interface _GamePadFactory {
  17536. /**
  17537. * Returns wether or not the current gamepad can be created for this type of controller.
  17538. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17539. * @returns true if it can be created, otherwise false
  17540. */
  17541. canCreate(gamepadInfo: any): boolean;
  17542. /**
  17543. * Creates a new instance of the Gamepad.
  17544. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17545. * @returns the new gamepad instance
  17546. */
  17547. create(gamepadInfo: any): Gamepad;
  17548. }
  17549. /**
  17550. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17551. */
  17552. export class PoseEnabledControllerHelper {
  17553. /** @hidden */
  17554. static _ControllerFactories: _GamePadFactory[];
  17555. /** @hidden */
  17556. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17557. /**
  17558. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17559. * @param vrGamepad the gamepad to initialized
  17560. * @returns a vr controller of the type the gamepad identified as
  17561. */
  17562. static InitiateController(vrGamepad: any): Gamepad;
  17563. }
  17564. /**
  17565. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17566. */
  17567. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17568. private _deviceRoomPosition;
  17569. private _deviceRoomRotationQuaternion;
  17570. /**
  17571. * The device position in babylon space
  17572. */
  17573. devicePosition: Vector3;
  17574. /**
  17575. * The device rotation in babylon space
  17576. */
  17577. deviceRotationQuaternion: Quaternion;
  17578. /**
  17579. * The scale factor of the device in babylon space
  17580. */
  17581. deviceScaleFactor: number;
  17582. /**
  17583. * (Likely devicePosition should be used instead) The device position in its room space
  17584. */
  17585. position: Vector3;
  17586. /**
  17587. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17588. */
  17589. rotationQuaternion: Quaternion;
  17590. /**
  17591. * The type of controller (Eg. Windows mixed reality)
  17592. */
  17593. controllerType: PoseEnabledControllerType;
  17594. protected _calculatedPosition: Vector3;
  17595. private _calculatedRotation;
  17596. /**
  17597. * The raw pose from the device
  17598. */
  17599. rawPose: DevicePose;
  17600. private _trackPosition;
  17601. private _maxRotationDistFromHeadset;
  17602. private _draggedRoomRotation;
  17603. /**
  17604. * @hidden
  17605. */
  17606. _disableTrackPosition(fixedPosition: Vector3): void;
  17607. /**
  17608. * Internal, the mesh attached to the controller
  17609. * @hidden
  17610. */
  17611. _mesh: Nullable<AbstractMesh>;
  17612. private _poseControlledCamera;
  17613. private _leftHandSystemQuaternion;
  17614. /**
  17615. * Internal, matrix used to convert room space to babylon space
  17616. * @hidden
  17617. */
  17618. _deviceToWorld: Matrix;
  17619. /**
  17620. * Node to be used when casting a ray from the controller
  17621. * @hidden
  17622. */
  17623. _pointingPoseNode: Nullable<TransformNode>;
  17624. /**
  17625. * Name of the child mesh that can be used to cast a ray from the controller
  17626. */
  17627. static readonly POINTING_POSE: string;
  17628. /**
  17629. * Creates a new PoseEnabledController from a gamepad
  17630. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17631. */
  17632. constructor(browserGamepad: any);
  17633. private _workingMatrix;
  17634. /**
  17635. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17636. */
  17637. update(): void;
  17638. /**
  17639. * Updates only the pose device and mesh without doing any button event checking
  17640. */
  17641. protected _updatePoseAndMesh(): void;
  17642. /**
  17643. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17644. * @param poseData raw pose fromthe device
  17645. */
  17646. updateFromDevice(poseData: DevicePose): void;
  17647. /**
  17648. * @hidden
  17649. */
  17650. _meshAttachedObservable: Observable<AbstractMesh>;
  17651. /**
  17652. * Attaches a mesh to the controller
  17653. * @param mesh the mesh to be attached
  17654. */
  17655. attachToMesh(mesh: AbstractMesh): void;
  17656. /**
  17657. * Attaches the controllers mesh to a camera
  17658. * @param camera the camera the mesh should be attached to
  17659. */
  17660. attachToPoseControlledCamera(camera: TargetCamera): void;
  17661. /**
  17662. * Disposes of the controller
  17663. */
  17664. dispose(): void;
  17665. /**
  17666. * The mesh that is attached to the controller
  17667. */
  17668. readonly mesh: Nullable<AbstractMesh>;
  17669. /**
  17670. * Gets the ray of the controller in the direction the controller is pointing
  17671. * @param length the length the resulting ray should be
  17672. * @returns a ray in the direction the controller is pointing
  17673. */
  17674. getForwardRay(length?: number): Ray;
  17675. }
  17676. }
  17677. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  17678. import { Observable } from "babylonjs/Misc/observable";
  17679. import { Scene } from "babylonjs/scene";
  17680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17681. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  17682. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  17683. /**
  17684. * Defines the WebVRController object that represents controllers tracked in 3D space
  17685. */
  17686. export abstract class WebVRController extends PoseEnabledController {
  17687. /**
  17688. * Internal, the default controller model for the controller
  17689. */
  17690. protected _defaultModel: AbstractMesh;
  17691. /**
  17692. * Fired when the trigger state has changed
  17693. */
  17694. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17695. /**
  17696. * Fired when the main button state has changed
  17697. */
  17698. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17699. /**
  17700. * Fired when the secondary button state has changed
  17701. */
  17702. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17703. /**
  17704. * Fired when the pad state has changed
  17705. */
  17706. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17707. /**
  17708. * Fired when controllers stick values have changed
  17709. */
  17710. onPadValuesChangedObservable: Observable<StickValues>;
  17711. /**
  17712. * Array of button availible on the controller
  17713. */
  17714. protected _buttons: Array<MutableGamepadButton>;
  17715. private _onButtonStateChange;
  17716. /**
  17717. * Fired when a controller button's state has changed
  17718. * @param callback the callback containing the button that was modified
  17719. */
  17720. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17721. /**
  17722. * X and Y axis corresponding to the controllers joystick
  17723. */
  17724. pad: StickValues;
  17725. /**
  17726. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17727. */
  17728. hand: string;
  17729. /**
  17730. * The default controller model for the controller
  17731. */
  17732. readonly defaultModel: AbstractMesh;
  17733. /**
  17734. * Creates a new WebVRController from a gamepad
  17735. * @param vrGamepad the gamepad that the WebVRController should be created from
  17736. */
  17737. constructor(vrGamepad: any);
  17738. /**
  17739. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17740. */
  17741. update(): void;
  17742. /**
  17743. * Function to be called when a button is modified
  17744. */
  17745. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17746. /**
  17747. * Loads a mesh and attaches it to the controller
  17748. * @param scene the scene the mesh should be added to
  17749. * @param meshLoaded callback for when the mesh has been loaded
  17750. */
  17751. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17752. private _setButtonValue;
  17753. private _changes;
  17754. private _checkChanges;
  17755. /**
  17756. * Disposes of th webVRCOntroller
  17757. */
  17758. dispose(): void;
  17759. }
  17760. }
  17761. declare module "babylonjs/Lights/hemisphericLight" {
  17762. import { Nullable } from "babylonjs/types";
  17763. import { Scene } from "babylonjs/scene";
  17764. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  17765. import { Effect } from "babylonjs/Materials/effect";
  17766. import { Light } from "babylonjs/Lights/light";
  17767. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17768. /**
  17769. * The HemisphericLight simulates the ambient environment light,
  17770. * so the passed direction is the light reflection direction, not the incoming direction.
  17771. */
  17772. export class HemisphericLight extends Light {
  17773. /**
  17774. * The groundColor is the light in the opposite direction to the one specified during creation.
  17775. * 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.
  17776. */
  17777. groundColor: Color3;
  17778. /**
  17779. * The light reflection direction, not the incoming direction.
  17780. */
  17781. direction: Vector3;
  17782. /**
  17783. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17784. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17785. * The HemisphericLight can't cast shadows.
  17786. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17787. * @param name The friendly name of the light
  17788. * @param direction The direction of the light reflection
  17789. * @param scene The scene the light belongs to
  17790. */
  17791. constructor(name: string, direction: Vector3, scene: Scene);
  17792. protected _buildUniformLayout(): void;
  17793. /**
  17794. * Returns the string "HemisphericLight".
  17795. * @return The class name
  17796. */
  17797. getClassName(): string;
  17798. /**
  17799. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17800. * Returns the updated direction.
  17801. * @param target The target the direction should point to
  17802. * @return The computed direction
  17803. */
  17804. setDirectionToTarget(target: Vector3): Vector3;
  17805. /**
  17806. * Returns the shadow generator associated to the light.
  17807. * @returns Always null for hemispheric lights because it does not support shadows.
  17808. */
  17809. getShadowGenerator(): Nullable<IShadowGenerator>;
  17810. /**
  17811. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17812. * @param effect The effect to update
  17813. * @param lightIndex The index of the light in the effect to update
  17814. * @returns The hemispheric light
  17815. */
  17816. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17817. /**
  17818. * Computes the world matrix of the node
  17819. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17820. * @param useWasUpdatedFlag defines a reserved property
  17821. * @returns the world matrix
  17822. */
  17823. computeWorldMatrix(): Matrix;
  17824. /**
  17825. * Returns the integer 3.
  17826. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17827. */
  17828. getTypeID(): number;
  17829. /**
  17830. * Prepares the list of defines specific to the light type.
  17831. * @param defines the list of defines
  17832. * @param lightIndex defines the index of the light for the effect
  17833. */
  17834. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17835. }
  17836. }
  17837. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  17838. /** @hidden */
  17839. export var vrMultiviewToSingleviewPixelShader: {
  17840. name: string;
  17841. shader: string;
  17842. };
  17843. }
  17844. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  17845. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17846. import { Scene } from "babylonjs/scene";
  17847. /**
  17848. * Renders to multiple views with a single draw call
  17849. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17850. */
  17851. export class MultiviewRenderTarget extends RenderTargetTexture {
  17852. /**
  17853. * Creates a multiview render target
  17854. * @param scene scene used with the render target
  17855. * @param size the size of the render target (used for each view)
  17856. */
  17857. constructor(scene: Scene, size?: number | {
  17858. width: number;
  17859. height: number;
  17860. } | {
  17861. ratio: number;
  17862. });
  17863. /**
  17864. * @hidden
  17865. * @param faceIndex the face index, if its a cube texture
  17866. */
  17867. _bindFrameBuffer(faceIndex?: number): void;
  17868. /**
  17869. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17870. * @returns the view count
  17871. */
  17872. getViewCount(): number;
  17873. }
  17874. }
  17875. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  17876. import { Camera } from "babylonjs/Cameras/camera";
  17877. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17878. import { Nullable } from "babylonjs/types";
  17879. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17880. import { Matrix } from "babylonjs/Maths/math";
  17881. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17882. module "babylonjs/Engines/engine" {
  17883. interface Engine {
  17884. /**
  17885. * Creates a new multiview render target
  17886. * @param width defines the width of the texture
  17887. * @param height defines the height of the texture
  17888. * @returns the created multiview texture
  17889. */
  17890. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17891. /**
  17892. * Binds a multiview framebuffer to be drawn to
  17893. * @param multiviewTexture texture to bind
  17894. */
  17895. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17896. }
  17897. }
  17898. module "babylonjs/Cameras/camera" {
  17899. interface Camera {
  17900. /**
  17901. * @hidden
  17902. * 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)
  17903. */
  17904. _useMultiviewToSingleView: boolean;
  17905. /**
  17906. * @hidden
  17907. * 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)
  17908. */
  17909. _multiviewTexture: Nullable<RenderTargetTexture>;
  17910. /**
  17911. * @hidden
  17912. * ensures the multiview texture of the camera exists and has the specified width/height
  17913. * @param width height to set on the multiview texture
  17914. * @param height width to set on the multiview texture
  17915. */
  17916. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17917. }
  17918. }
  17919. module "babylonjs/scene" {
  17920. interface Scene {
  17921. /** @hidden */
  17922. _transformMatrixR: Matrix;
  17923. /** @hidden */
  17924. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17925. /** @hidden */
  17926. _createMultiviewUbo(): void;
  17927. /** @hidden */
  17928. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17929. /** @hidden */
  17930. _renderMultiviewToSingleView(camera: Camera): void;
  17931. }
  17932. }
  17933. }
  17934. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  17935. import { Camera } from "babylonjs/Cameras/camera";
  17936. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17937. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  17938. import "babylonjs/Engines/Extensions/engine.multiview";
  17939. /**
  17940. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17941. * This will not be used for webXR as it supports displaying texture arrays directly
  17942. */
  17943. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17944. /**
  17945. * Initializes a VRMultiviewToSingleview
  17946. * @param name name of the post process
  17947. * @param camera camera to be applied to
  17948. * @param scaleFactor scaling factor to the size of the output texture
  17949. */
  17950. constructor(name: string, camera: Camera, scaleFactor: number);
  17951. }
  17952. }
  17953. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  17954. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  17955. import { Nullable } from "babylonjs/types";
  17956. import { Size } from "babylonjs/Maths/math";
  17957. import { Observable } from "babylonjs/Misc/observable";
  17958. module "babylonjs/Engines/engine" {
  17959. interface Engine {
  17960. /** @hidden */
  17961. _vrDisplay: any;
  17962. /** @hidden */
  17963. _vrSupported: boolean;
  17964. /** @hidden */
  17965. _oldSize: Size;
  17966. /** @hidden */
  17967. _oldHardwareScaleFactor: number;
  17968. /** @hidden */
  17969. _vrExclusivePointerMode: boolean;
  17970. /** @hidden */
  17971. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17972. /** @hidden */
  17973. _onVRDisplayPointerRestricted: () => void;
  17974. /** @hidden */
  17975. _onVRDisplayPointerUnrestricted: () => void;
  17976. /** @hidden */
  17977. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17978. /** @hidden */
  17979. _onVrDisplayDisconnect: Nullable<() => void>;
  17980. /** @hidden */
  17981. _onVrDisplayPresentChange: Nullable<() => void>;
  17982. /**
  17983. * Observable signaled when VR display mode changes
  17984. */
  17985. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17986. /**
  17987. * Observable signaled when VR request present is complete
  17988. */
  17989. onVRRequestPresentComplete: Observable<boolean>;
  17990. /**
  17991. * Observable signaled when VR request present starts
  17992. */
  17993. onVRRequestPresentStart: Observable<Engine>;
  17994. /**
  17995. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17996. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17997. */
  17998. isInVRExclusivePointerMode: boolean;
  17999. /**
  18000. * Gets a boolean indicating if a webVR device was detected
  18001. * @returns true if a webVR device was detected
  18002. */
  18003. isVRDevicePresent(): boolean;
  18004. /**
  18005. * Gets the current webVR device
  18006. * @returns the current webVR device (or null)
  18007. */
  18008. getVRDevice(): any;
  18009. /**
  18010. * Initializes a webVR display and starts listening to display change events
  18011. * The onVRDisplayChangedObservable will be notified upon these changes
  18012. * @returns A promise containing a VRDisplay and if vr is supported
  18013. */
  18014. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  18015. /** @hidden */
  18016. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  18017. /**
  18018. * Call this function to switch to webVR mode
  18019. * Will do nothing if webVR is not supported or if there is no webVR device
  18020. * @see http://doc.babylonjs.com/how_to/webvr_camera
  18021. */
  18022. enableVR(): void;
  18023. /** @hidden */
  18024. _onVRFullScreenTriggered(): void;
  18025. }
  18026. }
  18027. }
  18028. declare module "babylonjs/Cameras/VR/webVRCamera" {
  18029. import { Nullable } from "babylonjs/types";
  18030. import { Observable } from "babylonjs/Misc/observable";
  18031. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18032. import { Scene } from "babylonjs/scene";
  18033. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  18034. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  18035. import { Node } from "babylonjs/node";
  18036. import { Ray } from "babylonjs/Culling/ray";
  18037. import "babylonjs/Cameras/RigModes/webVRRigMode";
  18038. import "babylonjs/Engines/Extensions/engine.webVR";
  18039. /**
  18040. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  18041. * IMPORTANT!! The data is right-hand data.
  18042. * @export
  18043. * @interface DevicePose
  18044. */
  18045. export interface DevicePose {
  18046. /**
  18047. * The position of the device, values in array are [x,y,z].
  18048. */
  18049. readonly position: Nullable<Float32Array>;
  18050. /**
  18051. * The linearVelocity of the device, values in array are [x,y,z].
  18052. */
  18053. readonly linearVelocity: Nullable<Float32Array>;
  18054. /**
  18055. * The linearAcceleration of the device, values in array are [x,y,z].
  18056. */
  18057. readonly linearAcceleration: Nullable<Float32Array>;
  18058. /**
  18059. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  18060. */
  18061. readonly orientation: Nullable<Float32Array>;
  18062. /**
  18063. * The angularVelocity of the device, values in array are [x,y,z].
  18064. */
  18065. readonly angularVelocity: Nullable<Float32Array>;
  18066. /**
  18067. * The angularAcceleration of the device, values in array are [x,y,z].
  18068. */
  18069. readonly angularAcceleration: Nullable<Float32Array>;
  18070. }
  18071. /**
  18072. * Interface representing a pose controlled object in Babylon.
  18073. * A pose controlled object has both regular pose values as well as pose values
  18074. * from an external device such as a VR head mounted display
  18075. */
  18076. export interface PoseControlled {
  18077. /**
  18078. * The position of the object in babylon space.
  18079. */
  18080. position: Vector3;
  18081. /**
  18082. * The rotation quaternion of the object in babylon space.
  18083. */
  18084. rotationQuaternion: Quaternion;
  18085. /**
  18086. * The position of the device in babylon space.
  18087. */
  18088. devicePosition?: Vector3;
  18089. /**
  18090. * The rotation quaternion of the device in babylon space.
  18091. */
  18092. deviceRotationQuaternion: Quaternion;
  18093. /**
  18094. * The raw pose coming from the device.
  18095. */
  18096. rawPose: Nullable<DevicePose>;
  18097. /**
  18098. * The scale of the device to be used when translating from device space to babylon space.
  18099. */
  18100. deviceScaleFactor: number;
  18101. /**
  18102. * Updates the poseControlled values based on the input device pose.
  18103. * @param poseData the pose data to update the object with
  18104. */
  18105. updateFromDevice(poseData: DevicePose): void;
  18106. }
  18107. /**
  18108. * Set of options to customize the webVRCamera
  18109. */
  18110. export interface WebVROptions {
  18111. /**
  18112. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  18113. */
  18114. trackPosition?: boolean;
  18115. /**
  18116. * Sets the scale of the vrDevice in babylon space. (default: 1)
  18117. */
  18118. positionScale?: number;
  18119. /**
  18120. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  18121. */
  18122. displayName?: string;
  18123. /**
  18124. * Should the native controller meshes be initialized. (default: true)
  18125. */
  18126. controllerMeshes?: boolean;
  18127. /**
  18128. * Creating a default HemiLight only on controllers. (default: true)
  18129. */
  18130. defaultLightingOnControllers?: boolean;
  18131. /**
  18132. * If you don't want to use the default VR button of the helper. (default: false)
  18133. */
  18134. useCustomVRButton?: boolean;
  18135. /**
  18136. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  18137. */
  18138. customVRButton?: HTMLButtonElement;
  18139. /**
  18140. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  18141. */
  18142. rayLength?: number;
  18143. /**
  18144. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  18145. */
  18146. defaultHeight?: number;
  18147. /**
  18148. * If multiview should be used if availible (default: false)
  18149. */
  18150. useMultiview?: boolean;
  18151. }
  18152. /**
  18153. * This represents a WebVR camera.
  18154. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18155. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18156. */
  18157. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  18158. private webVROptions;
  18159. /**
  18160. * @hidden
  18161. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18162. */
  18163. _vrDevice: any;
  18164. /**
  18165. * The rawPose of the vrDevice.
  18166. */
  18167. rawPose: Nullable<DevicePose>;
  18168. private _onVREnabled;
  18169. private _specsVersion;
  18170. private _attached;
  18171. private _frameData;
  18172. protected _descendants: Array<Node>;
  18173. private _deviceRoomPosition;
  18174. /** @hidden */
  18175. _deviceRoomRotationQuaternion: Quaternion;
  18176. private _standingMatrix;
  18177. /**
  18178. * Represents device position in babylon space.
  18179. */
  18180. devicePosition: Vector3;
  18181. /**
  18182. * Represents device rotation in babylon space.
  18183. */
  18184. deviceRotationQuaternion: Quaternion;
  18185. /**
  18186. * The scale of the device to be used when translating from device space to babylon space.
  18187. */
  18188. deviceScaleFactor: number;
  18189. private _deviceToWorld;
  18190. private _worldToDevice;
  18191. /**
  18192. * References to the webVR controllers for the vrDevice.
  18193. */
  18194. controllers: Array<WebVRController>;
  18195. /**
  18196. * Emits an event when a controller is attached.
  18197. */
  18198. onControllersAttachedObservable: Observable<WebVRController[]>;
  18199. /**
  18200. * Emits an event when a controller's mesh has been loaded;
  18201. */
  18202. onControllerMeshLoadedObservable: Observable<WebVRController>;
  18203. /**
  18204. * Emits an event when the HMD's pose has been updated.
  18205. */
  18206. onPoseUpdatedFromDeviceObservable: Observable<any>;
  18207. private _poseSet;
  18208. /**
  18209. * If the rig cameras be used as parent instead of this camera.
  18210. */
  18211. rigParenting: boolean;
  18212. private _lightOnControllers;
  18213. private _defaultHeight?;
  18214. /**
  18215. * Instantiates a WebVRFreeCamera.
  18216. * @param name The name of the WebVRFreeCamera
  18217. * @param position The starting anchor position for the camera
  18218. * @param scene The scene the camera belongs to
  18219. * @param webVROptions a set of customizable options for the webVRCamera
  18220. */
  18221. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  18222. /**
  18223. * Gets the device distance from the ground in meters.
  18224. * @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.
  18225. */
  18226. deviceDistanceToRoomGround(): number;
  18227. /**
  18228. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18229. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18230. */
  18231. useStandingMatrix(callback?: (bool: boolean) => void): void;
  18232. /**
  18233. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18234. * @returns A promise with a boolean set to if the standing matrix is supported.
  18235. */
  18236. useStandingMatrixAsync(): Promise<boolean>;
  18237. /**
  18238. * Disposes the camera
  18239. */
  18240. dispose(): void;
  18241. /**
  18242. * Gets a vrController by name.
  18243. * @param name The name of the controller to retreive
  18244. * @returns the controller matching the name specified or null if not found
  18245. */
  18246. getControllerByName(name: string): Nullable<WebVRController>;
  18247. private _leftController;
  18248. /**
  18249. * The controller corresponding to the users left hand.
  18250. */
  18251. readonly leftController: Nullable<WebVRController>;
  18252. private _rightController;
  18253. /**
  18254. * The controller corresponding to the users right hand.
  18255. */
  18256. readonly rightController: Nullable<WebVRController>;
  18257. /**
  18258. * Casts a ray forward from the vrCamera's gaze.
  18259. * @param length Length of the ray (default: 100)
  18260. * @returns the ray corresponding to the gaze
  18261. */
  18262. getForwardRay(length?: number): Ray;
  18263. /**
  18264. * @hidden
  18265. * Updates the camera based on device's frame data
  18266. */
  18267. _checkInputs(): void;
  18268. /**
  18269. * Updates the poseControlled values based on the input device pose.
  18270. * @param poseData Pose coming from the device
  18271. */
  18272. updateFromDevice(poseData: DevicePose): void;
  18273. private _htmlElementAttached;
  18274. private _detachIfAttached;
  18275. /**
  18276. * WebVR's attach control will start broadcasting frames to the device.
  18277. * Note that in certain browsers (chrome for example) this function must be called
  18278. * within a user-interaction callback. Example:
  18279. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18280. *
  18281. * @param element html element to attach the vrDevice to
  18282. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18283. */
  18284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18285. /**
  18286. * Detaches the camera from the html element and disables VR
  18287. *
  18288. * @param element html element to detach from
  18289. */
  18290. detachControl(element: HTMLElement): void;
  18291. /**
  18292. * @returns the name of this class
  18293. */
  18294. getClassName(): string;
  18295. /**
  18296. * Calls resetPose on the vrDisplay
  18297. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18298. */
  18299. resetToCurrentRotation(): void;
  18300. /**
  18301. * @hidden
  18302. * Updates the rig cameras (left and right eye)
  18303. */
  18304. _updateRigCameras(): void;
  18305. private _workingVector;
  18306. private _oneVector;
  18307. private _workingMatrix;
  18308. private updateCacheCalled;
  18309. private _correctPositionIfNotTrackPosition;
  18310. /**
  18311. * @hidden
  18312. * Updates the cached values of the camera
  18313. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18314. */
  18315. _updateCache(ignoreParentClass?: boolean): void;
  18316. /**
  18317. * @hidden
  18318. * Get current device position in babylon world
  18319. */
  18320. _computeDevicePosition(): void;
  18321. /**
  18322. * Updates the current device position and rotation in the babylon world
  18323. */
  18324. update(): void;
  18325. /**
  18326. * @hidden
  18327. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18328. * @returns an identity matrix
  18329. */
  18330. _getViewMatrix(): Matrix;
  18331. private _tmpMatrix;
  18332. /**
  18333. * This function is called by the two RIG cameras.
  18334. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18335. * @hidden
  18336. */
  18337. _getWebVRViewMatrix(): Matrix;
  18338. /** @hidden */
  18339. _getWebVRProjectionMatrix(): Matrix;
  18340. private _onGamepadConnectedObserver;
  18341. private _onGamepadDisconnectedObserver;
  18342. private _updateCacheWhenTrackingDisabledObserver;
  18343. /**
  18344. * Initializes the controllers and their meshes
  18345. */
  18346. initControllers(): void;
  18347. }
  18348. }
  18349. declare module "babylonjs/PostProcesses/postProcess" {
  18350. import { Nullable } from "babylonjs/types";
  18351. import { SmartArray } from "babylonjs/Misc/smartArray";
  18352. import { Observable } from "babylonjs/Misc/observable";
  18353. import { Color4, Vector2 } from "babylonjs/Maths/math";
  18354. import { Camera } from "babylonjs/Cameras/camera";
  18355. import { Effect } from "babylonjs/Materials/effect";
  18356. import "babylonjs/Shaders/postprocess.vertex";
  18357. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18358. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18359. import { Engine } from "babylonjs/Engines/engine";
  18360. /**
  18361. * Size options for a post process
  18362. */
  18363. export type PostProcessOptions = {
  18364. width: number;
  18365. height: number;
  18366. };
  18367. /**
  18368. * PostProcess can be used to apply a shader to a texture after it has been rendered
  18369. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18370. */
  18371. export class PostProcess {
  18372. /** Name of the PostProcess. */
  18373. name: string;
  18374. /**
  18375. * Gets or sets the unique id of the post process
  18376. */
  18377. uniqueId: number;
  18378. /**
  18379. * Width of the texture to apply the post process on
  18380. */
  18381. width: number;
  18382. /**
  18383. * Height of the texture to apply the post process on
  18384. */
  18385. height: number;
  18386. /**
  18387. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  18388. * @hidden
  18389. */
  18390. _outputTexture: Nullable<InternalTexture>;
  18391. /**
  18392. * Sampling mode used by the shader
  18393. * See https://doc.babylonjs.com/classes/3.1/texture
  18394. */
  18395. renderTargetSamplingMode: number;
  18396. /**
  18397. * Clear color to use when screen clearing
  18398. */
  18399. clearColor: Color4;
  18400. /**
  18401. * If the buffer needs to be cleared before applying the post process. (default: true)
  18402. * Should be set to false if shader will overwrite all previous pixels.
  18403. */
  18404. autoClear: boolean;
  18405. /**
  18406. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18407. */
  18408. alphaMode: number;
  18409. /**
  18410. * Sets the setAlphaBlendConstants of the babylon engine
  18411. */
  18412. alphaConstants: Color4;
  18413. /**
  18414. * Animations to be used for the post processing
  18415. */
  18416. animations: import("babylonjs/Animations/animation").Animation[];
  18417. /**
  18418. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18419. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18420. */
  18421. enablePixelPerfectMode: boolean;
  18422. /**
  18423. * Force the postprocess to be applied without taking in account viewport
  18424. */
  18425. forceFullscreenViewport: boolean;
  18426. /**
  18427. * List of inspectable custom properties (used by the Inspector)
  18428. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18429. */
  18430. inspectableCustomProperties: IInspectable[];
  18431. /**
  18432. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18433. *
  18434. * | Value | Type | Description |
  18435. * | ----- | ----------------------------------- | ----------- |
  18436. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18437. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18438. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18439. *
  18440. */
  18441. scaleMode: number;
  18442. /**
  18443. * Force textures to be a power of two (default: false)
  18444. */
  18445. alwaysForcePOT: boolean;
  18446. private _samples;
  18447. /**
  18448. * Number of sample textures (default: 1)
  18449. */
  18450. samples: number;
  18451. /**
  18452. * Modify the scale of the post process to be the same as the viewport (default: false)
  18453. */
  18454. adaptScaleToCurrentViewport: boolean;
  18455. private _camera;
  18456. private _scene;
  18457. private _engine;
  18458. private _options;
  18459. private _reusable;
  18460. private _textureType;
  18461. /**
  18462. * Smart array of input and output textures for the post process.
  18463. * @hidden
  18464. */
  18465. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  18466. /**
  18467. * The index in _textures that corresponds to the output texture.
  18468. * @hidden
  18469. */
  18470. _currentRenderTextureInd: number;
  18471. private _effect;
  18472. private _samplers;
  18473. private _fragmentUrl;
  18474. private _vertexUrl;
  18475. private _parameters;
  18476. private _scaleRatio;
  18477. protected _indexParameters: any;
  18478. private _shareOutputWithPostProcess;
  18479. private _texelSize;
  18480. private _forcedOutputTexture;
  18481. /**
  18482. * Returns the fragment url or shader name used in the post process.
  18483. * @returns the fragment url or name in the shader store.
  18484. */
  18485. getEffectName(): string;
  18486. /**
  18487. * An event triggered when the postprocess is activated.
  18488. */
  18489. onActivateObservable: Observable<Camera>;
  18490. private _onActivateObserver;
  18491. /**
  18492. * A function that is added to the onActivateObservable
  18493. */
  18494. onActivate: Nullable<(camera: Camera) => void>;
  18495. /**
  18496. * An event triggered when the postprocess changes its size.
  18497. */
  18498. onSizeChangedObservable: Observable<PostProcess>;
  18499. private _onSizeChangedObserver;
  18500. /**
  18501. * A function that is added to the onSizeChangedObservable
  18502. */
  18503. onSizeChanged: (postProcess: PostProcess) => void;
  18504. /**
  18505. * An event triggered when the postprocess applies its effect.
  18506. */
  18507. onApplyObservable: Observable<Effect>;
  18508. private _onApplyObserver;
  18509. /**
  18510. * A function that is added to the onApplyObservable
  18511. */
  18512. onApply: (effect: Effect) => void;
  18513. /**
  18514. * An event triggered before rendering the postprocess
  18515. */
  18516. onBeforeRenderObservable: Observable<Effect>;
  18517. private _onBeforeRenderObserver;
  18518. /**
  18519. * A function that is added to the onBeforeRenderObservable
  18520. */
  18521. onBeforeRender: (effect: Effect) => void;
  18522. /**
  18523. * An event triggered after rendering the postprocess
  18524. */
  18525. onAfterRenderObservable: Observable<Effect>;
  18526. private _onAfterRenderObserver;
  18527. /**
  18528. * A function that is added to the onAfterRenderObservable
  18529. */
  18530. onAfterRender: (efect: Effect) => void;
  18531. /**
  18532. * 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
  18533. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18534. */
  18535. inputTexture: InternalTexture;
  18536. /**
  18537. * Gets the camera which post process is applied to.
  18538. * @returns The camera the post process is applied to.
  18539. */
  18540. getCamera(): Camera;
  18541. /**
  18542. * Gets the texel size of the postprocess.
  18543. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18544. */
  18545. readonly texelSize: Vector2;
  18546. /**
  18547. * Creates a new instance PostProcess
  18548. * @param name The name of the PostProcess.
  18549. * @param fragmentUrl The url of the fragment shader to be used.
  18550. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18551. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18552. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18553. * @param camera The camera to apply the render pass to.
  18554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18555. * @param engine The engine which the post process will be applied. (default: current engine)
  18556. * @param reusable If the post process can be reused on the same frame. (default: false)
  18557. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18558. * @param textureType Type of textures used when performing the post process. (default: 0)
  18559. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18560. * @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
  18561. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18562. */
  18563. constructor(
  18564. /** Name of the PostProcess. */
  18565. 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);
  18566. /**
  18567. * Gets a string idenfifying the name of the class
  18568. * @returns "PostProcess" string
  18569. */
  18570. getClassName(): string;
  18571. /**
  18572. * Gets the engine which this post process belongs to.
  18573. * @returns The engine the post process was enabled with.
  18574. */
  18575. getEngine(): Engine;
  18576. /**
  18577. * The effect that is created when initializing the post process.
  18578. * @returns The created effect corresponding the the postprocess.
  18579. */
  18580. getEffect(): Effect;
  18581. /**
  18582. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18583. * @param postProcess The post process to share the output with.
  18584. * @returns This post process.
  18585. */
  18586. shareOutputWith(postProcess: PostProcess): PostProcess;
  18587. /**
  18588. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18589. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18590. */
  18591. useOwnOutput(): void;
  18592. /**
  18593. * Updates the effect with the current post process compile time values and recompiles the shader.
  18594. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18595. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18596. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18597. * @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
  18598. * @param onCompiled Called when the shader has been compiled.
  18599. * @param onError Called if there is an error when compiling a shader.
  18600. */
  18601. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18602. /**
  18603. * The post process is reusable if it can be used multiple times within one frame.
  18604. * @returns If the post process is reusable
  18605. */
  18606. isReusable(): boolean;
  18607. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18608. markTextureDirty(): void;
  18609. /**
  18610. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18611. * 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.
  18612. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18613. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18614. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18615. * @returns The target texture that was bound to be written to.
  18616. */
  18617. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18618. /**
  18619. * If the post process is supported.
  18620. */
  18621. readonly isSupported: boolean;
  18622. /**
  18623. * The aspect ratio of the output texture.
  18624. */
  18625. readonly aspectRatio: number;
  18626. /**
  18627. * Get a value indicating if the post-process is ready to be used
  18628. * @returns true if the post-process is ready (shader is compiled)
  18629. */
  18630. isReady(): boolean;
  18631. /**
  18632. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18633. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18634. */
  18635. apply(): Nullable<Effect>;
  18636. private _disposeTextures;
  18637. /**
  18638. * Disposes the post process.
  18639. * @param camera The camera to dispose the post process on.
  18640. */
  18641. dispose(camera?: Camera): void;
  18642. }
  18643. }
  18644. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  18645. /** @hidden */
  18646. export var kernelBlurVaryingDeclaration: {
  18647. name: string;
  18648. shader: string;
  18649. };
  18650. }
  18651. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  18652. /** @hidden */
  18653. export var kernelBlurFragment: {
  18654. name: string;
  18655. shader: string;
  18656. };
  18657. }
  18658. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  18659. /** @hidden */
  18660. export var kernelBlurFragment2: {
  18661. name: string;
  18662. shader: string;
  18663. };
  18664. }
  18665. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  18666. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18667. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  18668. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  18669. /** @hidden */
  18670. export var kernelBlurPixelShader: {
  18671. name: string;
  18672. shader: string;
  18673. };
  18674. }
  18675. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  18676. /** @hidden */
  18677. export var kernelBlurVertex: {
  18678. name: string;
  18679. shader: string;
  18680. };
  18681. }
  18682. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  18683. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18684. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  18685. /** @hidden */
  18686. export var kernelBlurVertexShader: {
  18687. name: string;
  18688. shader: string;
  18689. };
  18690. }
  18691. declare module "babylonjs/PostProcesses/blurPostProcess" {
  18692. import { Vector2 } from "babylonjs/Maths/math";
  18693. import { Nullable } from "babylonjs/types";
  18694. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18695. import { Camera } from "babylonjs/Cameras/camera";
  18696. import { Effect } from "babylonjs/Materials/effect";
  18697. import { Engine } from "babylonjs/Engines/engine";
  18698. import "babylonjs/Shaders/kernelBlur.fragment";
  18699. import "babylonjs/Shaders/kernelBlur.vertex";
  18700. /**
  18701. * The Blur Post Process which blurs an image based on a kernel and direction.
  18702. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18703. */
  18704. export class BlurPostProcess extends PostProcess {
  18705. /** The direction in which to blur the image. */
  18706. direction: Vector2;
  18707. private blockCompilation;
  18708. protected _kernel: number;
  18709. protected _idealKernel: number;
  18710. protected _packedFloat: boolean;
  18711. private _staticDefines;
  18712. /**
  18713. * Sets the length in pixels of the blur sample region
  18714. */
  18715. /**
  18716. * Gets the length in pixels of the blur sample region
  18717. */
  18718. kernel: number;
  18719. /**
  18720. * Sets wether or not the blur needs to unpack/repack floats
  18721. */
  18722. /**
  18723. * Gets wether or not the blur is unpacking/repacking floats
  18724. */
  18725. packedFloat: boolean;
  18726. /**
  18727. * Creates a new instance BlurPostProcess
  18728. * @param name The name of the effect.
  18729. * @param direction The direction in which to blur the image.
  18730. * @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.
  18731. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18732. * @param camera The camera to apply the render pass to.
  18733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18734. * @param engine The engine which the post process will be applied. (default: current engine)
  18735. * @param reusable If the post process can be reused on the same frame. (default: false)
  18736. * @param textureType Type of textures used when performing the post process. (default: 0)
  18737. * @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)
  18738. */
  18739. constructor(name: string,
  18740. /** The direction in which to blur the image. */
  18741. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18742. /**
  18743. * Updates the effect with the current post process compile time values and recompiles the shader.
  18744. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18745. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18746. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18747. * @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
  18748. * @param onCompiled Called when the shader has been compiled.
  18749. * @param onError Called if there is an error when compiling a shader.
  18750. */
  18751. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18752. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18753. /**
  18754. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18755. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18756. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18757. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18758. * The gaps between physical kernels are compensated for in the weighting of the samples
  18759. * @param idealKernel Ideal blur kernel.
  18760. * @return Nearest best kernel.
  18761. */
  18762. protected _nearestBestKernel(idealKernel: number): number;
  18763. /**
  18764. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18765. * @param x The point on the Gaussian distribution to sample.
  18766. * @return the value of the Gaussian function at x.
  18767. */
  18768. protected _gaussianWeight(x: number): number;
  18769. /**
  18770. * Generates a string that can be used as a floating point number in GLSL.
  18771. * @param x Value to print.
  18772. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18773. * @return GLSL float string.
  18774. */
  18775. protected _glslFloat(x: number, decimalFigures?: number): string;
  18776. }
  18777. }
  18778. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18779. import { Scene } from "babylonjs/scene";
  18780. import { Plane } from "babylonjs/Maths/math";
  18781. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18782. /**
  18783. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18784. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18785. * You can then easily use it as a reflectionTexture on a flat surface.
  18786. * In case the surface is not a plane, please consider relying on reflection probes.
  18787. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18788. */
  18789. export class MirrorTexture extends RenderTargetTexture {
  18790. private scene;
  18791. /**
  18792. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18793. * 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.
  18794. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18795. */
  18796. mirrorPlane: Plane;
  18797. /**
  18798. * Define the blur ratio used to blur the reflection if needed.
  18799. */
  18800. blurRatio: number;
  18801. /**
  18802. * Define the adaptive blur kernel used to blur the reflection if needed.
  18803. * This will autocompute the closest best match for the `blurKernel`
  18804. */
  18805. adaptiveBlurKernel: number;
  18806. /**
  18807. * Define the blur kernel used to blur the reflection if needed.
  18808. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18809. */
  18810. blurKernel: number;
  18811. /**
  18812. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18813. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18814. */
  18815. blurKernelX: number;
  18816. /**
  18817. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18818. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18819. */
  18820. blurKernelY: number;
  18821. private _autoComputeBlurKernel;
  18822. protected _onRatioRescale(): void;
  18823. private _updateGammaSpace;
  18824. private _imageProcessingConfigChangeObserver;
  18825. private _transformMatrix;
  18826. private _mirrorMatrix;
  18827. private _savedViewMatrix;
  18828. private _blurX;
  18829. private _blurY;
  18830. private _adaptiveBlurKernel;
  18831. private _blurKernelX;
  18832. private _blurKernelY;
  18833. private _blurRatio;
  18834. /**
  18835. * Instantiates a Mirror Texture.
  18836. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18837. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18838. * You can then easily use it as a reflectionTexture on a flat surface.
  18839. * In case the surface is not a plane, please consider relying on reflection probes.
  18840. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18841. * @param name
  18842. * @param size
  18843. * @param scene
  18844. * @param generateMipMaps
  18845. * @param type
  18846. * @param samplingMode
  18847. * @param generateDepthBuffer
  18848. */
  18849. constructor(name: string, size: number | {
  18850. width: number;
  18851. height: number;
  18852. } | {
  18853. ratio: number;
  18854. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18855. private _preparePostProcesses;
  18856. /**
  18857. * Clone the mirror texture.
  18858. * @returns the cloned texture
  18859. */
  18860. clone(): MirrorTexture;
  18861. /**
  18862. * Serialize the texture to a JSON representation you could use in Parse later on
  18863. * @returns the serialized JSON representation
  18864. */
  18865. serialize(): any;
  18866. /**
  18867. * Dispose the texture and release its associated resources.
  18868. */
  18869. dispose(): void;
  18870. }
  18871. }
  18872. declare module "babylonjs/Materials/Textures/texture" {
  18873. import { Observable } from "babylonjs/Misc/observable";
  18874. import { Nullable } from "babylonjs/types";
  18875. import { Scene } from "babylonjs/scene";
  18876. import { Matrix } from "babylonjs/Maths/math";
  18877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18878. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18879. /**
  18880. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18881. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18882. */
  18883. export class Texture extends BaseTexture {
  18884. /** @hidden */
  18885. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18886. /** @hidden */
  18887. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18888. /** @hidden */
  18889. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18890. /** nearest is mag = nearest and min = nearest and mip = linear */
  18891. static readonly NEAREST_SAMPLINGMODE: number;
  18892. /** nearest is mag = nearest and min = nearest and mip = linear */
  18893. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18894. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18895. static readonly BILINEAR_SAMPLINGMODE: number;
  18896. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18897. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18898. /** Trilinear is mag = linear and min = linear and mip = linear */
  18899. static readonly TRILINEAR_SAMPLINGMODE: number;
  18900. /** Trilinear is mag = linear and min = linear and mip = linear */
  18901. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18902. /** mag = nearest and min = nearest and mip = nearest */
  18903. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18904. /** mag = nearest and min = linear and mip = nearest */
  18905. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18906. /** mag = nearest and min = linear and mip = linear */
  18907. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18908. /** mag = nearest and min = linear and mip = none */
  18909. static readonly NEAREST_LINEAR: number;
  18910. /** mag = nearest and min = nearest and mip = none */
  18911. static readonly NEAREST_NEAREST: number;
  18912. /** mag = linear and min = nearest and mip = nearest */
  18913. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18914. /** mag = linear and min = nearest and mip = linear */
  18915. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18916. /** mag = linear and min = linear and mip = none */
  18917. static readonly LINEAR_LINEAR: number;
  18918. /** mag = linear and min = nearest and mip = none */
  18919. static readonly LINEAR_NEAREST: number;
  18920. /** Explicit coordinates mode */
  18921. static readonly EXPLICIT_MODE: number;
  18922. /** Spherical coordinates mode */
  18923. static readonly SPHERICAL_MODE: number;
  18924. /** Planar coordinates mode */
  18925. static readonly PLANAR_MODE: number;
  18926. /** Cubic coordinates mode */
  18927. static readonly CUBIC_MODE: number;
  18928. /** Projection coordinates mode */
  18929. static readonly PROJECTION_MODE: number;
  18930. /** Inverse Cubic coordinates mode */
  18931. static readonly SKYBOX_MODE: number;
  18932. /** Inverse Cubic coordinates mode */
  18933. static readonly INVCUBIC_MODE: number;
  18934. /** Equirectangular coordinates mode */
  18935. static readonly EQUIRECTANGULAR_MODE: number;
  18936. /** Equirectangular Fixed coordinates mode */
  18937. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18938. /** Equirectangular Fixed Mirrored coordinates mode */
  18939. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18940. /** Texture is not repeating outside of 0..1 UVs */
  18941. static readonly CLAMP_ADDRESSMODE: number;
  18942. /** Texture is repeating outside of 0..1 UVs */
  18943. static readonly WRAP_ADDRESSMODE: number;
  18944. /** Texture is repeating and mirrored */
  18945. static readonly MIRROR_ADDRESSMODE: number;
  18946. /**
  18947. * 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
  18948. */
  18949. static UseSerializedUrlIfAny: boolean;
  18950. /**
  18951. * Define the url of the texture.
  18952. */
  18953. url: Nullable<string>;
  18954. /**
  18955. * Define an offset on the texture to offset the u coordinates of the UVs
  18956. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18957. */
  18958. uOffset: number;
  18959. /**
  18960. * Define an offset on the texture to offset the v coordinates of the UVs
  18961. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18962. */
  18963. vOffset: number;
  18964. /**
  18965. * Define an offset on the texture to scale the u coordinates of the UVs
  18966. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18967. */
  18968. uScale: number;
  18969. /**
  18970. * Define an offset on the texture to scale the v coordinates of the UVs
  18971. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18972. */
  18973. vScale: number;
  18974. /**
  18975. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18976. * @see http://doc.babylonjs.com/how_to/more_materials
  18977. */
  18978. uAng: number;
  18979. /**
  18980. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18981. * @see http://doc.babylonjs.com/how_to/more_materials
  18982. */
  18983. vAng: number;
  18984. /**
  18985. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18986. * @see http://doc.babylonjs.com/how_to/more_materials
  18987. */
  18988. wAng: number;
  18989. /**
  18990. * Defines the center of rotation (U)
  18991. */
  18992. uRotationCenter: number;
  18993. /**
  18994. * Defines the center of rotation (V)
  18995. */
  18996. vRotationCenter: number;
  18997. /**
  18998. * Defines the center of rotation (W)
  18999. */
  19000. wRotationCenter: number;
  19001. /**
  19002. * Are mip maps generated for this texture or not.
  19003. */
  19004. readonly noMipmap: boolean;
  19005. /**
  19006. * List of inspectable custom properties (used by the Inspector)
  19007. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19008. */
  19009. inspectableCustomProperties: Nullable<IInspectable[]>;
  19010. private _noMipmap;
  19011. /** @hidden */
  19012. _invertY: boolean;
  19013. private _rowGenerationMatrix;
  19014. private _cachedTextureMatrix;
  19015. private _projectionModeMatrix;
  19016. private _t0;
  19017. private _t1;
  19018. private _t2;
  19019. private _cachedUOffset;
  19020. private _cachedVOffset;
  19021. private _cachedUScale;
  19022. private _cachedVScale;
  19023. private _cachedUAng;
  19024. private _cachedVAng;
  19025. private _cachedWAng;
  19026. private _cachedProjectionMatrixId;
  19027. private _cachedCoordinatesMode;
  19028. /** @hidden */
  19029. protected _initialSamplingMode: number;
  19030. /** @hidden */
  19031. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  19032. private _deleteBuffer;
  19033. protected _format: Nullable<number>;
  19034. private _delayedOnLoad;
  19035. private _delayedOnError;
  19036. /**
  19037. * Observable triggered once the texture has been loaded.
  19038. */
  19039. onLoadObservable: Observable<Texture>;
  19040. protected _isBlocking: boolean;
  19041. /**
  19042. * Is the texture preventing material to render while loading.
  19043. * If false, a default texture will be used instead of the loading one during the preparation step.
  19044. */
  19045. isBlocking: boolean;
  19046. /**
  19047. * Get the current sampling mode associated with the texture.
  19048. */
  19049. readonly samplingMode: number;
  19050. /**
  19051. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  19052. */
  19053. readonly invertY: boolean;
  19054. /**
  19055. * Instantiates a new texture.
  19056. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  19057. * @see http://doc.babylonjs.com/babylon101/materials#texture
  19058. * @param url define the url of the picture to load as a texture
  19059. * @param scene define the scene the texture will belong to
  19060. * @param noMipmap define if the texture will require mip maps or not
  19061. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19062. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19063. * @param onLoad define a callback triggered when the texture has been loaded
  19064. * @param onError define a callback triggered when an error occurred during the loading session
  19065. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19066. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19067. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19068. */
  19069. 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);
  19070. /**
  19071. * Update the url (and optional buffer) of this texture if url was null during construction.
  19072. * @param url the url of the texture
  19073. * @param buffer the buffer of the texture (defaults to null)
  19074. * @param onLoad callback called when the texture is loaded (defaults to null)
  19075. */
  19076. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  19077. /**
  19078. * Finish the loading sequence of a texture flagged as delayed load.
  19079. * @hidden
  19080. */
  19081. delayLoad(): void;
  19082. private _prepareRowForTextureGeneration;
  19083. /**
  19084. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  19085. * @returns the transform matrix of the texture.
  19086. */
  19087. getTextureMatrix(): Matrix;
  19088. /**
  19089. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  19090. * @returns The reflection texture transform
  19091. */
  19092. getReflectionTextureMatrix(): Matrix;
  19093. /**
  19094. * Clones the texture.
  19095. * @returns the cloned texture
  19096. */
  19097. clone(): Texture;
  19098. /**
  19099. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19100. * @returns The JSON representation of the texture
  19101. */
  19102. serialize(): any;
  19103. /**
  19104. * Get the current class name of the texture useful for serialization or dynamic coding.
  19105. * @returns "Texture"
  19106. */
  19107. getClassName(): string;
  19108. /**
  19109. * Dispose the texture and release its associated resources.
  19110. */
  19111. dispose(): void;
  19112. /**
  19113. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  19114. * @param parsedTexture Define the JSON representation of the texture
  19115. * @param scene Define the scene the parsed texture should be instantiated in
  19116. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  19117. * @returns The parsed texture if successful
  19118. */
  19119. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  19120. /**
  19121. * Creates a texture from its base 64 representation.
  19122. * @param data Define the base64 payload without the data: prefix
  19123. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19124. * @param scene Define the scene the texture should belong to
  19125. * @param noMipmap Forces the texture to not create mip map information if true
  19126. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19127. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19128. * @param onLoad define a callback triggered when the texture has been loaded
  19129. * @param onError define a callback triggered when an error occurred during the loading session
  19130. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19131. * @returns the created texture
  19132. */
  19133. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  19134. /**
  19135. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  19136. * @param data Define the base64 payload without the data: prefix
  19137. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19138. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19139. * @param scene Define the scene the texture should belong to
  19140. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19141. * @param noMipmap Forces the texture to not create mip map information if true
  19142. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19143. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19144. * @param onLoad define a callback triggered when the texture has been loaded
  19145. * @param onError define a callback triggered when an error occurred during the loading session
  19146. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19147. * @returns the created texture
  19148. */
  19149. 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;
  19150. }
  19151. }
  19152. declare module "babylonjs/PostProcesses/postProcessManager" {
  19153. import { Nullable } from "babylonjs/types";
  19154. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19155. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19156. import { Scene } from "babylonjs/scene";
  19157. /**
  19158. * PostProcessManager is used to manage one or more post processes or post process pipelines
  19159. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19160. */
  19161. export class PostProcessManager {
  19162. private _scene;
  19163. private _indexBuffer;
  19164. private _vertexBuffers;
  19165. /**
  19166. * Creates a new instance PostProcess
  19167. * @param scene The scene that the post process is associated with.
  19168. */
  19169. constructor(scene: Scene);
  19170. private _prepareBuffers;
  19171. private _buildIndexBuffer;
  19172. /**
  19173. * Rebuilds the vertex buffers of the manager.
  19174. * @hidden
  19175. */
  19176. _rebuild(): void;
  19177. /**
  19178. * Prepares a frame to be run through a post process.
  19179. * @param sourceTexture The input texture to the post procesess. (default: null)
  19180. * @param postProcesses An array of post processes to be run. (default: null)
  19181. * @returns True if the post processes were able to be run.
  19182. * @hidden
  19183. */
  19184. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  19185. /**
  19186. * Manually render a set of post processes to a texture.
  19187. * @param postProcesses An array of post processes to be run.
  19188. * @param targetTexture The target texture to render to.
  19189. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  19190. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  19191. * @param lodLevel defines which lod of the texture to render to
  19192. */
  19193. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  19194. /**
  19195. * Finalize the result of the output of the postprocesses.
  19196. * @param doNotPresent If true the result will not be displayed to the screen.
  19197. * @param targetTexture The target texture to render to.
  19198. * @param faceIndex The index of the face to bind the target texture to.
  19199. * @param postProcesses The array of post processes to render.
  19200. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  19201. * @hidden
  19202. */
  19203. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  19204. /**
  19205. * Disposes of the post process manager.
  19206. */
  19207. dispose(): void;
  19208. }
  19209. }
  19210. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  19211. import { Scene } from "babylonjs/scene";
  19212. import { ISceneComponent } from "babylonjs/sceneComponent";
  19213. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19214. module "babylonjs/abstractScene" {
  19215. interface AbstractScene {
  19216. /**
  19217. * The list of procedural textures added to the scene
  19218. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19219. */
  19220. proceduralTextures: Array<ProceduralTexture>;
  19221. }
  19222. }
  19223. /**
  19224. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  19225. * in a given scene.
  19226. */
  19227. export class ProceduralTextureSceneComponent implements ISceneComponent {
  19228. /**
  19229. * The component name helpfull to identify the component in the list of scene components.
  19230. */
  19231. readonly name: string;
  19232. /**
  19233. * The scene the component belongs to.
  19234. */
  19235. scene: Scene;
  19236. /**
  19237. * Creates a new instance of the component for the given scene
  19238. * @param scene Defines the scene to register the component in
  19239. */
  19240. constructor(scene: Scene);
  19241. /**
  19242. * Registers the component in a given scene
  19243. */
  19244. register(): void;
  19245. /**
  19246. * Rebuilds the elements related to this component in case of
  19247. * context lost for instance.
  19248. */
  19249. rebuild(): void;
  19250. /**
  19251. * Disposes the component and the associated ressources.
  19252. */
  19253. dispose(): void;
  19254. private _beforeClear;
  19255. }
  19256. }
  19257. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  19258. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19259. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  19260. module "babylonjs/Engines/engine" {
  19261. interface Engine {
  19262. /**
  19263. * Creates a new render target cube texture
  19264. * @param size defines the size of the texture
  19265. * @param options defines the options used to create the texture
  19266. * @returns a new render target cube texture stored in an InternalTexture
  19267. */
  19268. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  19269. }
  19270. }
  19271. }
  19272. declare module "babylonjs/Shaders/procedural.vertex" {
  19273. /** @hidden */
  19274. export var proceduralVertexShader: {
  19275. name: string;
  19276. shader: string;
  19277. };
  19278. }
  19279. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  19280. import { Observable } from "babylonjs/Misc/observable";
  19281. import { Nullable } from "babylonjs/types";
  19282. import { Scene } from "babylonjs/scene";
  19283. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  19284. import { Effect } from "babylonjs/Materials/effect";
  19285. import { Texture } from "babylonjs/Materials/Textures/texture";
  19286. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19287. import "babylonjs/Shaders/procedural.vertex";
  19288. /**
  19289. * 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.
  19290. * This is the base class of any Procedural texture and contains most of the shareable code.
  19291. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19292. */
  19293. export class ProceduralTexture extends Texture {
  19294. isCube: boolean;
  19295. /**
  19296. * Define if the texture is enabled or not (disabled texture will not render)
  19297. */
  19298. isEnabled: boolean;
  19299. /**
  19300. * Define if the texture must be cleared before rendering (default is true)
  19301. */
  19302. autoClear: boolean;
  19303. /**
  19304. * Callback called when the texture is generated
  19305. */
  19306. onGenerated: () => void;
  19307. /**
  19308. * Event raised when the texture is generated
  19309. */
  19310. onGeneratedObservable: Observable<ProceduralTexture>;
  19311. /** @hidden */
  19312. _generateMipMaps: boolean;
  19313. /** @hidden **/
  19314. _effect: Effect;
  19315. /** @hidden */
  19316. _textures: {
  19317. [key: string]: Texture;
  19318. };
  19319. private _size;
  19320. private _currentRefreshId;
  19321. private _refreshRate;
  19322. private _vertexBuffers;
  19323. private _indexBuffer;
  19324. private _uniforms;
  19325. private _samplers;
  19326. private _fragment;
  19327. private _floats;
  19328. private _ints;
  19329. private _floatsArrays;
  19330. private _colors3;
  19331. private _colors4;
  19332. private _vectors2;
  19333. private _vectors3;
  19334. private _matrices;
  19335. private _fallbackTexture;
  19336. private _fallbackTextureUsed;
  19337. private _engine;
  19338. private _cachedDefines;
  19339. private _contentUpdateId;
  19340. private _contentData;
  19341. /**
  19342. * Instantiates a new procedural texture.
  19343. * 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.
  19344. * This is the base class of any Procedural texture and contains most of the shareable code.
  19345. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19346. * @param name Define the name of the texture
  19347. * @param size Define the size of the texture to create
  19348. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  19349. * @param scene Define the scene the texture belongs to
  19350. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  19351. * @param generateMipMaps Define if the texture should creates mip maps or not
  19352. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  19353. */
  19354. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  19355. /**
  19356. * The effect that is created when initializing the post process.
  19357. * @returns The created effect corresponding the the postprocess.
  19358. */
  19359. getEffect(): Effect;
  19360. /**
  19361. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  19362. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  19363. */
  19364. getContent(): Nullable<ArrayBufferView>;
  19365. private _createIndexBuffer;
  19366. /** @hidden */
  19367. _rebuild(): void;
  19368. /**
  19369. * Resets the texture in order to recreate its associated resources.
  19370. * This can be called in case of context loss
  19371. */
  19372. reset(): void;
  19373. protected _getDefines(): string;
  19374. /**
  19375. * Is the texture ready to be used ? (rendered at least once)
  19376. * @returns true if ready, otherwise, false.
  19377. */
  19378. isReady(): boolean;
  19379. /**
  19380. * Resets the refresh counter of the texture and start bak from scratch.
  19381. * Could be useful to regenerate the texture if it is setup to render only once.
  19382. */
  19383. resetRefreshCounter(): void;
  19384. /**
  19385. * Set the fragment shader to use in order to render the texture.
  19386. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  19387. */
  19388. setFragment(fragment: any): void;
  19389. /**
  19390. * Define the refresh rate of the texture or the rendering frequency.
  19391. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19392. */
  19393. refreshRate: number;
  19394. /** @hidden */
  19395. _shouldRender(): boolean;
  19396. /**
  19397. * Get the size the texture is rendering at.
  19398. * @returns the size (texture is always squared)
  19399. */
  19400. getRenderSize(): number;
  19401. /**
  19402. * Resize the texture to new value.
  19403. * @param size Define the new size the texture should have
  19404. * @param generateMipMaps Define whether the new texture should create mip maps
  19405. */
  19406. resize(size: number, generateMipMaps: boolean): void;
  19407. private _checkUniform;
  19408. /**
  19409. * Set a texture in the shader program used to render.
  19410. * @param name Define the name of the uniform samplers as defined in the shader
  19411. * @param texture Define the texture to bind to this sampler
  19412. * @return the texture itself allowing "fluent" like uniform updates
  19413. */
  19414. setTexture(name: string, texture: Texture): ProceduralTexture;
  19415. /**
  19416. * Set a float in the shader.
  19417. * @param name Define the name of the uniform as defined in the shader
  19418. * @param value Define the value to give to the uniform
  19419. * @return the texture itself allowing "fluent" like uniform updates
  19420. */
  19421. setFloat(name: string, value: number): ProceduralTexture;
  19422. /**
  19423. * Set a int in the shader.
  19424. * @param name Define the name of the uniform as defined in the shader
  19425. * @param value Define the value to give to the uniform
  19426. * @return the texture itself allowing "fluent" like uniform updates
  19427. */
  19428. setInt(name: string, value: number): ProceduralTexture;
  19429. /**
  19430. * Set an array of floats in the shader.
  19431. * @param name Define the name of the uniform as defined in the shader
  19432. * @param value Define the value to give to the uniform
  19433. * @return the texture itself allowing "fluent" like uniform updates
  19434. */
  19435. setFloats(name: string, value: number[]): ProceduralTexture;
  19436. /**
  19437. * Set a vec3 in the shader from a Color3.
  19438. * @param name Define the name of the uniform as defined in the shader
  19439. * @param value Define the value to give to the uniform
  19440. * @return the texture itself allowing "fluent" like uniform updates
  19441. */
  19442. setColor3(name: string, value: Color3): ProceduralTexture;
  19443. /**
  19444. * Set a vec4 in the shader from a Color4.
  19445. * @param name Define the name of the uniform as defined in the shader
  19446. * @param value Define the value to give to the uniform
  19447. * @return the texture itself allowing "fluent" like uniform updates
  19448. */
  19449. setColor4(name: string, value: Color4): ProceduralTexture;
  19450. /**
  19451. * Set a vec2 in the shader from a Vector2.
  19452. * @param name Define the name of the uniform as defined in the shader
  19453. * @param value Define the value to give to the uniform
  19454. * @return the texture itself allowing "fluent" like uniform updates
  19455. */
  19456. setVector2(name: string, value: Vector2): ProceduralTexture;
  19457. /**
  19458. * Set a vec3 in the shader from a Vector3.
  19459. * @param name Define the name of the uniform as defined in the shader
  19460. * @param value Define the value to give to the uniform
  19461. * @return the texture itself allowing "fluent" like uniform updates
  19462. */
  19463. setVector3(name: string, value: Vector3): ProceduralTexture;
  19464. /**
  19465. * Set a mat4 in the shader from a MAtrix.
  19466. * @param name Define the name of the uniform as defined in the shader
  19467. * @param value Define the value to give to the uniform
  19468. * @return the texture itself allowing "fluent" like uniform updates
  19469. */
  19470. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19471. /**
  19472. * Render the texture to its associated render target.
  19473. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19474. */
  19475. render(useCameraPostProcess?: boolean): void;
  19476. /**
  19477. * Clone the texture.
  19478. * @returns the cloned texture
  19479. */
  19480. clone(): ProceduralTexture;
  19481. /**
  19482. * Dispose the texture and release its asoociated resources.
  19483. */
  19484. dispose(): void;
  19485. }
  19486. }
  19487. declare module "babylonjs/Particles/baseParticleSystem" {
  19488. import { Nullable } from "babylonjs/types";
  19489. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  19490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19491. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19492. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19493. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19494. import { Scene } from "babylonjs/scene";
  19495. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  19496. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19497. import { Texture } from "babylonjs/Materials/Textures/texture";
  19498. import { Animation } from "babylonjs/Animations/animation";
  19499. /**
  19500. * This represents the base class for particle system in Babylon.
  19501. * 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.
  19502. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19503. * @example https://doc.babylonjs.com/babylon101/particles
  19504. */
  19505. export class BaseParticleSystem {
  19506. /**
  19507. * Source color is added to the destination color without alpha affecting the result
  19508. */
  19509. static BLENDMODE_ONEONE: number;
  19510. /**
  19511. * Blend current color and particle color using particle’s alpha
  19512. */
  19513. static BLENDMODE_STANDARD: number;
  19514. /**
  19515. * Add current color and particle color multiplied by particle’s alpha
  19516. */
  19517. static BLENDMODE_ADD: number;
  19518. /**
  19519. * Multiply current color with particle color
  19520. */
  19521. static BLENDMODE_MULTIPLY: number;
  19522. /**
  19523. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19524. */
  19525. static BLENDMODE_MULTIPLYADD: number;
  19526. /**
  19527. * List of animations used by the particle system.
  19528. */
  19529. animations: Animation[];
  19530. /**
  19531. * The id of the Particle system.
  19532. */
  19533. id: string;
  19534. /**
  19535. * The friendly name of the Particle system.
  19536. */
  19537. name: string;
  19538. /**
  19539. * The rendering group used by the Particle system to chose when to render.
  19540. */
  19541. renderingGroupId: number;
  19542. /**
  19543. * The emitter represents the Mesh or position we are attaching the particle system to.
  19544. */
  19545. emitter: Nullable<AbstractMesh | Vector3>;
  19546. /**
  19547. * The maximum number of particles to emit per frame
  19548. */
  19549. emitRate: number;
  19550. /**
  19551. * If you want to launch only a few particles at once, that can be done, as well.
  19552. */
  19553. manualEmitCount: number;
  19554. /**
  19555. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19556. */
  19557. updateSpeed: number;
  19558. /**
  19559. * The amount of time the particle system is running (depends of the overall update speed).
  19560. */
  19561. targetStopDuration: number;
  19562. /**
  19563. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19564. */
  19565. disposeOnStop: boolean;
  19566. /**
  19567. * Minimum power of emitting particles.
  19568. */
  19569. minEmitPower: number;
  19570. /**
  19571. * Maximum power of emitting particles.
  19572. */
  19573. maxEmitPower: number;
  19574. /**
  19575. * Minimum life time of emitting particles.
  19576. */
  19577. minLifeTime: number;
  19578. /**
  19579. * Maximum life time of emitting particles.
  19580. */
  19581. maxLifeTime: number;
  19582. /**
  19583. * Minimum Size of emitting particles.
  19584. */
  19585. minSize: number;
  19586. /**
  19587. * Maximum Size of emitting particles.
  19588. */
  19589. maxSize: number;
  19590. /**
  19591. * Minimum scale of emitting particles on X axis.
  19592. */
  19593. minScaleX: number;
  19594. /**
  19595. * Maximum scale of emitting particles on X axis.
  19596. */
  19597. maxScaleX: number;
  19598. /**
  19599. * Minimum scale of emitting particles on Y axis.
  19600. */
  19601. minScaleY: number;
  19602. /**
  19603. * Maximum scale of emitting particles on Y axis.
  19604. */
  19605. maxScaleY: number;
  19606. /**
  19607. * Gets or sets the minimal initial rotation in radians.
  19608. */
  19609. minInitialRotation: number;
  19610. /**
  19611. * Gets or sets the maximal initial rotation in radians.
  19612. */
  19613. maxInitialRotation: number;
  19614. /**
  19615. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19616. */
  19617. minAngularSpeed: number;
  19618. /**
  19619. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19620. */
  19621. maxAngularSpeed: number;
  19622. /**
  19623. * The texture used to render each particle. (this can be a spritesheet)
  19624. */
  19625. particleTexture: Nullable<Texture>;
  19626. /**
  19627. * The layer mask we are rendering the particles through.
  19628. */
  19629. layerMask: number;
  19630. /**
  19631. * This can help using your own shader to render the particle system.
  19632. * The according effect will be created
  19633. */
  19634. customShader: any;
  19635. /**
  19636. * By default particle system starts as soon as they are created. This prevents the
  19637. * automatic start to happen and let you decide when to start emitting particles.
  19638. */
  19639. preventAutoStart: boolean;
  19640. private _noiseTexture;
  19641. /**
  19642. * Gets or sets a texture used to add random noise to particle positions
  19643. */
  19644. noiseTexture: Nullable<ProceduralTexture>;
  19645. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19646. noiseStrength: Vector3;
  19647. /**
  19648. * Callback triggered when the particle animation is ending.
  19649. */
  19650. onAnimationEnd: Nullable<() => void>;
  19651. /**
  19652. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19653. */
  19654. blendMode: number;
  19655. /**
  19656. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19657. * to override the particles.
  19658. */
  19659. forceDepthWrite: boolean;
  19660. /** 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 */
  19661. preWarmCycles: number;
  19662. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19663. preWarmStepOffset: number;
  19664. /**
  19665. * 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)
  19666. */
  19667. spriteCellChangeSpeed: number;
  19668. /**
  19669. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19670. */
  19671. startSpriteCellID: number;
  19672. /**
  19673. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19674. */
  19675. endSpriteCellID: number;
  19676. /**
  19677. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19678. */
  19679. spriteCellWidth: number;
  19680. /**
  19681. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19682. */
  19683. spriteCellHeight: number;
  19684. /**
  19685. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19686. */
  19687. spriteRandomStartCell: boolean;
  19688. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19689. translationPivot: Vector2;
  19690. /** @hidden */
  19691. protected _isAnimationSheetEnabled: boolean;
  19692. /**
  19693. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19694. */
  19695. beginAnimationOnStart: boolean;
  19696. /**
  19697. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19698. */
  19699. beginAnimationFrom: number;
  19700. /**
  19701. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19702. */
  19703. beginAnimationTo: number;
  19704. /**
  19705. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19706. */
  19707. beginAnimationLoop: boolean;
  19708. /**
  19709. * Gets or sets a world offset applied to all particles
  19710. */
  19711. worldOffset: Vector3;
  19712. /**
  19713. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19714. */
  19715. isAnimationSheetEnabled: boolean;
  19716. /**
  19717. * Get hosting scene
  19718. * @returns the scene
  19719. */
  19720. getScene(): Scene;
  19721. /**
  19722. * You can use gravity if you want to give an orientation to your particles.
  19723. */
  19724. gravity: Vector3;
  19725. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19726. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19727. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19728. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19729. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19730. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19731. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19732. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19733. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19734. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19735. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19736. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19737. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19738. /**
  19739. * Defines the delay in milliseconds before starting the system (0 by default)
  19740. */
  19741. startDelay: number;
  19742. /**
  19743. * Gets the current list of drag gradients.
  19744. * You must use addDragGradient and removeDragGradient to udpate this list
  19745. * @returns the list of drag gradients
  19746. */
  19747. getDragGradients(): Nullable<Array<FactorGradient>>;
  19748. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19749. limitVelocityDamping: number;
  19750. /**
  19751. * Gets the current list of limit velocity gradients.
  19752. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19753. * @returns the list of limit velocity gradients
  19754. */
  19755. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19756. /**
  19757. * Gets the current list of color gradients.
  19758. * You must use addColorGradient and removeColorGradient to udpate this list
  19759. * @returns the list of color gradients
  19760. */
  19761. getColorGradients(): Nullable<Array<ColorGradient>>;
  19762. /**
  19763. * Gets the current list of size gradients.
  19764. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19765. * @returns the list of size gradients
  19766. */
  19767. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19768. /**
  19769. * Gets the current list of color remap gradients.
  19770. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19771. * @returns the list of color remap gradients
  19772. */
  19773. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19774. /**
  19775. * Gets the current list of alpha remap gradients.
  19776. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19777. * @returns the list of alpha remap gradients
  19778. */
  19779. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19780. /**
  19781. * Gets the current list of life time gradients.
  19782. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19783. * @returns the list of life time gradients
  19784. */
  19785. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19786. /**
  19787. * Gets the current list of angular speed gradients.
  19788. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19789. * @returns the list of angular speed gradients
  19790. */
  19791. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19792. /**
  19793. * Gets the current list of velocity gradients.
  19794. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19795. * @returns the list of velocity gradients
  19796. */
  19797. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19798. /**
  19799. * Gets the current list of start size gradients.
  19800. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19801. * @returns the list of start size gradients
  19802. */
  19803. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19804. /**
  19805. * Gets the current list of emit rate gradients.
  19806. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19807. * @returns the list of emit rate gradients
  19808. */
  19809. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19810. /**
  19811. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19812. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19813. */
  19814. direction1: Vector3;
  19815. /**
  19816. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19817. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19818. */
  19819. direction2: Vector3;
  19820. /**
  19821. * 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.
  19822. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19823. */
  19824. minEmitBox: Vector3;
  19825. /**
  19826. * 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.
  19827. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19828. */
  19829. maxEmitBox: Vector3;
  19830. /**
  19831. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19832. */
  19833. color1: Color4;
  19834. /**
  19835. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19836. */
  19837. color2: Color4;
  19838. /**
  19839. * Color the particle will have at the end of its lifetime
  19840. */
  19841. colorDead: Color4;
  19842. /**
  19843. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19844. */
  19845. textureMask: Color4;
  19846. /**
  19847. * The particle emitter type defines the emitter used by the particle system.
  19848. * It can be for example box, sphere, or cone...
  19849. */
  19850. particleEmitterType: IParticleEmitterType;
  19851. /** @hidden */
  19852. _isSubEmitter: boolean;
  19853. /**
  19854. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19855. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19856. */
  19857. billboardMode: number;
  19858. protected _isBillboardBased: boolean;
  19859. /**
  19860. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19861. */
  19862. isBillboardBased: boolean;
  19863. /**
  19864. * The scene the particle system belongs to.
  19865. */
  19866. protected _scene: Scene;
  19867. /**
  19868. * Local cache of defines for image processing.
  19869. */
  19870. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19871. /**
  19872. * Default configuration related to image processing available in the standard Material.
  19873. */
  19874. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19875. /**
  19876. * Gets the image processing configuration used either in this material.
  19877. */
  19878. /**
  19879. * Sets the Default image processing configuration used either in the this material.
  19880. *
  19881. * If sets to null, the scene one is in use.
  19882. */
  19883. imageProcessingConfiguration: ImageProcessingConfiguration;
  19884. /**
  19885. * Attaches a new image processing configuration to the Standard Material.
  19886. * @param configuration
  19887. */
  19888. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19889. /** @hidden */
  19890. protected _reset(): void;
  19891. /** @hidden */
  19892. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19893. /**
  19894. * Instantiates a particle system.
  19895. * 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.
  19896. * @param name The name of the particle system
  19897. */
  19898. constructor(name: string);
  19899. /**
  19900. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19901. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19902. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19903. * @returns the emitter
  19904. */
  19905. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19906. /**
  19907. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19908. * @param radius The radius of the hemisphere to emit from
  19909. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19910. * @returns the emitter
  19911. */
  19912. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19913. /**
  19914. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19915. * @param radius The radius of the sphere to emit from
  19916. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19917. * @returns the emitter
  19918. */
  19919. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19920. /**
  19921. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19922. * @param radius The radius of the sphere to emit from
  19923. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19924. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19925. * @returns the emitter
  19926. */
  19927. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19928. /**
  19929. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19930. * @param radius The radius of the emission cylinder
  19931. * @param height The height of the emission cylinder
  19932. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19933. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19934. * @returns the emitter
  19935. */
  19936. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19937. /**
  19938. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19939. * @param radius The radius of the cylinder to emit from
  19940. * @param height The height of the emission cylinder
  19941. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19942. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19943. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19944. * @returns the emitter
  19945. */
  19946. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19947. /**
  19948. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19949. * @param radius The radius of the cone to emit from
  19950. * @param angle The base angle of the cone
  19951. * @returns the emitter
  19952. */
  19953. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19954. /**
  19955. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19956. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19957. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19958. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19959. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19960. * @returns the emitter
  19961. */
  19962. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19963. }
  19964. }
  19965. declare module "babylonjs/Particles/subEmitter" {
  19966. import { Scene } from "babylonjs/scene";
  19967. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  19968. /**
  19969. * Type of sub emitter
  19970. */
  19971. export enum SubEmitterType {
  19972. /**
  19973. * Attached to the particle over it's lifetime
  19974. */
  19975. ATTACHED = 0,
  19976. /**
  19977. * Created when the particle dies
  19978. */
  19979. END = 1
  19980. }
  19981. /**
  19982. * Sub emitter class used to emit particles from an existing particle
  19983. */
  19984. export class SubEmitter {
  19985. /**
  19986. * the particle system to be used by the sub emitter
  19987. */
  19988. particleSystem: ParticleSystem;
  19989. /**
  19990. * Type of the submitter (Default: END)
  19991. */
  19992. type: SubEmitterType;
  19993. /**
  19994. * 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)
  19995. * Note: This only is supported when using an emitter of type Mesh
  19996. */
  19997. inheritDirection: boolean;
  19998. /**
  19999. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  20000. */
  20001. inheritedVelocityAmount: number;
  20002. /**
  20003. * Creates a sub emitter
  20004. * @param particleSystem the particle system to be used by the sub emitter
  20005. */
  20006. constructor(
  20007. /**
  20008. * the particle system to be used by the sub emitter
  20009. */
  20010. particleSystem: ParticleSystem);
  20011. /**
  20012. * Clones the sub emitter
  20013. * @returns the cloned sub emitter
  20014. */
  20015. clone(): SubEmitter;
  20016. /**
  20017. * Serialize current object to a JSON object
  20018. * @returns the serialized object
  20019. */
  20020. serialize(): any;
  20021. /** @hidden */
  20022. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  20023. /**
  20024. * Creates a new SubEmitter from a serialized JSON version
  20025. * @param serializationObject defines the JSON object to read from
  20026. * @param scene defines the hosting scene
  20027. * @param rootUrl defines the rootUrl for data loading
  20028. * @returns a new SubEmitter
  20029. */
  20030. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  20031. /** Release associated resources */
  20032. dispose(): void;
  20033. }
  20034. }
  20035. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  20036. /** @hidden */
  20037. export var imageProcessingDeclaration: {
  20038. name: string;
  20039. shader: string;
  20040. };
  20041. }
  20042. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  20043. /** @hidden */
  20044. export var imageProcessingFunctions: {
  20045. name: string;
  20046. shader: string;
  20047. };
  20048. }
  20049. declare module "babylonjs/Shaders/particles.fragment" {
  20050. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20051. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  20052. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  20053. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  20054. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20055. /** @hidden */
  20056. export var particlesPixelShader: {
  20057. name: string;
  20058. shader: string;
  20059. };
  20060. }
  20061. declare module "babylonjs/Shaders/particles.vertex" {
  20062. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20063. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20064. /** @hidden */
  20065. export var particlesVertexShader: {
  20066. name: string;
  20067. shader: string;
  20068. };
  20069. }
  20070. declare module "babylonjs/Particles/particleSystem" {
  20071. import { Nullable } from "babylonjs/types";
  20072. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  20073. import { Observable } from "babylonjs/Misc/observable";
  20074. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  20075. import { Effect } from "babylonjs/Materials/effect";
  20076. import { Scene, IDisposable } from "babylonjs/scene";
  20077. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20078. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  20079. import { Particle } from "babylonjs/Particles/particle";
  20080. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20081. import "babylonjs/Shaders/particles.fragment";
  20082. import "babylonjs/Shaders/particles.vertex";
  20083. /**
  20084. * This represents a particle system in Babylon.
  20085. * 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.
  20086. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  20087. * @example https://doc.babylonjs.com/babylon101/particles
  20088. */
  20089. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  20090. /**
  20091. * Billboard mode will only apply to Y axis
  20092. */
  20093. static readonly BILLBOARDMODE_Y: number;
  20094. /**
  20095. * Billboard mode will apply to all axes
  20096. */
  20097. static readonly BILLBOARDMODE_ALL: number;
  20098. /**
  20099. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  20100. */
  20101. static readonly BILLBOARDMODE_STRETCHED: number;
  20102. /**
  20103. * This function can be defined to provide custom update for active particles.
  20104. * This function will be called instead of regular update (age, position, color, etc.).
  20105. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  20106. */
  20107. updateFunction: (particles: Particle[]) => void;
  20108. private _emitterWorldMatrix;
  20109. /**
  20110. * This function can be defined to specify initial direction for every new particle.
  20111. * It by default use the emitterType defined function
  20112. */
  20113. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20114. /**
  20115. * This function can be defined to specify initial position for every new particle.
  20116. * It by default use the emitterType defined function
  20117. */
  20118. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20119. /**
  20120. * @hidden
  20121. */
  20122. _inheritedVelocityOffset: Vector3;
  20123. /**
  20124. * An event triggered when the system is disposed
  20125. */
  20126. onDisposeObservable: Observable<ParticleSystem>;
  20127. private _onDisposeObserver;
  20128. /**
  20129. * Sets a callback that will be triggered when the system is disposed
  20130. */
  20131. onDispose: () => void;
  20132. private _particles;
  20133. private _epsilon;
  20134. private _capacity;
  20135. private _stockParticles;
  20136. private _newPartsExcess;
  20137. private _vertexData;
  20138. private _vertexBuffer;
  20139. private _vertexBuffers;
  20140. private _spriteBuffer;
  20141. private _indexBuffer;
  20142. private _effect;
  20143. private _customEffect;
  20144. private _cachedDefines;
  20145. private _scaledColorStep;
  20146. private _colorDiff;
  20147. private _scaledDirection;
  20148. private _scaledGravity;
  20149. private _currentRenderId;
  20150. private _alive;
  20151. private _useInstancing;
  20152. private _started;
  20153. private _stopped;
  20154. private _actualFrame;
  20155. private _scaledUpdateSpeed;
  20156. private _vertexBufferSize;
  20157. /** @hidden */
  20158. _currentEmitRateGradient: Nullable<FactorGradient>;
  20159. /** @hidden */
  20160. _currentEmitRate1: number;
  20161. /** @hidden */
  20162. _currentEmitRate2: number;
  20163. /** @hidden */
  20164. _currentStartSizeGradient: Nullable<FactorGradient>;
  20165. /** @hidden */
  20166. _currentStartSize1: number;
  20167. /** @hidden */
  20168. _currentStartSize2: number;
  20169. private readonly _rawTextureWidth;
  20170. private _rampGradientsTexture;
  20171. private _useRampGradients;
  20172. /** Gets or sets a boolean indicating that ramp gradients must be used
  20173. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20174. */
  20175. useRampGradients: boolean;
  20176. /**
  20177. * 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.
  20178. * 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: [])
  20179. */
  20180. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  20181. private _subEmitters;
  20182. /**
  20183. * @hidden
  20184. * If the particle systems emitter should be disposed when the particle system is disposed
  20185. */
  20186. _disposeEmitterOnDispose: boolean;
  20187. /**
  20188. * The current active Sub-systems, this property is used by the root particle system only.
  20189. */
  20190. activeSubSystems: Array<ParticleSystem>;
  20191. private _rootParticleSystem;
  20192. /**
  20193. * Gets the current list of active particles
  20194. */
  20195. readonly particles: Particle[];
  20196. /**
  20197. * Returns the string "ParticleSystem"
  20198. * @returns a string containing the class name
  20199. */
  20200. getClassName(): string;
  20201. /**
  20202. * Instantiates a particle system.
  20203. * 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.
  20204. * @param name The name of the particle system
  20205. * @param capacity The max number of particles alive at the same time
  20206. * @param scene The scene the particle system belongs to
  20207. * @param customEffect a custom effect used to change the way particles are rendered by default
  20208. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20209. * @param epsilon Offset used to render the particles
  20210. */
  20211. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20212. private _addFactorGradient;
  20213. private _removeFactorGradient;
  20214. /**
  20215. * Adds a new life time gradient
  20216. * @param gradient defines the gradient to use (between 0 and 1)
  20217. * @param factor defines the life time factor to affect to the specified gradient
  20218. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20219. * @returns the current particle system
  20220. */
  20221. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20222. /**
  20223. * Remove a specific life time gradient
  20224. * @param gradient defines the gradient to remove
  20225. * @returns the current particle system
  20226. */
  20227. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20228. /**
  20229. * Adds a new size gradient
  20230. * @param gradient defines the gradient to use (between 0 and 1)
  20231. * @param factor defines the size factor to affect to the specified gradient
  20232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20233. * @returns the current particle system
  20234. */
  20235. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20236. /**
  20237. * Remove a specific size gradient
  20238. * @param gradient defines the gradient to remove
  20239. * @returns the current particle system
  20240. */
  20241. removeSizeGradient(gradient: number): IParticleSystem;
  20242. /**
  20243. * Adds a new color remap gradient
  20244. * @param gradient defines the gradient to use (between 0 and 1)
  20245. * @param min defines the color remap minimal range
  20246. * @param max defines the color remap maximal range
  20247. * @returns the current particle system
  20248. */
  20249. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20250. /**
  20251. * Remove a specific color remap gradient
  20252. * @param gradient defines the gradient to remove
  20253. * @returns the current particle system
  20254. */
  20255. removeColorRemapGradient(gradient: number): IParticleSystem;
  20256. /**
  20257. * Adds a new alpha remap gradient
  20258. * @param gradient defines the gradient to use (between 0 and 1)
  20259. * @param min defines the alpha remap minimal range
  20260. * @param max defines the alpha remap maximal range
  20261. * @returns the current particle system
  20262. */
  20263. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20264. /**
  20265. * Remove a specific alpha remap gradient
  20266. * @param gradient defines the gradient to remove
  20267. * @returns the current particle system
  20268. */
  20269. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  20270. /**
  20271. * Adds a new angular speed gradient
  20272. * @param gradient defines the gradient to use (between 0 and 1)
  20273. * @param factor defines the angular speed to affect to the specified gradient
  20274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20275. * @returns the current particle system
  20276. */
  20277. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20278. /**
  20279. * Remove a specific angular speed gradient
  20280. * @param gradient defines the gradient to remove
  20281. * @returns the current particle system
  20282. */
  20283. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20284. /**
  20285. * Adds a new velocity gradient
  20286. * @param gradient defines the gradient to use (between 0 and 1)
  20287. * @param factor defines the velocity to affect to the specified gradient
  20288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20289. * @returns the current particle system
  20290. */
  20291. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20292. /**
  20293. * Remove a specific velocity gradient
  20294. * @param gradient defines the gradient to remove
  20295. * @returns the current particle system
  20296. */
  20297. removeVelocityGradient(gradient: number): IParticleSystem;
  20298. /**
  20299. * Adds a new limit velocity gradient
  20300. * @param gradient defines the gradient to use (between 0 and 1)
  20301. * @param factor defines the limit velocity value to affect to the specified gradient
  20302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20303. * @returns the current particle system
  20304. */
  20305. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20306. /**
  20307. * Remove a specific limit velocity gradient
  20308. * @param gradient defines the gradient to remove
  20309. * @returns the current particle system
  20310. */
  20311. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20312. /**
  20313. * Adds a new drag gradient
  20314. * @param gradient defines the gradient to use (between 0 and 1)
  20315. * @param factor defines the drag value to affect to the specified gradient
  20316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20317. * @returns the current particle system
  20318. */
  20319. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20320. /**
  20321. * Remove a specific drag gradient
  20322. * @param gradient defines the gradient to remove
  20323. * @returns the current particle system
  20324. */
  20325. removeDragGradient(gradient: number): IParticleSystem;
  20326. /**
  20327. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20328. * @param gradient defines the gradient to use (between 0 and 1)
  20329. * @param factor defines the emit rate value to affect to the specified gradient
  20330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20331. * @returns the current particle system
  20332. */
  20333. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20334. /**
  20335. * Remove a specific emit rate gradient
  20336. * @param gradient defines the gradient to remove
  20337. * @returns the current particle system
  20338. */
  20339. removeEmitRateGradient(gradient: number): IParticleSystem;
  20340. /**
  20341. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20342. * @param gradient defines the gradient to use (between 0 and 1)
  20343. * @param factor defines the start size value to affect to the specified gradient
  20344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20345. * @returns the current particle system
  20346. */
  20347. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20348. /**
  20349. * Remove a specific start size gradient
  20350. * @param gradient defines the gradient to remove
  20351. * @returns the current particle system
  20352. */
  20353. removeStartSizeGradient(gradient: number): IParticleSystem;
  20354. private _createRampGradientTexture;
  20355. /**
  20356. * Gets the current list of ramp gradients.
  20357. * You must use addRampGradient and removeRampGradient to udpate this list
  20358. * @returns the list of ramp gradients
  20359. */
  20360. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20361. /**
  20362. * Adds a new ramp gradient used to remap particle colors
  20363. * @param gradient defines the gradient to use (between 0 and 1)
  20364. * @param color defines the color to affect to the specified gradient
  20365. * @returns the current particle system
  20366. */
  20367. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  20368. /**
  20369. * Remove a specific ramp gradient
  20370. * @param gradient defines the gradient to remove
  20371. * @returns the current particle system
  20372. */
  20373. removeRampGradient(gradient: number): ParticleSystem;
  20374. /**
  20375. * Adds a new color gradient
  20376. * @param gradient defines the gradient to use (between 0 and 1)
  20377. * @param color1 defines the color to affect to the specified gradient
  20378. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20379. * @returns this particle system
  20380. */
  20381. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20382. /**
  20383. * Remove a specific color gradient
  20384. * @param gradient defines the gradient to remove
  20385. * @returns this particle system
  20386. */
  20387. removeColorGradient(gradient: number): IParticleSystem;
  20388. private _fetchR;
  20389. protected _reset(): void;
  20390. private _resetEffect;
  20391. private _createVertexBuffers;
  20392. private _createIndexBuffer;
  20393. /**
  20394. * Gets the maximum number of particles active at the same time.
  20395. * @returns The max number of active particles.
  20396. */
  20397. getCapacity(): number;
  20398. /**
  20399. * Gets whether there are still active particles in the system.
  20400. * @returns True if it is alive, otherwise false.
  20401. */
  20402. isAlive(): boolean;
  20403. /**
  20404. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20405. * @returns True if it has been started, otherwise false.
  20406. */
  20407. isStarted(): boolean;
  20408. private _prepareSubEmitterInternalArray;
  20409. /**
  20410. * Starts the particle system and begins to emit
  20411. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  20412. */
  20413. start(delay?: number): void;
  20414. /**
  20415. * Stops the particle system.
  20416. * @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.
  20417. */
  20418. stop(stopSubEmitters?: boolean): void;
  20419. /**
  20420. * Remove all active particles
  20421. */
  20422. reset(): void;
  20423. /**
  20424. * @hidden (for internal use only)
  20425. */
  20426. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20427. /**
  20428. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20429. * Its lifetime will start back at 0.
  20430. */
  20431. recycleParticle: (particle: Particle) => void;
  20432. private _stopSubEmitters;
  20433. private _createParticle;
  20434. private _removeFromRoot;
  20435. private _emitFromParticle;
  20436. private _update;
  20437. /** @hidden */
  20438. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  20439. /** @hidden */
  20440. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  20441. /** @hidden */
  20442. private _getEffect;
  20443. /**
  20444. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20445. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  20446. */
  20447. animate(preWarmOnly?: boolean): void;
  20448. private _appendParticleVertices;
  20449. /**
  20450. * Rebuilds the particle system.
  20451. */
  20452. rebuild(): void;
  20453. /**
  20454. * Is this system ready to be used/rendered
  20455. * @return true if the system is ready
  20456. */
  20457. isReady(): boolean;
  20458. private _render;
  20459. /**
  20460. * Renders the particle system in its current state.
  20461. * @returns the current number of particles
  20462. */
  20463. render(): number;
  20464. /**
  20465. * Disposes the particle system and free the associated resources
  20466. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20467. */
  20468. dispose(disposeTexture?: boolean): void;
  20469. /**
  20470. * Clones the particle system.
  20471. * @param name The name of the cloned object
  20472. * @param newEmitter The new emitter to use
  20473. * @returns the cloned particle system
  20474. */
  20475. clone(name: string, newEmitter: any): ParticleSystem;
  20476. /**
  20477. * Serializes the particle system to a JSON object.
  20478. * @returns the JSON object
  20479. */
  20480. serialize(): any;
  20481. /** @hidden */
  20482. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20483. /** @hidden */
  20484. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20485. /**
  20486. * Parses a JSON object to create a particle system.
  20487. * @param parsedParticleSystem The JSON object to parse
  20488. * @param scene The scene to create the particle system in
  20489. * @param rootUrl The root url to use to load external dependencies like texture
  20490. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20491. * @returns the Parsed particle system
  20492. */
  20493. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20494. }
  20495. }
  20496. declare module "babylonjs/Particles/particle" {
  20497. import { Nullable } from "babylonjs/types";
  20498. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  20499. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  20500. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20501. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  20502. /**
  20503. * A particle represents one of the element emitted by a particle system.
  20504. * This is mainly define by its coordinates, direction, velocity and age.
  20505. */
  20506. export class Particle {
  20507. /**
  20508. * The particle system the particle belongs to.
  20509. */
  20510. particleSystem: ParticleSystem;
  20511. private static _Count;
  20512. /**
  20513. * Unique ID of the particle
  20514. */
  20515. id: number;
  20516. /**
  20517. * The world position of the particle in the scene.
  20518. */
  20519. position: Vector3;
  20520. /**
  20521. * The world direction of the particle in the scene.
  20522. */
  20523. direction: Vector3;
  20524. /**
  20525. * The color of the particle.
  20526. */
  20527. color: Color4;
  20528. /**
  20529. * The color change of the particle per step.
  20530. */
  20531. colorStep: Color4;
  20532. /**
  20533. * Defines how long will the life of the particle be.
  20534. */
  20535. lifeTime: number;
  20536. /**
  20537. * The current age of the particle.
  20538. */
  20539. age: number;
  20540. /**
  20541. * The current size of the particle.
  20542. */
  20543. size: number;
  20544. /**
  20545. * The current scale of the particle.
  20546. */
  20547. scale: Vector2;
  20548. /**
  20549. * The current angle of the particle.
  20550. */
  20551. angle: number;
  20552. /**
  20553. * Defines how fast is the angle changing.
  20554. */
  20555. angularSpeed: number;
  20556. /**
  20557. * Defines the cell index used by the particle to be rendered from a sprite.
  20558. */
  20559. cellIndex: number;
  20560. /**
  20561. * The information required to support color remapping
  20562. */
  20563. remapData: Vector4;
  20564. /** @hidden */
  20565. _randomCellOffset?: number;
  20566. /** @hidden */
  20567. _initialDirection: Nullable<Vector3>;
  20568. /** @hidden */
  20569. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20570. /** @hidden */
  20571. _initialStartSpriteCellID: number;
  20572. /** @hidden */
  20573. _initialEndSpriteCellID: number;
  20574. /** @hidden */
  20575. _currentColorGradient: Nullable<ColorGradient>;
  20576. /** @hidden */
  20577. _currentColor1: Color4;
  20578. /** @hidden */
  20579. _currentColor2: Color4;
  20580. /** @hidden */
  20581. _currentSizeGradient: Nullable<FactorGradient>;
  20582. /** @hidden */
  20583. _currentSize1: number;
  20584. /** @hidden */
  20585. _currentSize2: number;
  20586. /** @hidden */
  20587. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20588. /** @hidden */
  20589. _currentAngularSpeed1: number;
  20590. /** @hidden */
  20591. _currentAngularSpeed2: number;
  20592. /** @hidden */
  20593. _currentVelocityGradient: Nullable<FactorGradient>;
  20594. /** @hidden */
  20595. _currentVelocity1: number;
  20596. /** @hidden */
  20597. _currentVelocity2: number;
  20598. /** @hidden */
  20599. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20600. /** @hidden */
  20601. _currentLimitVelocity1: number;
  20602. /** @hidden */
  20603. _currentLimitVelocity2: number;
  20604. /** @hidden */
  20605. _currentDragGradient: Nullable<FactorGradient>;
  20606. /** @hidden */
  20607. _currentDrag1: number;
  20608. /** @hidden */
  20609. _currentDrag2: number;
  20610. /** @hidden */
  20611. _randomNoiseCoordinates1: Vector3;
  20612. /** @hidden */
  20613. _randomNoiseCoordinates2: Vector3;
  20614. /**
  20615. * Creates a new instance Particle
  20616. * @param particleSystem the particle system the particle belongs to
  20617. */
  20618. constructor(
  20619. /**
  20620. * The particle system the particle belongs to.
  20621. */
  20622. particleSystem: ParticleSystem);
  20623. private updateCellInfoFromSystem;
  20624. /**
  20625. * Defines how the sprite cell index is updated for the particle
  20626. */
  20627. updateCellIndex(): void;
  20628. /** @hidden */
  20629. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20630. /** @hidden */
  20631. _inheritParticleInfoToSubEmitters(): void;
  20632. /** @hidden */
  20633. _reset(): void;
  20634. /**
  20635. * Copy the properties of particle to another one.
  20636. * @param other the particle to copy the information to.
  20637. */
  20638. copyTo(other: Particle): void;
  20639. }
  20640. }
  20641. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  20642. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20643. import { Effect } from "babylonjs/Materials/effect";
  20644. import { Particle } from "babylonjs/Particles/particle";
  20645. /**
  20646. * Particle emitter represents a volume emitting particles.
  20647. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20648. */
  20649. export interface IParticleEmitterType {
  20650. /**
  20651. * Called by the particle System when the direction is computed for the created particle.
  20652. * @param worldMatrix is the world matrix of the particle system
  20653. * @param directionToUpdate is the direction vector to update with the result
  20654. * @param particle is the particle we are computed the direction for
  20655. */
  20656. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20657. /**
  20658. * Called by the particle System when the position is computed for the created particle.
  20659. * @param worldMatrix is the world matrix of the particle system
  20660. * @param positionToUpdate is the position vector to update with the result
  20661. * @param particle is the particle we are computed the position for
  20662. */
  20663. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20664. /**
  20665. * Clones the current emitter and returns a copy of it
  20666. * @returns the new emitter
  20667. */
  20668. clone(): IParticleEmitterType;
  20669. /**
  20670. * Called by the GPUParticleSystem to setup the update shader
  20671. * @param effect defines the update shader
  20672. */
  20673. applyToShader(effect: Effect): void;
  20674. /**
  20675. * Returns a string to use to update the GPU particles update shader
  20676. * @returns the effect defines string
  20677. */
  20678. getEffectDefines(): string;
  20679. /**
  20680. * Returns a string representing the class name
  20681. * @returns a string containing the class name
  20682. */
  20683. getClassName(): string;
  20684. /**
  20685. * Serializes the particle system to a JSON object.
  20686. * @returns the JSON object
  20687. */
  20688. serialize(): any;
  20689. /**
  20690. * Parse properties from a JSON object
  20691. * @param serializationObject defines the JSON object
  20692. */
  20693. parse(serializationObject: any): void;
  20694. }
  20695. }
  20696. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  20697. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20698. import { Effect } from "babylonjs/Materials/effect";
  20699. import { Particle } from "babylonjs/Particles/particle";
  20700. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20701. /**
  20702. * Particle emitter emitting particles from the inside of a box.
  20703. * It emits the particles randomly between 2 given directions.
  20704. */
  20705. export class BoxParticleEmitter implements IParticleEmitterType {
  20706. /**
  20707. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20708. */
  20709. direction1: Vector3;
  20710. /**
  20711. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20712. */
  20713. direction2: Vector3;
  20714. /**
  20715. * 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.
  20716. */
  20717. minEmitBox: Vector3;
  20718. /**
  20719. * 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.
  20720. */
  20721. maxEmitBox: Vector3;
  20722. /**
  20723. * Creates a new instance BoxParticleEmitter
  20724. */
  20725. constructor();
  20726. /**
  20727. * Called by the particle System when the direction is computed for the created particle.
  20728. * @param worldMatrix is the world matrix of the particle system
  20729. * @param directionToUpdate is the direction vector to update with the result
  20730. * @param particle is the particle we are computed the direction for
  20731. */
  20732. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20733. /**
  20734. * Called by the particle System when the position is computed for the created particle.
  20735. * @param worldMatrix is the world matrix of the particle system
  20736. * @param positionToUpdate is the position vector to update with the result
  20737. * @param particle is the particle we are computed the position for
  20738. */
  20739. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20740. /**
  20741. * Clones the current emitter and returns a copy of it
  20742. * @returns the new emitter
  20743. */
  20744. clone(): BoxParticleEmitter;
  20745. /**
  20746. * Called by the GPUParticleSystem to setup the update shader
  20747. * @param effect defines the update shader
  20748. */
  20749. applyToShader(effect: Effect): void;
  20750. /**
  20751. * Returns a string to use to update the GPU particles update shader
  20752. * @returns a string containng the defines string
  20753. */
  20754. getEffectDefines(): string;
  20755. /**
  20756. * Returns the string "BoxParticleEmitter"
  20757. * @returns a string containing the class name
  20758. */
  20759. getClassName(): string;
  20760. /**
  20761. * Serializes the particle system to a JSON object.
  20762. * @returns the JSON object
  20763. */
  20764. serialize(): any;
  20765. /**
  20766. * Parse properties from a JSON object
  20767. * @param serializationObject defines the JSON object
  20768. */
  20769. parse(serializationObject: any): void;
  20770. }
  20771. }
  20772. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  20773. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20774. import { Effect } from "babylonjs/Materials/effect";
  20775. import { Particle } from "babylonjs/Particles/particle";
  20776. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20777. /**
  20778. * Particle emitter emitting particles from the inside of a cone.
  20779. * It emits the particles alongside the cone volume from the base to the particle.
  20780. * The emission direction might be randomized.
  20781. */
  20782. export class ConeParticleEmitter implements IParticleEmitterType {
  20783. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20784. directionRandomizer: number;
  20785. private _radius;
  20786. private _angle;
  20787. private _height;
  20788. /**
  20789. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20790. */
  20791. radiusRange: number;
  20792. /**
  20793. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20794. */
  20795. heightRange: number;
  20796. /**
  20797. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20798. */
  20799. emitFromSpawnPointOnly: boolean;
  20800. /**
  20801. * Gets or sets the radius of the emission cone
  20802. */
  20803. radius: number;
  20804. /**
  20805. * Gets or sets the angle of the emission cone
  20806. */
  20807. angle: number;
  20808. private _buildHeight;
  20809. /**
  20810. * Creates a new instance ConeParticleEmitter
  20811. * @param radius the radius of the emission cone (1 by default)
  20812. * @param angle the cone base angle (PI by default)
  20813. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20814. */
  20815. constructor(radius?: number, angle?: number,
  20816. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20817. directionRandomizer?: number);
  20818. /**
  20819. * Called by the particle System when the direction is computed for the created particle.
  20820. * @param worldMatrix is the world matrix of the particle system
  20821. * @param directionToUpdate is the direction vector to update with the result
  20822. * @param particle is the particle we are computed the direction for
  20823. */
  20824. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20825. /**
  20826. * Called by the particle System when the position is computed for the created particle.
  20827. * @param worldMatrix is the world matrix of the particle system
  20828. * @param positionToUpdate is the position vector to update with the result
  20829. * @param particle is the particle we are computed the position for
  20830. */
  20831. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20832. /**
  20833. * Clones the current emitter and returns a copy of it
  20834. * @returns the new emitter
  20835. */
  20836. clone(): ConeParticleEmitter;
  20837. /**
  20838. * Called by the GPUParticleSystem to setup the update shader
  20839. * @param effect defines the update shader
  20840. */
  20841. applyToShader(effect: Effect): void;
  20842. /**
  20843. * Returns a string to use to update the GPU particles update shader
  20844. * @returns a string containng the defines string
  20845. */
  20846. getEffectDefines(): string;
  20847. /**
  20848. * Returns the string "ConeParticleEmitter"
  20849. * @returns a string containing the class name
  20850. */
  20851. getClassName(): string;
  20852. /**
  20853. * Serializes the particle system to a JSON object.
  20854. * @returns the JSON object
  20855. */
  20856. serialize(): any;
  20857. /**
  20858. * Parse properties from a JSON object
  20859. * @param serializationObject defines the JSON object
  20860. */
  20861. parse(serializationObject: any): void;
  20862. }
  20863. }
  20864. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  20865. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20866. import { Effect } from "babylonjs/Materials/effect";
  20867. import { Particle } from "babylonjs/Particles/particle";
  20868. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20869. /**
  20870. * Particle emitter emitting particles from the inside of a cylinder.
  20871. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20872. */
  20873. export class CylinderParticleEmitter implements IParticleEmitterType {
  20874. /**
  20875. * The radius of the emission cylinder.
  20876. */
  20877. radius: number;
  20878. /**
  20879. * The height of the emission cylinder.
  20880. */
  20881. height: number;
  20882. /**
  20883. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20884. */
  20885. radiusRange: number;
  20886. /**
  20887. * How much to randomize the particle direction [0-1].
  20888. */
  20889. directionRandomizer: number;
  20890. /**
  20891. * Creates a new instance CylinderParticleEmitter
  20892. * @param radius the radius of the emission cylinder (1 by default)
  20893. * @param height the height of the emission cylinder (1 by default)
  20894. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20895. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20896. */
  20897. constructor(
  20898. /**
  20899. * The radius of the emission cylinder.
  20900. */
  20901. radius?: number,
  20902. /**
  20903. * The height of the emission cylinder.
  20904. */
  20905. height?: number,
  20906. /**
  20907. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20908. */
  20909. radiusRange?: number,
  20910. /**
  20911. * How much to randomize the particle direction [0-1].
  20912. */
  20913. directionRandomizer?: number);
  20914. /**
  20915. * Called by the particle System when the direction is computed for the created particle.
  20916. * @param worldMatrix is the world matrix of the particle system
  20917. * @param directionToUpdate is the direction vector to update with the result
  20918. * @param particle is the particle we are computed the direction for
  20919. */
  20920. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20921. /**
  20922. * Called by the particle System when the position is computed for the created particle.
  20923. * @param worldMatrix is the world matrix of the particle system
  20924. * @param positionToUpdate is the position vector to update with the result
  20925. * @param particle is the particle we are computed the position for
  20926. */
  20927. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20928. /**
  20929. * Clones the current emitter and returns a copy of it
  20930. * @returns the new emitter
  20931. */
  20932. clone(): CylinderParticleEmitter;
  20933. /**
  20934. * Called by the GPUParticleSystem to setup the update shader
  20935. * @param effect defines the update shader
  20936. */
  20937. applyToShader(effect: Effect): void;
  20938. /**
  20939. * Returns a string to use to update the GPU particles update shader
  20940. * @returns a string containng the defines string
  20941. */
  20942. getEffectDefines(): string;
  20943. /**
  20944. * Returns the string "CylinderParticleEmitter"
  20945. * @returns a string containing the class name
  20946. */
  20947. getClassName(): string;
  20948. /**
  20949. * Serializes the particle system to a JSON object.
  20950. * @returns the JSON object
  20951. */
  20952. serialize(): any;
  20953. /**
  20954. * Parse properties from a JSON object
  20955. * @param serializationObject defines the JSON object
  20956. */
  20957. parse(serializationObject: any): void;
  20958. }
  20959. /**
  20960. * Particle emitter emitting particles from the inside of a cylinder.
  20961. * It emits the particles randomly between two vectors.
  20962. */
  20963. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20964. /**
  20965. * The min limit of the emission direction.
  20966. */
  20967. direction1: Vector3;
  20968. /**
  20969. * The max limit of the emission direction.
  20970. */
  20971. direction2: Vector3;
  20972. /**
  20973. * Creates a new instance CylinderDirectedParticleEmitter
  20974. * @param radius the radius of the emission cylinder (1 by default)
  20975. * @param height the height of the emission cylinder (1 by default)
  20976. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20977. * @param direction1 the min limit of the emission direction (up vector by default)
  20978. * @param direction2 the max limit of the emission direction (up vector by default)
  20979. */
  20980. constructor(radius?: number, height?: number, radiusRange?: number,
  20981. /**
  20982. * The min limit of the emission direction.
  20983. */
  20984. direction1?: Vector3,
  20985. /**
  20986. * The max limit of the emission direction.
  20987. */
  20988. direction2?: Vector3);
  20989. /**
  20990. * Called by the particle System when the direction is computed for the created particle.
  20991. * @param worldMatrix is the world matrix of the particle system
  20992. * @param directionToUpdate is the direction vector to update with the result
  20993. * @param particle is the particle we are computed the direction for
  20994. */
  20995. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20996. /**
  20997. * Clones the current emitter and returns a copy of it
  20998. * @returns the new emitter
  20999. */
  21000. clone(): CylinderDirectedParticleEmitter;
  21001. /**
  21002. * Called by the GPUParticleSystem to setup the update shader
  21003. * @param effect defines the update shader
  21004. */
  21005. applyToShader(effect: Effect): void;
  21006. /**
  21007. * Returns a string to use to update the GPU particles update shader
  21008. * @returns a string containng the defines string
  21009. */
  21010. getEffectDefines(): string;
  21011. /**
  21012. * Returns the string "CylinderDirectedParticleEmitter"
  21013. * @returns a string containing the class name
  21014. */
  21015. getClassName(): string;
  21016. /**
  21017. * Serializes the particle system to a JSON object.
  21018. * @returns the JSON object
  21019. */
  21020. serialize(): any;
  21021. /**
  21022. * Parse properties from a JSON object
  21023. * @param serializationObject defines the JSON object
  21024. */
  21025. parse(serializationObject: any): void;
  21026. }
  21027. }
  21028. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  21029. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21030. import { Effect } from "babylonjs/Materials/effect";
  21031. import { Particle } from "babylonjs/Particles/particle";
  21032. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21033. /**
  21034. * Particle emitter emitting particles from the inside of a hemisphere.
  21035. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  21036. */
  21037. export class HemisphericParticleEmitter implements IParticleEmitterType {
  21038. /**
  21039. * The radius of the emission hemisphere.
  21040. */
  21041. radius: number;
  21042. /**
  21043. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21044. */
  21045. radiusRange: number;
  21046. /**
  21047. * How much to randomize the particle direction [0-1].
  21048. */
  21049. directionRandomizer: number;
  21050. /**
  21051. * Creates a new instance HemisphericParticleEmitter
  21052. * @param radius the radius of the emission hemisphere (1 by default)
  21053. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21054. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21055. */
  21056. constructor(
  21057. /**
  21058. * The radius of the emission hemisphere.
  21059. */
  21060. radius?: number,
  21061. /**
  21062. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21063. */
  21064. radiusRange?: number,
  21065. /**
  21066. * How much to randomize the particle direction [0-1].
  21067. */
  21068. directionRandomizer?: number);
  21069. /**
  21070. * Called by the particle System when the direction is computed for the created particle.
  21071. * @param worldMatrix is the world matrix of the particle system
  21072. * @param directionToUpdate is the direction vector to update with the result
  21073. * @param particle is the particle we are computed the direction for
  21074. */
  21075. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21076. /**
  21077. * Called by the particle System when the position is computed for the created particle.
  21078. * @param worldMatrix is the world matrix of the particle system
  21079. * @param positionToUpdate is the position vector to update with the result
  21080. * @param particle is the particle we are computed the position for
  21081. */
  21082. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21083. /**
  21084. * Clones the current emitter and returns a copy of it
  21085. * @returns the new emitter
  21086. */
  21087. clone(): HemisphericParticleEmitter;
  21088. /**
  21089. * Called by the GPUParticleSystem to setup the update shader
  21090. * @param effect defines the update shader
  21091. */
  21092. applyToShader(effect: Effect): void;
  21093. /**
  21094. * Returns a string to use to update the GPU particles update shader
  21095. * @returns a string containng the defines string
  21096. */
  21097. getEffectDefines(): string;
  21098. /**
  21099. * Returns the string "HemisphericParticleEmitter"
  21100. * @returns a string containing the class name
  21101. */
  21102. getClassName(): string;
  21103. /**
  21104. * Serializes the particle system to a JSON object.
  21105. * @returns the JSON object
  21106. */
  21107. serialize(): any;
  21108. /**
  21109. * Parse properties from a JSON object
  21110. * @param serializationObject defines the JSON object
  21111. */
  21112. parse(serializationObject: any): void;
  21113. }
  21114. }
  21115. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  21116. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21117. import { Effect } from "babylonjs/Materials/effect";
  21118. import { Particle } from "babylonjs/Particles/particle";
  21119. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21120. /**
  21121. * Particle emitter emitting particles from a point.
  21122. * It emits the particles randomly between 2 given directions.
  21123. */
  21124. export class PointParticleEmitter implements IParticleEmitterType {
  21125. /**
  21126. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21127. */
  21128. direction1: Vector3;
  21129. /**
  21130. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21131. */
  21132. direction2: Vector3;
  21133. /**
  21134. * Creates a new instance PointParticleEmitter
  21135. */
  21136. constructor();
  21137. /**
  21138. * Called by the particle System when the direction is computed for the created particle.
  21139. * @param worldMatrix is the world matrix of the particle system
  21140. * @param directionToUpdate is the direction vector to update with the result
  21141. * @param particle is the particle we are computed the direction for
  21142. */
  21143. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21144. /**
  21145. * Called by the particle System when the position is computed for the created particle.
  21146. * @param worldMatrix is the world matrix of the particle system
  21147. * @param positionToUpdate is the position vector to update with the result
  21148. * @param particle is the particle we are computed the position for
  21149. */
  21150. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21151. /**
  21152. * Clones the current emitter and returns a copy of it
  21153. * @returns the new emitter
  21154. */
  21155. clone(): PointParticleEmitter;
  21156. /**
  21157. * Called by the GPUParticleSystem to setup the update shader
  21158. * @param effect defines the update shader
  21159. */
  21160. applyToShader(effect: Effect): void;
  21161. /**
  21162. * Returns a string to use to update the GPU particles update shader
  21163. * @returns a string containng the defines string
  21164. */
  21165. getEffectDefines(): string;
  21166. /**
  21167. * Returns the string "PointParticleEmitter"
  21168. * @returns a string containing the class name
  21169. */
  21170. getClassName(): string;
  21171. /**
  21172. * Serializes the particle system to a JSON object.
  21173. * @returns the JSON object
  21174. */
  21175. serialize(): any;
  21176. /**
  21177. * Parse properties from a JSON object
  21178. * @param serializationObject defines the JSON object
  21179. */
  21180. parse(serializationObject: any): void;
  21181. }
  21182. }
  21183. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  21184. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21185. import { Effect } from "babylonjs/Materials/effect";
  21186. import { Particle } from "babylonjs/Particles/particle";
  21187. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21188. /**
  21189. * Particle emitter emitting particles from the inside of a sphere.
  21190. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  21191. */
  21192. export class SphereParticleEmitter implements IParticleEmitterType {
  21193. /**
  21194. * The radius of the emission sphere.
  21195. */
  21196. radius: number;
  21197. /**
  21198. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21199. */
  21200. radiusRange: number;
  21201. /**
  21202. * How much to randomize the particle direction [0-1].
  21203. */
  21204. directionRandomizer: number;
  21205. /**
  21206. * Creates a new instance SphereParticleEmitter
  21207. * @param radius the radius of the emission sphere (1 by default)
  21208. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21209. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21210. */
  21211. constructor(
  21212. /**
  21213. * The radius of the emission sphere.
  21214. */
  21215. radius?: number,
  21216. /**
  21217. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21218. */
  21219. radiusRange?: number,
  21220. /**
  21221. * How much to randomize the particle direction [0-1].
  21222. */
  21223. directionRandomizer?: number);
  21224. /**
  21225. * Called by the particle System when the direction is computed for the created particle.
  21226. * @param worldMatrix is the world matrix of the particle system
  21227. * @param directionToUpdate is the direction vector to update with the result
  21228. * @param particle is the particle we are computed the direction for
  21229. */
  21230. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21231. /**
  21232. * Called by the particle System when the position is computed for the created particle.
  21233. * @param worldMatrix is the world matrix of the particle system
  21234. * @param positionToUpdate is the position vector to update with the result
  21235. * @param particle is the particle we are computed the position for
  21236. */
  21237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21238. /**
  21239. * Clones the current emitter and returns a copy of it
  21240. * @returns the new emitter
  21241. */
  21242. clone(): SphereParticleEmitter;
  21243. /**
  21244. * Called by the GPUParticleSystem to setup the update shader
  21245. * @param effect defines the update shader
  21246. */
  21247. applyToShader(effect: Effect): void;
  21248. /**
  21249. * Returns a string to use to update the GPU particles update shader
  21250. * @returns a string containng the defines string
  21251. */
  21252. getEffectDefines(): string;
  21253. /**
  21254. * Returns the string "SphereParticleEmitter"
  21255. * @returns a string containing the class name
  21256. */
  21257. getClassName(): string;
  21258. /**
  21259. * Serializes the particle system to a JSON object.
  21260. * @returns the JSON object
  21261. */
  21262. serialize(): any;
  21263. /**
  21264. * Parse properties from a JSON object
  21265. * @param serializationObject defines the JSON object
  21266. */
  21267. parse(serializationObject: any): void;
  21268. }
  21269. /**
  21270. * Particle emitter emitting particles from the inside of a sphere.
  21271. * It emits the particles randomly between two vectors.
  21272. */
  21273. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  21274. /**
  21275. * The min limit of the emission direction.
  21276. */
  21277. direction1: Vector3;
  21278. /**
  21279. * The max limit of the emission direction.
  21280. */
  21281. direction2: Vector3;
  21282. /**
  21283. * Creates a new instance SphereDirectedParticleEmitter
  21284. * @param radius the radius of the emission sphere (1 by default)
  21285. * @param direction1 the min limit of the emission direction (up vector by default)
  21286. * @param direction2 the max limit of the emission direction (up vector by default)
  21287. */
  21288. constructor(radius?: number,
  21289. /**
  21290. * The min limit of the emission direction.
  21291. */
  21292. direction1?: Vector3,
  21293. /**
  21294. * The max limit of the emission direction.
  21295. */
  21296. direction2?: Vector3);
  21297. /**
  21298. * Called by the particle System when the direction is computed for the created particle.
  21299. * @param worldMatrix is the world matrix of the particle system
  21300. * @param directionToUpdate is the direction vector to update with the result
  21301. * @param particle is the particle we are computed the direction for
  21302. */
  21303. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21304. /**
  21305. * Clones the current emitter and returns a copy of it
  21306. * @returns the new emitter
  21307. */
  21308. clone(): SphereDirectedParticleEmitter;
  21309. /**
  21310. * Called by the GPUParticleSystem to setup the update shader
  21311. * @param effect defines the update shader
  21312. */
  21313. applyToShader(effect: Effect): void;
  21314. /**
  21315. * Returns a string to use to update the GPU particles update shader
  21316. * @returns a string containng the defines string
  21317. */
  21318. getEffectDefines(): string;
  21319. /**
  21320. * Returns the string "SphereDirectedParticleEmitter"
  21321. * @returns a string containing the class name
  21322. */
  21323. getClassName(): string;
  21324. /**
  21325. * Serializes the particle system to a JSON object.
  21326. * @returns the JSON object
  21327. */
  21328. serialize(): any;
  21329. /**
  21330. * Parse properties from a JSON object
  21331. * @param serializationObject defines the JSON object
  21332. */
  21333. parse(serializationObject: any): void;
  21334. }
  21335. }
  21336. declare module "babylonjs/Particles/EmitterTypes/index" {
  21337. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  21338. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  21339. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  21340. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  21341. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21342. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  21343. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  21344. }
  21345. declare module "babylonjs/Particles/IParticleSystem" {
  21346. import { Nullable } from "babylonjs/types";
  21347. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  21348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21350. import { Texture } from "babylonjs/Materials/Textures/texture";
  21351. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  21352. import { Scene } from "babylonjs/scene";
  21353. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  21354. import { Animation } from "babylonjs/Animations/animation";
  21355. /**
  21356. * Interface representing a particle system in Babylon.js.
  21357. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  21358. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  21359. */
  21360. export interface IParticleSystem {
  21361. /**
  21362. * List of animations used by the particle system.
  21363. */
  21364. animations: Animation[];
  21365. /**
  21366. * The id of the Particle system.
  21367. */
  21368. id: string;
  21369. /**
  21370. * The name of the Particle system.
  21371. */
  21372. name: string;
  21373. /**
  21374. * The emitter represents the Mesh or position we are attaching the particle system to.
  21375. */
  21376. emitter: Nullable<AbstractMesh | Vector3>;
  21377. /**
  21378. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21379. */
  21380. isBillboardBased: boolean;
  21381. /**
  21382. * The rendering group used by the Particle system to chose when to render.
  21383. */
  21384. renderingGroupId: number;
  21385. /**
  21386. * The layer mask we are rendering the particles through.
  21387. */
  21388. layerMask: number;
  21389. /**
  21390. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  21391. */
  21392. updateSpeed: number;
  21393. /**
  21394. * The amount of time the particle system is running (depends of the overall update speed).
  21395. */
  21396. targetStopDuration: number;
  21397. /**
  21398. * The texture used to render each particle. (this can be a spritesheet)
  21399. */
  21400. particleTexture: Nullable<Texture>;
  21401. /**
  21402. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  21403. */
  21404. blendMode: number;
  21405. /**
  21406. * Minimum life time of emitting particles.
  21407. */
  21408. minLifeTime: number;
  21409. /**
  21410. * Maximum life time of emitting particles.
  21411. */
  21412. maxLifeTime: number;
  21413. /**
  21414. * Minimum Size of emitting particles.
  21415. */
  21416. minSize: number;
  21417. /**
  21418. * Maximum Size of emitting particles.
  21419. */
  21420. maxSize: number;
  21421. /**
  21422. * Minimum scale of emitting particles on X axis.
  21423. */
  21424. minScaleX: number;
  21425. /**
  21426. * Maximum scale of emitting particles on X axis.
  21427. */
  21428. maxScaleX: number;
  21429. /**
  21430. * Minimum scale of emitting particles on Y axis.
  21431. */
  21432. minScaleY: number;
  21433. /**
  21434. * Maximum scale of emitting particles on Y axis.
  21435. */
  21436. maxScaleY: number;
  21437. /**
  21438. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21439. */
  21440. color1: Color4;
  21441. /**
  21442. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21443. */
  21444. color2: Color4;
  21445. /**
  21446. * Color the particle will have at the end of its lifetime.
  21447. */
  21448. colorDead: Color4;
  21449. /**
  21450. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  21451. */
  21452. emitRate: number;
  21453. /**
  21454. * You can use gravity if you want to give an orientation to your particles.
  21455. */
  21456. gravity: Vector3;
  21457. /**
  21458. * Minimum power of emitting particles.
  21459. */
  21460. minEmitPower: number;
  21461. /**
  21462. * Maximum power of emitting particles.
  21463. */
  21464. maxEmitPower: number;
  21465. /**
  21466. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  21467. */
  21468. minAngularSpeed: number;
  21469. /**
  21470. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  21471. */
  21472. maxAngularSpeed: number;
  21473. /**
  21474. * Gets or sets the minimal initial rotation in radians.
  21475. */
  21476. minInitialRotation: number;
  21477. /**
  21478. * Gets or sets the maximal initial rotation in radians.
  21479. */
  21480. maxInitialRotation: number;
  21481. /**
  21482. * The particle emitter type defines the emitter used by the particle system.
  21483. * It can be for example box, sphere, or cone...
  21484. */
  21485. particleEmitterType: Nullable<IParticleEmitterType>;
  21486. /**
  21487. * Defines the delay in milliseconds before starting the system (0 by default)
  21488. */
  21489. startDelay: number;
  21490. /**
  21491. * 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
  21492. */
  21493. preWarmCycles: number;
  21494. /**
  21495. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  21496. */
  21497. preWarmStepOffset: number;
  21498. /**
  21499. * 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)
  21500. */
  21501. spriteCellChangeSpeed: number;
  21502. /**
  21503. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  21504. */
  21505. startSpriteCellID: number;
  21506. /**
  21507. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  21508. */
  21509. endSpriteCellID: number;
  21510. /**
  21511. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  21512. */
  21513. spriteCellWidth: number;
  21514. /**
  21515. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  21516. */
  21517. spriteCellHeight: number;
  21518. /**
  21519. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  21520. */
  21521. spriteRandomStartCell: boolean;
  21522. /**
  21523. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  21524. */
  21525. isAnimationSheetEnabled: boolean;
  21526. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21527. translationPivot: Vector2;
  21528. /**
  21529. * Gets or sets a texture used to add random noise to particle positions
  21530. */
  21531. noiseTexture: Nullable<BaseTexture>;
  21532. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21533. noiseStrength: Vector3;
  21534. /**
  21535. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21536. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21537. */
  21538. billboardMode: number;
  21539. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21540. limitVelocityDamping: number;
  21541. /**
  21542. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21543. */
  21544. beginAnimationOnStart: boolean;
  21545. /**
  21546. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21547. */
  21548. beginAnimationFrom: number;
  21549. /**
  21550. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21551. */
  21552. beginAnimationTo: number;
  21553. /**
  21554. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21555. */
  21556. beginAnimationLoop: boolean;
  21557. /**
  21558. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21559. */
  21560. disposeOnStop: boolean;
  21561. /**
  21562. * Gets the maximum number of particles active at the same time.
  21563. * @returns The max number of active particles.
  21564. */
  21565. getCapacity(): number;
  21566. /**
  21567. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21568. * @returns True if it has been started, otherwise false.
  21569. */
  21570. isStarted(): boolean;
  21571. /**
  21572. * Animates the particle system for this frame.
  21573. */
  21574. animate(): void;
  21575. /**
  21576. * Renders the particle system in its current state.
  21577. * @returns the current number of particles
  21578. */
  21579. render(): number;
  21580. /**
  21581. * Dispose the particle system and frees its associated resources.
  21582. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21583. */
  21584. dispose(disposeTexture?: boolean): void;
  21585. /**
  21586. * Clones the particle system.
  21587. * @param name The name of the cloned object
  21588. * @param newEmitter The new emitter to use
  21589. * @returns the cloned particle system
  21590. */
  21591. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21592. /**
  21593. * Serializes the particle system to a JSON object.
  21594. * @returns the JSON object
  21595. */
  21596. serialize(): any;
  21597. /**
  21598. * Rebuild the particle system
  21599. */
  21600. rebuild(): void;
  21601. /**
  21602. * Starts the particle system and begins to emit
  21603. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21604. */
  21605. start(delay?: number): void;
  21606. /**
  21607. * Stops the particle system.
  21608. */
  21609. stop(): void;
  21610. /**
  21611. * Remove all active particles
  21612. */
  21613. reset(): void;
  21614. /**
  21615. * Is this system ready to be used/rendered
  21616. * @return true if the system is ready
  21617. */
  21618. isReady(): boolean;
  21619. /**
  21620. * Adds a new color gradient
  21621. * @param gradient defines the gradient to use (between 0 and 1)
  21622. * @param color1 defines the color to affect to the specified gradient
  21623. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21624. * @returns the current particle system
  21625. */
  21626. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21627. /**
  21628. * Remove a specific color gradient
  21629. * @param gradient defines the gradient to remove
  21630. * @returns the current particle system
  21631. */
  21632. removeColorGradient(gradient: number): IParticleSystem;
  21633. /**
  21634. * Adds a new size gradient
  21635. * @param gradient defines the gradient to use (between 0 and 1)
  21636. * @param factor defines the size factor to affect to the specified gradient
  21637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21638. * @returns the current particle system
  21639. */
  21640. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21641. /**
  21642. * Remove a specific size gradient
  21643. * @param gradient defines the gradient to remove
  21644. * @returns the current particle system
  21645. */
  21646. removeSizeGradient(gradient: number): IParticleSystem;
  21647. /**
  21648. * Gets the current list of color gradients.
  21649. * You must use addColorGradient and removeColorGradient to udpate this list
  21650. * @returns the list of color gradients
  21651. */
  21652. getColorGradients(): Nullable<Array<ColorGradient>>;
  21653. /**
  21654. * Gets the current list of size gradients.
  21655. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21656. * @returns the list of size gradients
  21657. */
  21658. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21659. /**
  21660. * Gets the current list of angular speed gradients.
  21661. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21662. * @returns the list of angular speed gradients
  21663. */
  21664. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21665. /**
  21666. * Adds a new angular speed gradient
  21667. * @param gradient defines the gradient to use (between 0 and 1)
  21668. * @param factor defines the angular speed to affect to the specified gradient
  21669. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21670. * @returns the current particle system
  21671. */
  21672. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21673. /**
  21674. * Remove a specific angular speed gradient
  21675. * @param gradient defines the gradient to remove
  21676. * @returns the current particle system
  21677. */
  21678. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21679. /**
  21680. * Gets the current list of velocity gradients.
  21681. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21682. * @returns the list of velocity gradients
  21683. */
  21684. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21685. /**
  21686. * Adds a new velocity gradient
  21687. * @param gradient defines the gradient to use (between 0 and 1)
  21688. * @param factor defines the velocity to affect to the specified gradient
  21689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21690. * @returns the current particle system
  21691. */
  21692. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21693. /**
  21694. * Remove a specific velocity gradient
  21695. * @param gradient defines the gradient to remove
  21696. * @returns the current particle system
  21697. */
  21698. removeVelocityGradient(gradient: number): IParticleSystem;
  21699. /**
  21700. * Gets the current list of limit velocity gradients.
  21701. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21702. * @returns the list of limit velocity gradients
  21703. */
  21704. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21705. /**
  21706. * Adds a new limit velocity gradient
  21707. * @param gradient defines the gradient to use (between 0 and 1)
  21708. * @param factor defines the limit velocity to affect to the specified gradient
  21709. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21710. * @returns the current particle system
  21711. */
  21712. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21713. /**
  21714. * Remove a specific limit velocity gradient
  21715. * @param gradient defines the gradient to remove
  21716. * @returns the current particle system
  21717. */
  21718. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21719. /**
  21720. * Adds a new drag gradient
  21721. * @param gradient defines the gradient to use (between 0 and 1)
  21722. * @param factor defines the drag to affect to the specified gradient
  21723. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21724. * @returns the current particle system
  21725. */
  21726. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21727. /**
  21728. * Remove a specific drag gradient
  21729. * @param gradient defines the gradient to remove
  21730. * @returns the current particle system
  21731. */
  21732. removeDragGradient(gradient: number): IParticleSystem;
  21733. /**
  21734. * Gets the current list of drag gradients.
  21735. * You must use addDragGradient and removeDragGradient to udpate this list
  21736. * @returns the list of drag gradients
  21737. */
  21738. getDragGradients(): Nullable<Array<FactorGradient>>;
  21739. /**
  21740. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21741. * @param gradient defines the gradient to use (between 0 and 1)
  21742. * @param factor defines the emit rate to affect to the specified gradient
  21743. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21744. * @returns the current particle system
  21745. */
  21746. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21747. /**
  21748. * Remove a specific emit rate gradient
  21749. * @param gradient defines the gradient to remove
  21750. * @returns the current particle system
  21751. */
  21752. removeEmitRateGradient(gradient: number): IParticleSystem;
  21753. /**
  21754. * Gets the current list of emit rate gradients.
  21755. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21756. * @returns the list of emit rate gradients
  21757. */
  21758. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21759. /**
  21760. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21761. * @param gradient defines the gradient to use (between 0 and 1)
  21762. * @param factor defines the start size to affect to the specified gradient
  21763. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21764. * @returns the current particle system
  21765. */
  21766. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21767. /**
  21768. * Remove a specific start size gradient
  21769. * @param gradient defines the gradient to remove
  21770. * @returns the current particle system
  21771. */
  21772. removeStartSizeGradient(gradient: number): IParticleSystem;
  21773. /**
  21774. * Gets the current list of start size gradients.
  21775. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21776. * @returns the list of start size gradients
  21777. */
  21778. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21779. /**
  21780. * Adds a new life time gradient
  21781. * @param gradient defines the gradient to use (between 0 and 1)
  21782. * @param factor defines the life time factor to affect to the specified gradient
  21783. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21784. * @returns the current particle system
  21785. */
  21786. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21787. /**
  21788. * Remove a specific life time gradient
  21789. * @param gradient defines the gradient to remove
  21790. * @returns the current particle system
  21791. */
  21792. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21793. /**
  21794. * Gets the current list of life time gradients.
  21795. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21796. * @returns the list of life time gradients
  21797. */
  21798. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21799. /**
  21800. * Gets the current list of color gradients.
  21801. * You must use addColorGradient and removeColorGradient to udpate this list
  21802. * @returns the list of color gradients
  21803. */
  21804. getColorGradients(): Nullable<Array<ColorGradient>>;
  21805. /**
  21806. * Adds a new ramp gradient used to remap particle colors
  21807. * @param gradient defines the gradient to use (between 0 and 1)
  21808. * @param color defines the color to affect to the specified gradient
  21809. * @returns the current particle system
  21810. */
  21811. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21812. /**
  21813. * Gets the current list of ramp gradients.
  21814. * You must use addRampGradient and removeRampGradient to udpate this list
  21815. * @returns the list of ramp gradients
  21816. */
  21817. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21818. /** Gets or sets a boolean indicating that ramp gradients must be used
  21819. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21820. */
  21821. useRampGradients: boolean;
  21822. /**
  21823. * Adds a new color remap gradient
  21824. * @param gradient defines the gradient to use (between 0 and 1)
  21825. * @param min defines the color remap minimal range
  21826. * @param max defines the color remap maximal range
  21827. * @returns the current particle system
  21828. */
  21829. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21830. /**
  21831. * Gets the current list of color remap gradients.
  21832. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21833. * @returns the list of color remap gradients
  21834. */
  21835. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21836. /**
  21837. * Adds a new alpha remap gradient
  21838. * @param gradient defines the gradient to use (between 0 and 1)
  21839. * @param min defines the alpha remap minimal range
  21840. * @param max defines the alpha remap maximal range
  21841. * @returns the current particle system
  21842. */
  21843. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21844. /**
  21845. * Gets the current list of alpha remap gradients.
  21846. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21847. * @returns the list of alpha remap gradients
  21848. */
  21849. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21850. /**
  21851. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21852. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21853. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21854. * @returns the emitter
  21855. */
  21856. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21857. /**
  21858. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21859. * @param radius The radius of the hemisphere to emit from
  21860. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21861. * @returns the emitter
  21862. */
  21863. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21864. /**
  21865. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21866. * @param radius The radius of the sphere to emit from
  21867. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21868. * @returns the emitter
  21869. */
  21870. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21871. /**
  21872. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21873. * @param radius The radius of the sphere to emit from
  21874. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21875. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21876. * @returns the emitter
  21877. */
  21878. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21879. /**
  21880. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21881. * @param radius The radius of the emission cylinder
  21882. * @param height The height of the emission cylinder
  21883. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21884. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21885. * @returns the emitter
  21886. */
  21887. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21888. /**
  21889. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21890. * @param radius The radius of the cylinder to emit from
  21891. * @param height The height of the emission cylinder
  21892. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21893. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21894. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21895. * @returns the emitter
  21896. */
  21897. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21898. /**
  21899. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21900. * @param radius The radius of the cone to emit from
  21901. * @param angle The base angle of the cone
  21902. * @returns the emitter
  21903. */
  21904. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21905. /**
  21906. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21907. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21908. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21909. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21910. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21911. * @returns the emitter
  21912. */
  21913. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21914. /**
  21915. * Get hosting scene
  21916. * @returns the scene
  21917. */
  21918. getScene(): Scene;
  21919. }
  21920. }
  21921. declare module "babylonjs/Shaders/line.fragment" {
  21922. /** @hidden */
  21923. export var linePixelShader: {
  21924. name: string;
  21925. shader: string;
  21926. };
  21927. }
  21928. declare module "babylonjs/Shaders/line.vertex" {
  21929. /** @hidden */
  21930. export var lineVertexShader: {
  21931. name: string;
  21932. shader: string;
  21933. };
  21934. }
  21935. declare module "babylonjs/Rendering/edgesRenderer" {
  21936. import { Nullable } from "babylonjs/types";
  21937. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21939. import { Vector3 } from "babylonjs/Maths/math";
  21940. import { IDisposable } from "babylonjs/scene";
  21941. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  21942. import "babylonjs/Shaders/line.fragment";
  21943. import "babylonjs/Shaders/line.vertex";
  21944. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21945. module "babylonjs/Meshes/abstractMesh" {
  21946. interface AbstractMesh {
  21947. /**
  21948. * Gets the edgesRenderer associated with the mesh
  21949. */
  21950. edgesRenderer: Nullable<EdgesRenderer>;
  21951. }
  21952. }
  21953. module "babylonjs/Meshes/linesMesh" {
  21954. interface LinesMesh {
  21955. /**
  21956. * Enables the edge rendering mode on the mesh.
  21957. * This mode makes the mesh edges visible
  21958. * @param epsilon defines the maximal distance between two angles to detect a face
  21959. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21960. * @returns the currentAbstractMesh
  21961. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21962. */
  21963. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21964. }
  21965. }
  21966. module "babylonjs/Meshes/linesMesh" {
  21967. interface InstancedLinesMesh {
  21968. /**
  21969. * Enables the edge rendering mode on the mesh.
  21970. * This mode makes the mesh edges visible
  21971. * @param epsilon defines the maximal distance between two angles to detect a face
  21972. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21973. * @returns the current InstancedLinesMesh
  21974. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21975. */
  21976. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21977. }
  21978. }
  21979. /**
  21980. * Defines the minimum contract an Edges renderer should follow.
  21981. */
  21982. export interface IEdgesRenderer extends IDisposable {
  21983. /**
  21984. * Gets or sets a boolean indicating if the edgesRenderer is active
  21985. */
  21986. isEnabled: boolean;
  21987. /**
  21988. * Renders the edges of the attached mesh,
  21989. */
  21990. render(): void;
  21991. /**
  21992. * Checks wether or not the edges renderer is ready to render.
  21993. * @return true if ready, otherwise false.
  21994. */
  21995. isReady(): boolean;
  21996. }
  21997. /**
  21998. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21999. */
  22000. export class EdgesRenderer implements IEdgesRenderer {
  22001. /**
  22002. * Define the size of the edges with an orthographic camera
  22003. */
  22004. edgesWidthScalerForOrthographic: number;
  22005. /**
  22006. * Define the size of the edges with a perspective camera
  22007. */
  22008. edgesWidthScalerForPerspective: number;
  22009. protected _source: AbstractMesh;
  22010. protected _linesPositions: number[];
  22011. protected _linesNormals: number[];
  22012. protected _linesIndices: number[];
  22013. protected _epsilon: number;
  22014. protected _indicesCount: number;
  22015. protected _lineShader: ShaderMaterial;
  22016. protected _ib: DataBuffer;
  22017. protected _buffers: {
  22018. [key: string]: Nullable<VertexBuffer>;
  22019. };
  22020. protected _checkVerticesInsteadOfIndices: boolean;
  22021. private _meshRebuildObserver;
  22022. private _meshDisposeObserver;
  22023. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  22024. isEnabled: boolean;
  22025. /**
  22026. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  22027. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  22028. * @param source Mesh used to create edges
  22029. * @param epsilon sum of angles in adjacency to check for edge
  22030. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  22031. * @param generateEdgesLines - should generate Lines or only prepare resources.
  22032. */
  22033. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  22034. protected _prepareRessources(): void;
  22035. /** @hidden */
  22036. _rebuild(): void;
  22037. /**
  22038. * Releases the required resources for the edges renderer
  22039. */
  22040. dispose(): void;
  22041. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  22042. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  22043. /**
  22044. * Checks if the pair of p0 and p1 is en edge
  22045. * @param faceIndex
  22046. * @param edge
  22047. * @param faceNormals
  22048. * @param p0
  22049. * @param p1
  22050. * @private
  22051. */
  22052. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  22053. /**
  22054. * push line into the position, normal and index buffer
  22055. * @protected
  22056. */
  22057. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  22058. /**
  22059. * Generates lines edges from adjacencjes
  22060. * @private
  22061. */
  22062. _generateEdgesLines(): void;
  22063. /**
  22064. * Checks wether or not the edges renderer is ready to render.
  22065. * @return true if ready, otherwise false.
  22066. */
  22067. isReady(): boolean;
  22068. /**
  22069. * Renders the edges of the attached mesh,
  22070. */
  22071. render(): void;
  22072. }
  22073. /**
  22074. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  22075. */
  22076. export class LineEdgesRenderer extends EdgesRenderer {
  22077. /**
  22078. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  22079. * @param source LineMesh used to generate edges
  22080. * @param epsilon not important (specified angle for edge detection)
  22081. * @param checkVerticesInsteadOfIndices not important for LineMesh
  22082. */
  22083. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  22084. /**
  22085. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  22086. */
  22087. _generateEdgesLines(): void;
  22088. }
  22089. }
  22090. declare module "babylonjs/Rendering/renderingGroup" {
  22091. import { SmartArray } from "babylonjs/Misc/smartArray";
  22092. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22094. import { Nullable } from "babylonjs/types";
  22095. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22096. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  22097. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22098. import { Material } from "babylonjs/Materials/material";
  22099. import { Scene } from "babylonjs/scene";
  22100. /**
  22101. * This represents the object necessary to create a rendering group.
  22102. * This is exclusively used and created by the rendering manager.
  22103. * To modify the behavior, you use the available helpers in your scene or meshes.
  22104. * @hidden
  22105. */
  22106. export class RenderingGroup {
  22107. index: number;
  22108. private static _zeroVector;
  22109. private _scene;
  22110. private _opaqueSubMeshes;
  22111. private _transparentSubMeshes;
  22112. private _alphaTestSubMeshes;
  22113. private _depthOnlySubMeshes;
  22114. private _particleSystems;
  22115. private _spriteManagers;
  22116. private _opaqueSortCompareFn;
  22117. private _alphaTestSortCompareFn;
  22118. private _transparentSortCompareFn;
  22119. private _renderOpaque;
  22120. private _renderAlphaTest;
  22121. private _renderTransparent;
  22122. /** @hidden */
  22123. _edgesRenderers: SmartArray<IEdgesRenderer>;
  22124. onBeforeTransparentRendering: () => void;
  22125. /**
  22126. * Set the opaque sort comparison function.
  22127. * If null the sub meshes will be render in the order they were created
  22128. */
  22129. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22130. /**
  22131. * Set the alpha test sort comparison function.
  22132. * If null the sub meshes will be render in the order they were created
  22133. */
  22134. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22135. /**
  22136. * Set the transparent sort comparison function.
  22137. * If null the sub meshes will be render in the order they were created
  22138. */
  22139. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22140. /**
  22141. * Creates a new rendering group.
  22142. * @param index The rendering group index
  22143. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  22144. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  22145. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  22146. */
  22147. 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>);
  22148. /**
  22149. * Render all the sub meshes contained in the group.
  22150. * @param customRenderFunction Used to override the default render behaviour of the group.
  22151. * @returns true if rendered some submeshes.
  22152. */
  22153. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  22154. /**
  22155. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  22156. * @param subMeshes The submeshes to render
  22157. */
  22158. private renderOpaqueSorted;
  22159. /**
  22160. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  22161. * @param subMeshes The submeshes to render
  22162. */
  22163. private renderAlphaTestSorted;
  22164. /**
  22165. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  22166. * @param subMeshes The submeshes to render
  22167. */
  22168. private renderTransparentSorted;
  22169. /**
  22170. * Renders the submeshes in a specified order.
  22171. * @param subMeshes The submeshes to sort before render
  22172. * @param sortCompareFn The comparison function use to sort
  22173. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  22174. * @param transparent Specifies to activate blending if true
  22175. */
  22176. private static renderSorted;
  22177. /**
  22178. * Renders the submeshes in the order they were dispatched (no sort applied).
  22179. * @param subMeshes The submeshes to render
  22180. */
  22181. private static renderUnsorted;
  22182. /**
  22183. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22184. * are rendered back to front if in the same alpha index.
  22185. *
  22186. * @param a The first submesh
  22187. * @param b The second submesh
  22188. * @returns The result of the comparison
  22189. */
  22190. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  22191. /**
  22192. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22193. * are rendered back to front.
  22194. *
  22195. * @param a The first submesh
  22196. * @param b The second submesh
  22197. * @returns The result of the comparison
  22198. */
  22199. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  22200. /**
  22201. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22202. * are rendered front to back (prevent overdraw).
  22203. *
  22204. * @param a The first submesh
  22205. * @param b The second submesh
  22206. * @returns The result of the comparison
  22207. */
  22208. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  22209. /**
  22210. * Resets the different lists of submeshes to prepare a new frame.
  22211. */
  22212. prepare(): void;
  22213. dispose(): void;
  22214. /**
  22215. * Inserts the submesh in its correct queue depending on its material.
  22216. * @param subMesh The submesh to dispatch
  22217. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22218. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22219. */
  22220. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22221. dispatchSprites(spriteManager: ISpriteManager): void;
  22222. dispatchParticles(particleSystem: IParticleSystem): void;
  22223. private _renderParticles;
  22224. private _renderSprites;
  22225. }
  22226. }
  22227. declare module "babylonjs/Rendering/renderingManager" {
  22228. import { Nullable } from "babylonjs/types";
  22229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22230. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22231. import { SmartArray } from "babylonjs/Misc/smartArray";
  22232. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22233. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22234. import { Material } from "babylonjs/Materials/material";
  22235. import { Scene } from "babylonjs/scene";
  22236. import { Camera } from "babylonjs/Cameras/camera";
  22237. /**
  22238. * Interface describing the different options available in the rendering manager
  22239. * regarding Auto Clear between groups.
  22240. */
  22241. export interface IRenderingManagerAutoClearSetup {
  22242. /**
  22243. * Defines whether or not autoclear is enable.
  22244. */
  22245. autoClear: boolean;
  22246. /**
  22247. * Defines whether or not to autoclear the depth buffer.
  22248. */
  22249. depth: boolean;
  22250. /**
  22251. * Defines whether or not to autoclear the stencil buffer.
  22252. */
  22253. stencil: boolean;
  22254. }
  22255. /**
  22256. * This class is used by the onRenderingGroupObservable
  22257. */
  22258. export class RenderingGroupInfo {
  22259. /**
  22260. * The Scene that being rendered
  22261. */
  22262. scene: Scene;
  22263. /**
  22264. * The camera currently used for the rendering pass
  22265. */
  22266. camera: Nullable<Camera>;
  22267. /**
  22268. * The ID of the renderingGroup being processed
  22269. */
  22270. renderingGroupId: number;
  22271. }
  22272. /**
  22273. * This is the manager responsible of all the rendering for meshes sprites and particles.
  22274. * It is enable to manage the different groups as well as the different necessary sort functions.
  22275. * This should not be used directly aside of the few static configurations
  22276. */
  22277. export class RenderingManager {
  22278. /**
  22279. * The max id used for rendering groups (not included)
  22280. */
  22281. static MAX_RENDERINGGROUPS: number;
  22282. /**
  22283. * The min id used for rendering groups (included)
  22284. */
  22285. static MIN_RENDERINGGROUPS: number;
  22286. /**
  22287. * Used to globally prevent autoclearing scenes.
  22288. */
  22289. static AUTOCLEAR: boolean;
  22290. /**
  22291. * @hidden
  22292. */
  22293. _useSceneAutoClearSetup: boolean;
  22294. private _scene;
  22295. private _renderingGroups;
  22296. private _depthStencilBufferAlreadyCleaned;
  22297. private _autoClearDepthStencil;
  22298. private _customOpaqueSortCompareFn;
  22299. private _customAlphaTestSortCompareFn;
  22300. private _customTransparentSortCompareFn;
  22301. private _renderingGroupInfo;
  22302. /**
  22303. * Instantiates a new rendering group for a particular scene
  22304. * @param scene Defines the scene the groups belongs to
  22305. */
  22306. constructor(scene: Scene);
  22307. private _clearDepthStencilBuffer;
  22308. /**
  22309. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  22310. * @hidden
  22311. */
  22312. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  22313. /**
  22314. * Resets the different information of the group to prepare a new frame
  22315. * @hidden
  22316. */
  22317. reset(): void;
  22318. /**
  22319. * Dispose and release the group and its associated resources.
  22320. * @hidden
  22321. */
  22322. dispose(): void;
  22323. /**
  22324. * Clear the info related to rendering groups preventing retention points during dispose.
  22325. */
  22326. freeRenderingGroups(): void;
  22327. private _prepareRenderingGroup;
  22328. /**
  22329. * Add a sprite manager to the rendering manager in order to render it this frame.
  22330. * @param spriteManager Define the sprite manager to render
  22331. */
  22332. dispatchSprites(spriteManager: ISpriteManager): void;
  22333. /**
  22334. * Add a particle system to the rendering manager in order to render it this frame.
  22335. * @param particleSystem Define the particle system to render
  22336. */
  22337. dispatchParticles(particleSystem: IParticleSystem): void;
  22338. /**
  22339. * Add a submesh to the manager in order to render it this frame
  22340. * @param subMesh The submesh to dispatch
  22341. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22342. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22343. */
  22344. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22345. /**
  22346. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22347. * This allowed control for front to back rendering or reversly depending of the special needs.
  22348. *
  22349. * @param renderingGroupId The rendering group id corresponding to its index
  22350. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22351. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22352. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22353. */
  22354. 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;
  22355. /**
  22356. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22357. *
  22358. * @param renderingGroupId The rendering group id corresponding to its index
  22359. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22360. * @param depth Automatically clears depth between groups if true and autoClear is true.
  22361. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  22362. */
  22363. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  22364. /**
  22365. * Gets the current auto clear configuration for one rendering group of the rendering
  22366. * manager.
  22367. * @param index the rendering group index to get the information for
  22368. * @returns The auto clear setup for the requested rendering group
  22369. */
  22370. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  22371. }
  22372. }
  22373. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  22374. import { Observable } from "babylonjs/Misc/observable";
  22375. import { SmartArray } from "babylonjs/Misc/smartArray";
  22376. import { Nullable } from "babylonjs/types";
  22377. import { Camera } from "babylonjs/Cameras/camera";
  22378. import { Scene } from "babylonjs/scene";
  22379. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  22380. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  22381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22382. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22383. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22384. import { Texture } from "babylonjs/Materials/Textures/texture";
  22385. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  22386. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  22387. import "babylonjs/Engines/Extensions/engine.renderTarget";
  22388. import { Engine } from "babylonjs/Engines/engine";
  22389. /**
  22390. * This Helps creating a texture that will be created from a camera in your scene.
  22391. * It is basically a dynamic texture that could be used to create special effects for instance.
  22392. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  22393. */
  22394. export class RenderTargetTexture extends Texture {
  22395. isCube: boolean;
  22396. /**
  22397. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  22398. */
  22399. static readonly REFRESHRATE_RENDER_ONCE: number;
  22400. /**
  22401. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  22402. */
  22403. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  22404. /**
  22405. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  22406. * the central point of your effect and can save a lot of performances.
  22407. */
  22408. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  22409. /**
  22410. * Use this predicate to dynamically define the list of mesh you want to render.
  22411. * If set, the renderList property will be overwritten.
  22412. */
  22413. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  22414. private _renderList;
  22415. /**
  22416. * Use this list to define the list of mesh you want to render.
  22417. */
  22418. renderList: Nullable<Array<AbstractMesh>>;
  22419. private _hookArray;
  22420. /**
  22421. * Define if particles should be rendered in your texture.
  22422. */
  22423. renderParticles: boolean;
  22424. /**
  22425. * Define if sprites should be rendered in your texture.
  22426. */
  22427. renderSprites: boolean;
  22428. /**
  22429. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  22430. */
  22431. coordinatesMode: number;
  22432. /**
  22433. * Define the camera used to render the texture.
  22434. */
  22435. activeCamera: Nullable<Camera>;
  22436. /**
  22437. * Override the render function of the texture with your own one.
  22438. */
  22439. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  22440. /**
  22441. * Define if camera post processes should be use while rendering the texture.
  22442. */
  22443. useCameraPostProcesses: boolean;
  22444. /**
  22445. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  22446. */
  22447. ignoreCameraViewport: boolean;
  22448. private _postProcessManager;
  22449. private _postProcesses;
  22450. private _resizeObserver;
  22451. /**
  22452. * An event triggered when the texture is unbind.
  22453. */
  22454. onBeforeBindObservable: Observable<RenderTargetTexture>;
  22455. /**
  22456. * An event triggered when the texture is unbind.
  22457. */
  22458. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  22459. private _onAfterUnbindObserver;
  22460. /**
  22461. * Set a after unbind callback in the texture.
  22462. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  22463. */
  22464. onAfterUnbind: () => void;
  22465. /**
  22466. * An event triggered before rendering the texture
  22467. */
  22468. onBeforeRenderObservable: Observable<number>;
  22469. private _onBeforeRenderObserver;
  22470. /**
  22471. * Set a before render callback in the texture.
  22472. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  22473. */
  22474. onBeforeRender: (faceIndex: number) => void;
  22475. /**
  22476. * An event triggered after rendering the texture
  22477. */
  22478. onAfterRenderObservable: Observable<number>;
  22479. private _onAfterRenderObserver;
  22480. /**
  22481. * Set a after render callback in the texture.
  22482. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  22483. */
  22484. onAfterRender: (faceIndex: number) => void;
  22485. /**
  22486. * An event triggered after the texture clear
  22487. */
  22488. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  22489. private _onClearObserver;
  22490. /**
  22491. * Set a clear callback in the texture.
  22492. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  22493. */
  22494. onClear: (Engine: Engine) => void;
  22495. /**
  22496. * Define the clear color of the Render Target if it should be different from the scene.
  22497. */
  22498. clearColor: Color4;
  22499. protected _size: number | {
  22500. width: number;
  22501. height: number;
  22502. };
  22503. protected _initialSizeParameter: number | {
  22504. width: number;
  22505. height: number;
  22506. } | {
  22507. ratio: number;
  22508. };
  22509. protected _sizeRatio: Nullable<number>;
  22510. /** @hidden */
  22511. _generateMipMaps: boolean;
  22512. protected _renderingManager: RenderingManager;
  22513. /** @hidden */
  22514. _waitingRenderList: string[];
  22515. protected _doNotChangeAspectRatio: boolean;
  22516. protected _currentRefreshId: number;
  22517. protected _refreshRate: number;
  22518. protected _textureMatrix: Matrix;
  22519. protected _samples: number;
  22520. protected _renderTargetOptions: RenderTargetCreationOptions;
  22521. /**
  22522. * Gets render target creation options that were used.
  22523. */
  22524. readonly renderTargetOptions: RenderTargetCreationOptions;
  22525. protected _engine: Engine;
  22526. protected _onRatioRescale(): void;
  22527. /**
  22528. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  22529. * It must define where the camera used to render the texture is set
  22530. */
  22531. boundingBoxPosition: Vector3;
  22532. private _boundingBoxSize;
  22533. /**
  22534. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  22535. * When defined, the cubemap will switch to local mode
  22536. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  22537. * @example https://www.babylonjs-playground.com/#RNASML
  22538. */
  22539. boundingBoxSize: Vector3;
  22540. /**
  22541. * In case the RTT has been created with a depth texture, get the associated
  22542. * depth texture.
  22543. * Otherwise, return null.
  22544. */
  22545. depthStencilTexture: Nullable<InternalTexture>;
  22546. /**
  22547. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  22548. * or used a shadow, depth texture...
  22549. * @param name The friendly name of the texture
  22550. * @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)
  22551. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  22552. * @param generateMipMaps True if mip maps need to be generated after render.
  22553. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  22554. * @param type The type of the buffer in the RTT (int, half float, float...)
  22555. * @param isCube True if a cube texture needs to be created
  22556. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  22557. * @param generateDepthBuffer True to generate a depth buffer
  22558. * @param generateStencilBuffer True to generate a stencil buffer
  22559. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  22560. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  22561. * @param delayAllocation if the texture allocation should be delayed (default: false)
  22562. */
  22563. constructor(name: string, size: number | {
  22564. width: number;
  22565. height: number;
  22566. } | {
  22567. ratio: number;
  22568. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  22569. /**
  22570. * Creates a depth stencil texture.
  22571. * This is only available in WebGL 2 or with the depth texture extension available.
  22572. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  22573. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  22574. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  22575. */
  22576. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  22577. private _processSizeParameter;
  22578. /**
  22579. * Define the number of samples to use in case of MSAA.
  22580. * It defaults to one meaning no MSAA has been enabled.
  22581. */
  22582. samples: number;
  22583. /**
  22584. * Resets the refresh counter of the texture and start bak from scratch.
  22585. * Could be useful to regenerate the texture if it is setup to render only once.
  22586. */
  22587. resetRefreshCounter(): void;
  22588. /**
  22589. * Define the refresh rate of the texture or the rendering frequency.
  22590. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22591. */
  22592. refreshRate: number;
  22593. /**
  22594. * Adds a post process to the render target rendering passes.
  22595. * @param postProcess define the post process to add
  22596. */
  22597. addPostProcess(postProcess: PostProcess): void;
  22598. /**
  22599. * Clear all the post processes attached to the render target
  22600. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22601. */
  22602. clearPostProcesses(dispose?: boolean): void;
  22603. /**
  22604. * Remove one of the post process from the list of attached post processes to the texture
  22605. * @param postProcess define the post process to remove from the list
  22606. */
  22607. removePostProcess(postProcess: PostProcess): void;
  22608. /** @hidden */
  22609. _shouldRender(): boolean;
  22610. /**
  22611. * Gets the actual render size of the texture.
  22612. * @returns the width of the render size
  22613. */
  22614. getRenderSize(): number;
  22615. /**
  22616. * Gets the actual render width of the texture.
  22617. * @returns the width of the render size
  22618. */
  22619. getRenderWidth(): number;
  22620. /**
  22621. * Gets the actual render height of the texture.
  22622. * @returns the height of the render size
  22623. */
  22624. getRenderHeight(): number;
  22625. /**
  22626. * Get if the texture can be rescaled or not.
  22627. */
  22628. readonly canRescale: boolean;
  22629. /**
  22630. * Resize the texture using a ratio.
  22631. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22632. */
  22633. scale(ratio: number): void;
  22634. /**
  22635. * Get the texture reflection matrix used to rotate/transform the reflection.
  22636. * @returns the reflection matrix
  22637. */
  22638. getReflectionTextureMatrix(): Matrix;
  22639. /**
  22640. * Resize the texture to a new desired size.
  22641. * Be carrefull as it will recreate all the data in the new texture.
  22642. * @param size Define the new size. It can be:
  22643. * - a number for squared texture,
  22644. * - an object containing { width: number, height: number }
  22645. * - or an object containing a ratio { ratio: number }
  22646. */
  22647. resize(size: number | {
  22648. width: number;
  22649. height: number;
  22650. } | {
  22651. ratio: number;
  22652. }): void;
  22653. /**
  22654. * Renders all the objects from the render list into the texture.
  22655. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22656. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22657. */
  22658. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22659. private _bestReflectionRenderTargetDimension;
  22660. /**
  22661. * @hidden
  22662. * @param faceIndex face index to bind to if this is a cubetexture
  22663. */
  22664. _bindFrameBuffer(faceIndex?: number): void;
  22665. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22666. private renderToTarget;
  22667. /**
  22668. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22669. * This allowed control for front to back rendering or reversly depending of the special needs.
  22670. *
  22671. * @param renderingGroupId The rendering group id corresponding to its index
  22672. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22673. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22674. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22675. */
  22676. 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;
  22677. /**
  22678. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22679. *
  22680. * @param renderingGroupId The rendering group id corresponding to its index
  22681. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22682. */
  22683. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22684. /**
  22685. * Clones the texture.
  22686. * @returns the cloned texture
  22687. */
  22688. clone(): RenderTargetTexture;
  22689. /**
  22690. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22691. * @returns The JSON representation of the texture
  22692. */
  22693. serialize(): any;
  22694. /**
  22695. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22696. */
  22697. disposeFramebufferObjects(): void;
  22698. /**
  22699. * Dispose the texture and release its associated resources.
  22700. */
  22701. dispose(): void;
  22702. /** @hidden */
  22703. _rebuild(): void;
  22704. /**
  22705. * Clear the info related to rendering groups preventing retention point in material dispose.
  22706. */
  22707. freeRenderingGroups(): void;
  22708. /**
  22709. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22710. * @returns the view count
  22711. */
  22712. getViewCount(): number;
  22713. }
  22714. }
  22715. declare module "babylonjs/Materials/material" {
  22716. import { IAnimatable } from "babylonjs/Misc/tools";
  22717. import { SmartArray } from "babylonjs/Misc/smartArray";
  22718. import { Observable } from "babylonjs/Misc/observable";
  22719. import { Nullable } from "babylonjs/types";
  22720. import { Scene } from "babylonjs/scene";
  22721. import { Matrix } from "babylonjs/Maths/math";
  22722. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22724. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22725. import { Effect } from "babylonjs/Materials/effect";
  22726. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22727. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22728. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22729. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22730. import { Mesh } from "babylonjs/Meshes/mesh";
  22731. import { Animation } from "babylonjs/Animations/animation";
  22732. /**
  22733. * Base class for the main features of a material in Babylon.js
  22734. */
  22735. export class Material implements IAnimatable {
  22736. /**
  22737. * Returns the triangle fill mode
  22738. */
  22739. static readonly TriangleFillMode: number;
  22740. /**
  22741. * Returns the wireframe mode
  22742. */
  22743. static readonly WireFrameFillMode: number;
  22744. /**
  22745. * Returns the point fill mode
  22746. */
  22747. static readonly PointFillMode: number;
  22748. /**
  22749. * Returns the point list draw mode
  22750. */
  22751. static readonly PointListDrawMode: number;
  22752. /**
  22753. * Returns the line list draw mode
  22754. */
  22755. static readonly LineListDrawMode: number;
  22756. /**
  22757. * Returns the line loop draw mode
  22758. */
  22759. static readonly LineLoopDrawMode: number;
  22760. /**
  22761. * Returns the line strip draw mode
  22762. */
  22763. static readonly LineStripDrawMode: number;
  22764. /**
  22765. * Returns the triangle strip draw mode
  22766. */
  22767. static readonly TriangleStripDrawMode: number;
  22768. /**
  22769. * Returns the triangle fan draw mode
  22770. */
  22771. static readonly TriangleFanDrawMode: number;
  22772. /**
  22773. * Stores the clock-wise side orientation
  22774. */
  22775. static readonly ClockWiseSideOrientation: number;
  22776. /**
  22777. * Stores the counter clock-wise side orientation
  22778. */
  22779. static readonly CounterClockWiseSideOrientation: number;
  22780. /**
  22781. * The dirty texture flag value
  22782. */
  22783. static readonly TextureDirtyFlag: number;
  22784. /**
  22785. * The dirty light flag value
  22786. */
  22787. static readonly LightDirtyFlag: number;
  22788. /**
  22789. * The dirty fresnel flag value
  22790. */
  22791. static readonly FresnelDirtyFlag: number;
  22792. /**
  22793. * The dirty attribute flag value
  22794. */
  22795. static readonly AttributesDirtyFlag: number;
  22796. /**
  22797. * The dirty misc flag value
  22798. */
  22799. static readonly MiscDirtyFlag: number;
  22800. /**
  22801. * The all dirty flag value
  22802. */
  22803. static readonly AllDirtyFlag: number;
  22804. /**
  22805. * The ID of the material
  22806. */
  22807. id: string;
  22808. /**
  22809. * Gets or sets the unique id of the material
  22810. */
  22811. uniqueId: number;
  22812. /**
  22813. * The name of the material
  22814. */
  22815. name: string;
  22816. /**
  22817. * Gets or sets user defined metadata
  22818. */
  22819. metadata: any;
  22820. /**
  22821. * For internal use only. Please do not use.
  22822. */
  22823. reservedDataStore: any;
  22824. /**
  22825. * Specifies if the ready state should be checked on each call
  22826. */
  22827. checkReadyOnEveryCall: boolean;
  22828. /**
  22829. * Specifies if the ready state should be checked once
  22830. */
  22831. checkReadyOnlyOnce: boolean;
  22832. /**
  22833. * The state of the material
  22834. */
  22835. state: string;
  22836. /**
  22837. * The alpha value of the material
  22838. */
  22839. protected _alpha: number;
  22840. /**
  22841. * List of inspectable custom properties (used by the Inspector)
  22842. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22843. */
  22844. inspectableCustomProperties: IInspectable[];
  22845. /**
  22846. * Sets the alpha value of the material
  22847. */
  22848. /**
  22849. * Gets the alpha value of the material
  22850. */
  22851. alpha: number;
  22852. /**
  22853. * Specifies if back face culling is enabled
  22854. */
  22855. protected _backFaceCulling: boolean;
  22856. /**
  22857. * Sets the back-face culling state
  22858. */
  22859. /**
  22860. * Gets the back-face culling state
  22861. */
  22862. backFaceCulling: boolean;
  22863. /**
  22864. * Stores the value for side orientation
  22865. */
  22866. sideOrientation: number;
  22867. /**
  22868. * Callback triggered when the material is compiled
  22869. */
  22870. onCompiled: Nullable<(effect: Effect) => void>;
  22871. /**
  22872. * Callback triggered when an error occurs
  22873. */
  22874. onError: Nullable<(effect: Effect, errors: string) => void>;
  22875. /**
  22876. * Callback triggered to get the render target textures
  22877. */
  22878. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22879. /**
  22880. * Gets a boolean indicating that current material needs to register RTT
  22881. */
  22882. readonly hasRenderTargetTextures: boolean;
  22883. /**
  22884. * Specifies if the material should be serialized
  22885. */
  22886. doNotSerialize: boolean;
  22887. /**
  22888. * @hidden
  22889. */
  22890. _storeEffectOnSubMeshes: boolean;
  22891. /**
  22892. * Stores the animations for the material
  22893. */
  22894. animations: Nullable<Array<Animation>>;
  22895. /**
  22896. * An event triggered when the material is disposed
  22897. */
  22898. onDisposeObservable: Observable<Material>;
  22899. /**
  22900. * An observer which watches for dispose events
  22901. */
  22902. private _onDisposeObserver;
  22903. private _onUnBindObservable;
  22904. /**
  22905. * Called during a dispose event
  22906. */
  22907. onDispose: () => void;
  22908. private _onBindObservable;
  22909. /**
  22910. * An event triggered when the material is bound
  22911. */
  22912. readonly onBindObservable: Observable<AbstractMesh>;
  22913. /**
  22914. * An observer which watches for bind events
  22915. */
  22916. private _onBindObserver;
  22917. /**
  22918. * Called during a bind event
  22919. */
  22920. onBind: (Mesh: AbstractMesh) => void;
  22921. /**
  22922. * An event triggered when the material is unbound
  22923. */
  22924. readonly onUnBindObservable: Observable<Material>;
  22925. /**
  22926. * Stores the value of the alpha mode
  22927. */
  22928. private _alphaMode;
  22929. /**
  22930. * Sets the value of the alpha mode.
  22931. *
  22932. * | Value | Type | Description |
  22933. * | --- | --- | --- |
  22934. * | 0 | ALPHA_DISABLE | |
  22935. * | 1 | ALPHA_ADD | |
  22936. * | 2 | ALPHA_COMBINE | |
  22937. * | 3 | ALPHA_SUBTRACT | |
  22938. * | 4 | ALPHA_MULTIPLY | |
  22939. * | 5 | ALPHA_MAXIMIZED | |
  22940. * | 6 | ALPHA_ONEONE | |
  22941. * | 7 | ALPHA_PREMULTIPLIED | |
  22942. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22943. * | 9 | ALPHA_INTERPOLATE | |
  22944. * | 10 | ALPHA_SCREENMODE | |
  22945. *
  22946. */
  22947. /**
  22948. * Gets the value of the alpha mode
  22949. */
  22950. alphaMode: number;
  22951. /**
  22952. * Stores the state of the need depth pre-pass value
  22953. */
  22954. private _needDepthPrePass;
  22955. /**
  22956. * Sets the need depth pre-pass value
  22957. */
  22958. /**
  22959. * Gets the depth pre-pass value
  22960. */
  22961. needDepthPrePass: boolean;
  22962. /**
  22963. * Specifies if depth writing should be disabled
  22964. */
  22965. disableDepthWrite: boolean;
  22966. /**
  22967. * Specifies if depth writing should be forced
  22968. */
  22969. forceDepthWrite: boolean;
  22970. /**
  22971. * Specifies if there should be a separate pass for culling
  22972. */
  22973. separateCullingPass: boolean;
  22974. /**
  22975. * Stores the state specifing if fog should be enabled
  22976. */
  22977. private _fogEnabled;
  22978. /**
  22979. * Sets the state for enabling fog
  22980. */
  22981. /**
  22982. * Gets the value of the fog enabled state
  22983. */
  22984. fogEnabled: boolean;
  22985. /**
  22986. * Stores the size of points
  22987. */
  22988. pointSize: number;
  22989. /**
  22990. * Stores the z offset value
  22991. */
  22992. zOffset: number;
  22993. /**
  22994. * Gets a value specifying if wireframe mode is enabled
  22995. */
  22996. /**
  22997. * Sets the state of wireframe mode
  22998. */
  22999. wireframe: boolean;
  23000. /**
  23001. * Gets the value specifying if point clouds are enabled
  23002. */
  23003. /**
  23004. * Sets the state of point cloud mode
  23005. */
  23006. pointsCloud: boolean;
  23007. /**
  23008. * Gets the material fill mode
  23009. */
  23010. /**
  23011. * Sets the material fill mode
  23012. */
  23013. fillMode: number;
  23014. /**
  23015. * @hidden
  23016. * Stores the effects for the material
  23017. */
  23018. _effect: Nullable<Effect>;
  23019. /**
  23020. * @hidden
  23021. * Specifies if the material was previously ready
  23022. */
  23023. _wasPreviouslyReady: boolean;
  23024. /**
  23025. * Specifies if uniform buffers should be used
  23026. */
  23027. private _useUBO;
  23028. /**
  23029. * Stores a reference to the scene
  23030. */
  23031. private _scene;
  23032. /**
  23033. * Stores the fill mode state
  23034. */
  23035. private _fillMode;
  23036. /**
  23037. * Specifies if the depth write state should be cached
  23038. */
  23039. private _cachedDepthWriteState;
  23040. /**
  23041. * Stores the uniform buffer
  23042. */
  23043. protected _uniformBuffer: UniformBuffer;
  23044. /** @hidden */
  23045. _indexInSceneMaterialArray: number;
  23046. /** @hidden */
  23047. meshMap: Nullable<{
  23048. [id: string]: AbstractMesh | undefined;
  23049. }>;
  23050. /**
  23051. * Creates a material instance
  23052. * @param name defines the name of the material
  23053. * @param scene defines the scene to reference
  23054. * @param doNotAdd specifies if the material should be added to the scene
  23055. */
  23056. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23057. /**
  23058. * Returns a string representation of the current material
  23059. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23060. * @returns a string with material information
  23061. */
  23062. toString(fullDetails?: boolean): string;
  23063. /**
  23064. * Gets the class name of the material
  23065. * @returns a string with the class name of the material
  23066. */
  23067. getClassName(): string;
  23068. /**
  23069. * Specifies if updates for the material been locked
  23070. */
  23071. readonly isFrozen: boolean;
  23072. /**
  23073. * Locks updates for the material
  23074. */
  23075. freeze(): void;
  23076. /**
  23077. * Unlocks updates for the material
  23078. */
  23079. unfreeze(): void;
  23080. /**
  23081. * Specifies if the material is ready to be used
  23082. * @param mesh defines the mesh to check
  23083. * @param useInstances specifies if instances should be used
  23084. * @returns a boolean indicating if the material is ready to be used
  23085. */
  23086. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23087. /**
  23088. * Specifies that the submesh is ready to be used
  23089. * @param mesh defines the mesh to check
  23090. * @param subMesh defines which submesh to check
  23091. * @param useInstances specifies that instances should be used
  23092. * @returns a boolean indicating that the submesh is ready or not
  23093. */
  23094. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23095. /**
  23096. * Returns the material effect
  23097. * @returns the effect associated with the material
  23098. */
  23099. getEffect(): Nullable<Effect>;
  23100. /**
  23101. * Returns the current scene
  23102. * @returns a Scene
  23103. */
  23104. getScene(): Scene;
  23105. /**
  23106. * Specifies if the material will require alpha blending
  23107. * @returns a boolean specifying if alpha blending is needed
  23108. */
  23109. needAlphaBlending(): boolean;
  23110. /**
  23111. * Specifies if the mesh will require alpha blending
  23112. * @param mesh defines the mesh to check
  23113. * @returns a boolean specifying if alpha blending is needed for the mesh
  23114. */
  23115. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23116. /**
  23117. * Specifies if this material should be rendered in alpha test mode
  23118. * @returns a boolean specifying if an alpha test is needed.
  23119. */
  23120. needAlphaTesting(): boolean;
  23121. /**
  23122. * Gets the texture used for the alpha test
  23123. * @returns the texture to use for alpha testing
  23124. */
  23125. getAlphaTestTexture(): Nullable<BaseTexture>;
  23126. /**
  23127. * Marks the material to indicate that it needs to be re-calculated
  23128. */
  23129. markDirty(): void;
  23130. /** @hidden */
  23131. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23132. /**
  23133. * Binds the material to the mesh
  23134. * @param world defines the world transformation matrix
  23135. * @param mesh defines the mesh to bind the material to
  23136. */
  23137. bind(world: Matrix, mesh?: Mesh): void;
  23138. /**
  23139. * Binds the submesh to the material
  23140. * @param world defines the world transformation matrix
  23141. * @param mesh defines the mesh containing the submesh
  23142. * @param subMesh defines the submesh to bind the material to
  23143. */
  23144. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23145. /**
  23146. * Binds the world matrix to the material
  23147. * @param world defines the world transformation matrix
  23148. */
  23149. bindOnlyWorldMatrix(world: Matrix): void;
  23150. /**
  23151. * Binds the scene's uniform buffer to the effect.
  23152. * @param effect defines the effect to bind to the scene uniform buffer
  23153. * @param sceneUbo defines the uniform buffer storing scene data
  23154. */
  23155. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23156. /**
  23157. * Binds the view matrix to the effect
  23158. * @param effect defines the effect to bind the view matrix to
  23159. */
  23160. bindView(effect: Effect): void;
  23161. /**
  23162. * Binds the view projection matrix to the effect
  23163. * @param effect defines the effect to bind the view projection matrix to
  23164. */
  23165. bindViewProjection(effect: Effect): void;
  23166. /**
  23167. * Specifies if material alpha testing should be turned on for the mesh
  23168. * @param mesh defines the mesh to check
  23169. */
  23170. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23171. /**
  23172. * Processes to execute after binding the material to a mesh
  23173. * @param mesh defines the rendered mesh
  23174. */
  23175. protected _afterBind(mesh?: Mesh): void;
  23176. /**
  23177. * Unbinds the material from the mesh
  23178. */
  23179. unbind(): void;
  23180. /**
  23181. * Gets the active textures from the material
  23182. * @returns an array of textures
  23183. */
  23184. getActiveTextures(): BaseTexture[];
  23185. /**
  23186. * Specifies if the material uses a texture
  23187. * @param texture defines the texture to check against the material
  23188. * @returns a boolean specifying if the material uses the texture
  23189. */
  23190. hasTexture(texture: BaseTexture): boolean;
  23191. /**
  23192. * Makes a duplicate of the material, and gives it a new name
  23193. * @param name defines the new name for the duplicated material
  23194. * @returns the cloned material
  23195. */
  23196. clone(name: string): Nullable<Material>;
  23197. /**
  23198. * Gets the meshes bound to the material
  23199. * @returns an array of meshes bound to the material
  23200. */
  23201. getBindedMeshes(): AbstractMesh[];
  23202. /**
  23203. * Force shader compilation
  23204. * @param mesh defines the mesh associated with this material
  23205. * @param onCompiled defines a function to execute once the material is compiled
  23206. * @param options defines the options to configure the compilation
  23207. */
  23208. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23209. clipPlane: boolean;
  23210. }>): void;
  23211. /**
  23212. * Force shader compilation
  23213. * @param mesh defines the mesh that will use this material
  23214. * @param options defines additional options for compiling the shaders
  23215. * @returns a promise that resolves when the compilation completes
  23216. */
  23217. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23218. clipPlane: boolean;
  23219. }>): Promise<void>;
  23220. private static readonly _AllDirtyCallBack;
  23221. private static readonly _ImageProcessingDirtyCallBack;
  23222. private static readonly _TextureDirtyCallBack;
  23223. private static readonly _FresnelDirtyCallBack;
  23224. private static readonly _MiscDirtyCallBack;
  23225. private static readonly _LightsDirtyCallBack;
  23226. private static readonly _AttributeDirtyCallBack;
  23227. private static _FresnelAndMiscDirtyCallBack;
  23228. private static _TextureAndMiscDirtyCallBack;
  23229. private static readonly _DirtyCallbackArray;
  23230. private static readonly _RunDirtyCallBacks;
  23231. /**
  23232. * Marks a define in the material to indicate that it needs to be re-computed
  23233. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23234. */
  23235. markAsDirty(flag: number): void;
  23236. /**
  23237. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23238. * @param func defines a function which checks material defines against the submeshes
  23239. */
  23240. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23241. /**
  23242. * Indicates that we need to re-calculated for all submeshes
  23243. */
  23244. protected _markAllSubMeshesAsAllDirty(): void;
  23245. /**
  23246. * Indicates that image processing needs to be re-calculated for all submeshes
  23247. */
  23248. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23249. /**
  23250. * Indicates that textures need to be re-calculated for all submeshes
  23251. */
  23252. protected _markAllSubMeshesAsTexturesDirty(): void;
  23253. /**
  23254. * Indicates that fresnel needs to be re-calculated for all submeshes
  23255. */
  23256. protected _markAllSubMeshesAsFresnelDirty(): void;
  23257. /**
  23258. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23259. */
  23260. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23261. /**
  23262. * Indicates that lights need to be re-calculated for all submeshes
  23263. */
  23264. protected _markAllSubMeshesAsLightsDirty(): void;
  23265. /**
  23266. * Indicates that attributes need to be re-calculated for all submeshes
  23267. */
  23268. protected _markAllSubMeshesAsAttributesDirty(): void;
  23269. /**
  23270. * Indicates that misc needs to be re-calculated for all submeshes
  23271. */
  23272. protected _markAllSubMeshesAsMiscDirty(): void;
  23273. /**
  23274. * Indicates that textures and misc need to be re-calculated for all submeshes
  23275. */
  23276. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23277. /**
  23278. * Disposes the material
  23279. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23280. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23281. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23282. */
  23283. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23284. /** @hidden */
  23285. private releaseVertexArrayObject;
  23286. /**
  23287. * Serializes this material
  23288. * @returns the serialized material object
  23289. */
  23290. serialize(): any;
  23291. /**
  23292. * Creates a material from parsed material data
  23293. * @param parsedMaterial defines parsed material data
  23294. * @param scene defines the hosting scene
  23295. * @param rootUrl defines the root URL to use to load textures
  23296. * @returns a new material
  23297. */
  23298. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23299. }
  23300. }
  23301. declare module "babylonjs/Meshes/subMesh" {
  23302. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23303. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23304. import { Engine } from "babylonjs/Engines/engine";
  23305. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23306. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23307. import { Effect } from "babylonjs/Materials/effect";
  23308. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23309. import { Collider } from "babylonjs/Collisions/collider";
  23310. import { Material } from "babylonjs/Materials/material";
  23311. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23313. import { Mesh } from "babylonjs/Meshes/mesh";
  23314. import { Ray } from "babylonjs/Culling/ray";
  23315. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23316. /**
  23317. * Base class for submeshes
  23318. */
  23319. export class BaseSubMesh {
  23320. /** @hidden */
  23321. _materialDefines: Nullable<MaterialDefines>;
  23322. /** @hidden */
  23323. _materialEffect: Nullable<Effect>;
  23324. /**
  23325. * Gets associated effect
  23326. */
  23327. readonly effect: Nullable<Effect>;
  23328. /**
  23329. * Sets associated effect (effect used to render this submesh)
  23330. * @param effect defines the effect to associate with
  23331. * @param defines defines the set of defines used to compile this effect
  23332. */
  23333. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23334. }
  23335. /**
  23336. * Defines a subdivision inside a mesh
  23337. */
  23338. export class SubMesh extends BaseSubMesh implements ICullable {
  23339. /** the material index to use */
  23340. materialIndex: number;
  23341. /** vertex index start */
  23342. verticesStart: number;
  23343. /** vertices count */
  23344. verticesCount: number;
  23345. /** index start */
  23346. indexStart: number;
  23347. /** indices count */
  23348. indexCount: number;
  23349. /** @hidden */
  23350. _linesIndexCount: number;
  23351. private _mesh;
  23352. private _renderingMesh;
  23353. private _boundingInfo;
  23354. private _linesIndexBuffer;
  23355. /** @hidden */
  23356. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23357. /** @hidden */
  23358. _trianglePlanes: Plane[];
  23359. /** @hidden */
  23360. _lastColliderTransformMatrix: Nullable<Matrix>;
  23361. /** @hidden */
  23362. _renderId: number;
  23363. /** @hidden */
  23364. _alphaIndex: number;
  23365. /** @hidden */
  23366. _distanceToCamera: number;
  23367. /** @hidden */
  23368. _id: number;
  23369. private _currentMaterial;
  23370. /**
  23371. * Add a new submesh to a mesh
  23372. * @param materialIndex defines the material index to use
  23373. * @param verticesStart defines vertex index start
  23374. * @param verticesCount defines vertices count
  23375. * @param indexStart defines index start
  23376. * @param indexCount defines indices count
  23377. * @param mesh defines the parent mesh
  23378. * @param renderingMesh defines an optional rendering mesh
  23379. * @param createBoundingBox defines if bounding box should be created for this submesh
  23380. * @returns the new submesh
  23381. */
  23382. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23383. /**
  23384. * Creates a new submesh
  23385. * @param materialIndex defines the material index to use
  23386. * @param verticesStart defines vertex index start
  23387. * @param verticesCount defines vertices count
  23388. * @param indexStart defines index start
  23389. * @param indexCount defines indices count
  23390. * @param mesh defines the parent mesh
  23391. * @param renderingMesh defines an optional rendering mesh
  23392. * @param createBoundingBox defines if bounding box should be created for this submesh
  23393. */
  23394. constructor(
  23395. /** the material index to use */
  23396. materialIndex: number,
  23397. /** vertex index start */
  23398. verticesStart: number,
  23399. /** vertices count */
  23400. verticesCount: number,
  23401. /** index start */
  23402. indexStart: number,
  23403. /** indices count */
  23404. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23405. /**
  23406. * Returns true if this submesh covers the entire parent mesh
  23407. * @ignorenaming
  23408. */
  23409. readonly IsGlobal: boolean;
  23410. /**
  23411. * Returns the submesh BoudingInfo object
  23412. * @returns current bounding info (or mesh's one if the submesh is global)
  23413. */
  23414. getBoundingInfo(): BoundingInfo;
  23415. /**
  23416. * Sets the submesh BoundingInfo
  23417. * @param boundingInfo defines the new bounding info to use
  23418. * @returns the SubMesh
  23419. */
  23420. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23421. /**
  23422. * Returns the mesh of the current submesh
  23423. * @return the parent mesh
  23424. */
  23425. getMesh(): AbstractMesh;
  23426. /**
  23427. * Returns the rendering mesh of the submesh
  23428. * @returns the rendering mesh (could be different from parent mesh)
  23429. */
  23430. getRenderingMesh(): Mesh;
  23431. /**
  23432. * Returns the submesh material
  23433. * @returns null or the current material
  23434. */
  23435. getMaterial(): Nullable<Material>;
  23436. /**
  23437. * Sets a new updated BoundingInfo object to the submesh
  23438. * @param data defines an optional position array to use to determine the bounding info
  23439. * @returns the SubMesh
  23440. */
  23441. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23442. /** @hidden */
  23443. _checkCollision(collider: Collider): boolean;
  23444. /**
  23445. * Updates the submesh BoundingInfo
  23446. * @param world defines the world matrix to use to update the bounding info
  23447. * @returns the submesh
  23448. */
  23449. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23450. /**
  23451. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23452. * @param frustumPlanes defines the frustum planes
  23453. * @returns true if the submesh is intersecting with the frustum
  23454. */
  23455. isInFrustum(frustumPlanes: Plane[]): boolean;
  23456. /**
  23457. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23458. * @param frustumPlanes defines the frustum planes
  23459. * @returns true if the submesh is inside the frustum
  23460. */
  23461. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23462. /**
  23463. * Renders the submesh
  23464. * @param enableAlphaMode defines if alpha needs to be used
  23465. * @returns the submesh
  23466. */
  23467. render(enableAlphaMode: boolean): SubMesh;
  23468. /**
  23469. * @hidden
  23470. */
  23471. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23472. /**
  23473. * Checks if the submesh intersects with a ray
  23474. * @param ray defines the ray to test
  23475. * @returns true is the passed ray intersects the submesh bounding box
  23476. */
  23477. canIntersects(ray: Ray): boolean;
  23478. /**
  23479. * Intersects current submesh with a ray
  23480. * @param ray defines the ray to test
  23481. * @param positions defines mesh's positions array
  23482. * @param indices defines mesh's indices array
  23483. * @param fastCheck defines if only bounding info should be used
  23484. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23485. * @returns intersection info or null if no intersection
  23486. */
  23487. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23488. /** @hidden */
  23489. private _intersectLines;
  23490. /** @hidden */
  23491. private _intersectUnIndexedLines;
  23492. /** @hidden */
  23493. private _intersectTriangles;
  23494. /** @hidden */
  23495. private _intersectUnIndexedTriangles;
  23496. /** @hidden */
  23497. _rebuild(): void;
  23498. /**
  23499. * Creates a new submesh from the passed mesh
  23500. * @param newMesh defines the new hosting mesh
  23501. * @param newRenderingMesh defines an optional rendering mesh
  23502. * @returns the new submesh
  23503. */
  23504. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23505. /**
  23506. * Release associated resources
  23507. */
  23508. dispose(): void;
  23509. /**
  23510. * Gets the class name
  23511. * @returns the string "SubMesh".
  23512. */
  23513. getClassName(): string;
  23514. /**
  23515. * Creates a new submesh from indices data
  23516. * @param materialIndex the index of the main mesh material
  23517. * @param startIndex the index where to start the copy in the mesh indices array
  23518. * @param indexCount the number of indices to copy then from the startIndex
  23519. * @param mesh the main mesh to create the submesh from
  23520. * @param renderingMesh the optional rendering mesh
  23521. * @returns a new submesh
  23522. */
  23523. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23524. }
  23525. }
  23526. declare module "babylonjs/Meshes/geometry" {
  23527. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23528. import { Scene } from "babylonjs/scene";
  23529. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23530. import { Engine } from "babylonjs/Engines/engine";
  23531. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23532. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23533. import { Effect } from "babylonjs/Materials/effect";
  23534. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23536. import { Mesh } from "babylonjs/Meshes/mesh";
  23537. /**
  23538. * Class used to store geometry data (vertex buffers + index buffer)
  23539. */
  23540. export class Geometry implements IGetSetVerticesData {
  23541. /**
  23542. * Gets or sets the ID of the geometry
  23543. */
  23544. id: string;
  23545. /**
  23546. * Gets or sets the unique ID of the geometry
  23547. */
  23548. uniqueId: number;
  23549. /**
  23550. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23551. */
  23552. delayLoadState: number;
  23553. /**
  23554. * Gets the file containing the data to load when running in delay load state
  23555. */
  23556. delayLoadingFile: Nullable<string>;
  23557. /**
  23558. * Callback called when the geometry is updated
  23559. */
  23560. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23561. private _scene;
  23562. private _engine;
  23563. private _meshes;
  23564. private _totalVertices;
  23565. /** @hidden */
  23566. _indices: IndicesArray;
  23567. /** @hidden */
  23568. _vertexBuffers: {
  23569. [key: string]: VertexBuffer;
  23570. };
  23571. private _isDisposed;
  23572. private _extend;
  23573. private _boundingBias;
  23574. /** @hidden */
  23575. _delayInfo: Array<string>;
  23576. private _indexBuffer;
  23577. private _indexBufferIsUpdatable;
  23578. /** @hidden */
  23579. _boundingInfo: Nullable<BoundingInfo>;
  23580. /** @hidden */
  23581. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23582. /** @hidden */
  23583. _softwareSkinningFrameId: number;
  23584. private _vertexArrayObjects;
  23585. private _updatable;
  23586. /** @hidden */
  23587. _positions: Nullable<Vector3[]>;
  23588. /**
  23589. * 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
  23590. */
  23591. /**
  23592. * 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
  23593. */
  23594. boundingBias: Vector2;
  23595. /**
  23596. * Static function used to attach a new empty geometry to a mesh
  23597. * @param mesh defines the mesh to attach the geometry to
  23598. * @returns the new Geometry
  23599. */
  23600. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23601. /**
  23602. * Creates a new geometry
  23603. * @param id defines the unique ID
  23604. * @param scene defines the hosting scene
  23605. * @param vertexData defines the VertexData used to get geometry data
  23606. * @param updatable defines if geometry must be updatable (false by default)
  23607. * @param mesh defines the mesh that will be associated with the geometry
  23608. */
  23609. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23610. /**
  23611. * Gets the current extend of the geometry
  23612. */
  23613. readonly extend: {
  23614. minimum: Vector3;
  23615. maximum: Vector3;
  23616. };
  23617. /**
  23618. * Gets the hosting scene
  23619. * @returns the hosting Scene
  23620. */
  23621. getScene(): Scene;
  23622. /**
  23623. * Gets the hosting engine
  23624. * @returns the hosting Engine
  23625. */
  23626. getEngine(): Engine;
  23627. /**
  23628. * Defines if the geometry is ready to use
  23629. * @returns true if the geometry is ready to be used
  23630. */
  23631. isReady(): boolean;
  23632. /**
  23633. * Gets a value indicating that the geometry should not be serialized
  23634. */
  23635. readonly doNotSerialize: boolean;
  23636. /** @hidden */
  23637. _rebuild(): void;
  23638. /**
  23639. * Affects all geometry data in one call
  23640. * @param vertexData defines the geometry data
  23641. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23642. */
  23643. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23644. /**
  23645. * Set specific vertex data
  23646. * @param kind defines the data kind (Position, normal, etc...)
  23647. * @param data defines the vertex data to use
  23648. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23649. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23650. */
  23651. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23652. /**
  23653. * Removes a specific vertex data
  23654. * @param kind defines the data kind (Position, normal, etc...)
  23655. */
  23656. removeVerticesData(kind: string): void;
  23657. /**
  23658. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23659. * @param buffer defines the vertex buffer to use
  23660. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23661. */
  23662. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23663. /**
  23664. * Update a specific vertex buffer
  23665. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23666. * It will do nothing if the buffer is not updatable
  23667. * @param kind defines the data kind (Position, normal, etc...)
  23668. * @param data defines the data to use
  23669. * @param offset defines the offset in the target buffer where to store the data
  23670. * @param useBytes set to true if the offset is in bytes
  23671. */
  23672. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23673. /**
  23674. * Update a specific vertex buffer
  23675. * This function will create a new buffer if the current one is not updatable
  23676. * @param kind defines the data kind (Position, normal, etc...)
  23677. * @param data defines the data to use
  23678. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23679. */
  23680. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23681. private _updateBoundingInfo;
  23682. /** @hidden */
  23683. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23684. /**
  23685. * Gets total number of vertices
  23686. * @returns the total number of vertices
  23687. */
  23688. getTotalVertices(): number;
  23689. /**
  23690. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23691. * @param kind defines the data kind (Position, normal, etc...)
  23692. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23693. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23694. * @returns a float array containing vertex data
  23695. */
  23696. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23697. /**
  23698. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23699. * @param kind defines the data kind (Position, normal, etc...)
  23700. * @returns true if the vertex buffer with the specified kind is updatable
  23701. */
  23702. isVertexBufferUpdatable(kind: string): boolean;
  23703. /**
  23704. * Gets a specific vertex buffer
  23705. * @param kind defines the data kind (Position, normal, etc...)
  23706. * @returns a VertexBuffer
  23707. */
  23708. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23709. /**
  23710. * Returns all vertex buffers
  23711. * @return an object holding all vertex buffers indexed by kind
  23712. */
  23713. getVertexBuffers(): Nullable<{
  23714. [key: string]: VertexBuffer;
  23715. }>;
  23716. /**
  23717. * Gets a boolean indicating if specific vertex buffer is present
  23718. * @param kind defines the data kind (Position, normal, etc...)
  23719. * @returns true if data is present
  23720. */
  23721. isVerticesDataPresent(kind: string): boolean;
  23722. /**
  23723. * Gets a list of all attached data kinds (Position, normal, etc...)
  23724. * @returns a list of string containing all kinds
  23725. */
  23726. getVerticesDataKinds(): string[];
  23727. /**
  23728. * Update index buffer
  23729. * @param indices defines the indices to store in the index buffer
  23730. * @param offset defines the offset in the target buffer where to store the data
  23731. * @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)
  23732. */
  23733. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23734. /**
  23735. * Creates a new index buffer
  23736. * @param indices defines the indices to store in the index buffer
  23737. * @param totalVertices defines the total number of vertices (could be null)
  23738. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23739. */
  23740. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23741. /**
  23742. * Return the total number of indices
  23743. * @returns the total number of indices
  23744. */
  23745. getTotalIndices(): number;
  23746. /**
  23747. * Gets the index buffer array
  23748. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23749. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23750. * @returns the index buffer array
  23751. */
  23752. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23753. /**
  23754. * Gets the index buffer
  23755. * @return the index buffer
  23756. */
  23757. getIndexBuffer(): Nullable<DataBuffer>;
  23758. /** @hidden */
  23759. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23760. /**
  23761. * Release the associated resources for a specific mesh
  23762. * @param mesh defines the source mesh
  23763. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23764. */
  23765. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23766. /**
  23767. * Apply current geometry to a given mesh
  23768. * @param mesh defines the mesh to apply geometry to
  23769. */
  23770. applyToMesh(mesh: Mesh): void;
  23771. private _updateExtend;
  23772. private _applyToMesh;
  23773. private notifyUpdate;
  23774. /**
  23775. * Load the geometry if it was flagged as delay loaded
  23776. * @param scene defines the hosting scene
  23777. * @param onLoaded defines a callback called when the geometry is loaded
  23778. */
  23779. load(scene: Scene, onLoaded?: () => void): void;
  23780. private _queueLoad;
  23781. /**
  23782. * Invert the geometry to move from a right handed system to a left handed one.
  23783. */
  23784. toLeftHanded(): void;
  23785. /** @hidden */
  23786. _resetPointsArrayCache(): void;
  23787. /** @hidden */
  23788. _generatePointsArray(): boolean;
  23789. /**
  23790. * Gets a value indicating if the geometry is disposed
  23791. * @returns true if the geometry was disposed
  23792. */
  23793. isDisposed(): boolean;
  23794. private _disposeVertexArrayObjects;
  23795. /**
  23796. * Free all associated resources
  23797. */
  23798. dispose(): void;
  23799. /**
  23800. * Clone the current geometry into a new geometry
  23801. * @param id defines the unique ID of the new geometry
  23802. * @returns a new geometry object
  23803. */
  23804. copy(id: string): Geometry;
  23805. /**
  23806. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23807. * @return a JSON representation of the current geometry data (without the vertices data)
  23808. */
  23809. serialize(): any;
  23810. private toNumberArray;
  23811. /**
  23812. * Serialize all vertices data into a JSON oject
  23813. * @returns a JSON representation of the current geometry data
  23814. */
  23815. serializeVerticeData(): any;
  23816. /**
  23817. * Extracts a clone of a mesh geometry
  23818. * @param mesh defines the source mesh
  23819. * @param id defines the unique ID of the new geometry object
  23820. * @returns the new geometry object
  23821. */
  23822. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23823. /**
  23824. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23825. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23826. * Be aware Math.random() could cause collisions, but:
  23827. * "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"
  23828. * @returns a string containing a new GUID
  23829. */
  23830. static RandomId(): string;
  23831. /** @hidden */
  23832. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23833. private static _CleanMatricesWeights;
  23834. /**
  23835. * Create a new geometry from persisted data (Using .babylon file format)
  23836. * @param parsedVertexData defines the persisted data
  23837. * @param scene defines the hosting scene
  23838. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23839. * @returns the new geometry object
  23840. */
  23841. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23842. }
  23843. }
  23844. declare module "babylonjs/Meshes/mesh.vertexData" {
  23845. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23846. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23847. import { Geometry } from "babylonjs/Meshes/geometry";
  23848. import { Mesh } from "babylonjs/Meshes/mesh";
  23849. /**
  23850. * Define an interface for all classes that will get and set the data on vertices
  23851. */
  23852. export interface IGetSetVerticesData {
  23853. /**
  23854. * Gets a boolean indicating if specific vertex data is present
  23855. * @param kind defines the vertex data kind to use
  23856. * @returns true is data kind is present
  23857. */
  23858. isVerticesDataPresent(kind: string): boolean;
  23859. /**
  23860. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23861. * @param kind defines the data kind (Position, normal, etc...)
  23862. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23863. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23864. * @returns a float array containing vertex data
  23865. */
  23866. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23867. /**
  23868. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23869. * @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.
  23870. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23871. * @returns the indices array or an empty array if the mesh has no geometry
  23872. */
  23873. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23874. /**
  23875. * Set specific vertex data
  23876. * @param kind defines the data kind (Position, normal, etc...)
  23877. * @param data defines the vertex data to use
  23878. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23879. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23880. */
  23881. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23882. /**
  23883. * Update a specific associated vertex buffer
  23884. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23885. * - VertexBuffer.PositionKind
  23886. * - VertexBuffer.UVKind
  23887. * - VertexBuffer.UV2Kind
  23888. * - VertexBuffer.UV3Kind
  23889. * - VertexBuffer.UV4Kind
  23890. * - VertexBuffer.UV5Kind
  23891. * - VertexBuffer.UV6Kind
  23892. * - VertexBuffer.ColorKind
  23893. * - VertexBuffer.MatricesIndicesKind
  23894. * - VertexBuffer.MatricesIndicesExtraKind
  23895. * - VertexBuffer.MatricesWeightsKind
  23896. * - VertexBuffer.MatricesWeightsExtraKind
  23897. * @param data defines the data source
  23898. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23899. * @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)
  23900. */
  23901. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23902. /**
  23903. * Creates a new index buffer
  23904. * @param indices defines the indices to store in the index buffer
  23905. * @param totalVertices defines the total number of vertices (could be null)
  23906. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23907. */
  23908. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23909. }
  23910. /**
  23911. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23912. */
  23913. export class VertexData {
  23914. /**
  23915. * Mesh side orientation : usually the external or front surface
  23916. */
  23917. static readonly FRONTSIDE: number;
  23918. /**
  23919. * Mesh side orientation : usually the internal or back surface
  23920. */
  23921. static readonly BACKSIDE: number;
  23922. /**
  23923. * Mesh side orientation : both internal and external or front and back surfaces
  23924. */
  23925. static readonly DOUBLESIDE: number;
  23926. /**
  23927. * Mesh side orientation : by default, `FRONTSIDE`
  23928. */
  23929. static readonly DEFAULTSIDE: number;
  23930. /**
  23931. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23932. */
  23933. positions: Nullable<FloatArray>;
  23934. /**
  23935. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23936. */
  23937. normals: Nullable<FloatArray>;
  23938. /**
  23939. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23940. */
  23941. tangents: Nullable<FloatArray>;
  23942. /**
  23943. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23944. */
  23945. uvs: Nullable<FloatArray>;
  23946. /**
  23947. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23948. */
  23949. uvs2: Nullable<FloatArray>;
  23950. /**
  23951. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23952. */
  23953. uvs3: Nullable<FloatArray>;
  23954. /**
  23955. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23956. */
  23957. uvs4: Nullable<FloatArray>;
  23958. /**
  23959. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23960. */
  23961. uvs5: Nullable<FloatArray>;
  23962. /**
  23963. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23964. */
  23965. uvs6: Nullable<FloatArray>;
  23966. /**
  23967. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23968. */
  23969. colors: Nullable<FloatArray>;
  23970. /**
  23971. * 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).
  23972. */
  23973. matricesIndices: Nullable<FloatArray>;
  23974. /**
  23975. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23976. */
  23977. matricesWeights: Nullable<FloatArray>;
  23978. /**
  23979. * An array extending the number of possible indices
  23980. */
  23981. matricesIndicesExtra: Nullable<FloatArray>;
  23982. /**
  23983. * An array extending the number of possible weights when the number of indices is extended
  23984. */
  23985. matricesWeightsExtra: Nullable<FloatArray>;
  23986. /**
  23987. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23988. */
  23989. indices: Nullable<IndicesArray>;
  23990. /**
  23991. * Uses the passed data array to set the set the values for the specified kind of data
  23992. * @param data a linear array of floating numbers
  23993. * @param kind the type of data that is being set, eg positions, colors etc
  23994. */
  23995. set(data: FloatArray, kind: string): void;
  23996. /**
  23997. * Associates the vertexData to the passed Mesh.
  23998. * Sets it as updatable or not (default `false`)
  23999. * @param mesh the mesh the vertexData is applied to
  24000. * @param updatable when used and having the value true allows new data to update the vertexData
  24001. * @returns the VertexData
  24002. */
  24003. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  24004. /**
  24005. * Associates the vertexData to the passed Geometry.
  24006. * Sets it as updatable or not (default `false`)
  24007. * @param geometry the geometry the vertexData is applied to
  24008. * @param updatable when used and having the value true allows new data to update the vertexData
  24009. * @returns VertexData
  24010. */
  24011. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  24012. /**
  24013. * Updates the associated mesh
  24014. * @param mesh the mesh to be updated
  24015. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24016. * @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
  24017. * @returns VertexData
  24018. */
  24019. updateMesh(mesh: Mesh): VertexData;
  24020. /**
  24021. * Updates the associated geometry
  24022. * @param geometry the geometry to be updated
  24023. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24024. * @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
  24025. * @returns VertexData.
  24026. */
  24027. updateGeometry(geometry: Geometry): VertexData;
  24028. private _applyTo;
  24029. private _update;
  24030. /**
  24031. * Transforms each position and each normal of the vertexData according to the passed Matrix
  24032. * @param matrix the transforming matrix
  24033. * @returns the VertexData
  24034. */
  24035. transform(matrix: Matrix): VertexData;
  24036. /**
  24037. * Merges the passed VertexData into the current one
  24038. * @param other the VertexData to be merged into the current one
  24039. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  24040. * @returns the modified VertexData
  24041. */
  24042. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  24043. private _mergeElement;
  24044. private _validate;
  24045. /**
  24046. * Serializes the VertexData
  24047. * @returns a serialized object
  24048. */
  24049. serialize(): any;
  24050. /**
  24051. * Extracts the vertexData from a mesh
  24052. * @param mesh the mesh from which to extract the VertexData
  24053. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  24054. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24055. * @returns the object VertexData associated to the passed mesh
  24056. */
  24057. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24058. /**
  24059. * Extracts the vertexData from the geometry
  24060. * @param geometry the geometry from which to extract the VertexData
  24061. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  24062. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24063. * @returns the object VertexData associated to the passed mesh
  24064. */
  24065. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24066. private static _ExtractFrom;
  24067. /**
  24068. * Creates the VertexData for a Ribbon
  24069. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  24070. * * pathArray array of paths, each of which an array of successive Vector3
  24071. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  24072. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  24073. * * 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
  24074. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24075. * * 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)
  24076. * * 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)
  24077. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  24078. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  24079. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  24080. * @returns the VertexData of the ribbon
  24081. */
  24082. static CreateRibbon(options: {
  24083. pathArray: Vector3[][];
  24084. closeArray?: boolean;
  24085. closePath?: boolean;
  24086. offset?: number;
  24087. sideOrientation?: number;
  24088. frontUVs?: Vector4;
  24089. backUVs?: Vector4;
  24090. invertUV?: boolean;
  24091. uvs?: Vector2[];
  24092. colors?: Color4[];
  24093. }): VertexData;
  24094. /**
  24095. * Creates the VertexData for a box
  24096. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24097. * * size sets the width, height and depth of the box to the value of size, optional default 1
  24098. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  24099. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  24100. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  24101. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24102. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24103. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24104. * * 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)
  24105. * * 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)
  24106. * @returns the VertexData of the box
  24107. */
  24108. static CreateBox(options: {
  24109. size?: number;
  24110. width?: number;
  24111. height?: number;
  24112. depth?: number;
  24113. faceUV?: Vector4[];
  24114. faceColors?: Color4[];
  24115. sideOrientation?: number;
  24116. frontUVs?: Vector4;
  24117. backUVs?: Vector4;
  24118. }): VertexData;
  24119. /**
  24120. * Creates the VertexData for a tiled box
  24121. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24122. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24123. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24124. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24125. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24126. * @returns the VertexData of the box
  24127. */
  24128. static CreateTiledBox(options: {
  24129. pattern?: number;
  24130. width?: number;
  24131. height?: number;
  24132. depth?: number;
  24133. tileSize?: number;
  24134. tileWidth?: number;
  24135. tileHeight?: number;
  24136. alignHorizontal?: number;
  24137. alignVertical?: number;
  24138. faceUV?: Vector4[];
  24139. faceColors?: Color4[];
  24140. sideOrientation?: number;
  24141. }): VertexData;
  24142. /**
  24143. * Creates the VertexData for a tiled plane
  24144. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24145. * * pattern a limited pattern arrangement depending on the number
  24146. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24147. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24148. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24149. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24150. * * 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)
  24151. * * 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)
  24152. * @returns the VertexData of the tiled plane
  24153. */
  24154. static CreateTiledPlane(options: {
  24155. pattern?: number;
  24156. tileSize?: number;
  24157. tileWidth?: number;
  24158. tileHeight?: number;
  24159. size?: number;
  24160. width?: number;
  24161. height?: number;
  24162. alignHorizontal?: number;
  24163. alignVertical?: number;
  24164. sideOrientation?: number;
  24165. frontUVs?: Vector4;
  24166. backUVs?: Vector4;
  24167. }): VertexData;
  24168. /**
  24169. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24170. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24171. * * segments sets the number of horizontal strips optional, default 32
  24172. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24173. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24174. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24175. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24176. * * 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
  24177. * * 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
  24178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24179. * * 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)
  24180. * * 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)
  24181. * @returns the VertexData of the ellipsoid
  24182. */
  24183. static CreateSphere(options: {
  24184. segments?: number;
  24185. diameter?: number;
  24186. diameterX?: number;
  24187. diameterY?: number;
  24188. diameterZ?: number;
  24189. arc?: number;
  24190. slice?: number;
  24191. sideOrientation?: number;
  24192. frontUVs?: Vector4;
  24193. backUVs?: Vector4;
  24194. }): VertexData;
  24195. /**
  24196. * Creates the VertexData for a cylinder, cone or prism
  24197. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24198. * * height sets the height (y direction) of the cylinder, optional, default 2
  24199. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24200. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24201. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24202. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24203. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24204. * * 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
  24205. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24206. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24207. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24208. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24210. * * 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)
  24211. * * 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)
  24212. * @returns the VertexData of the cylinder, cone or prism
  24213. */
  24214. static CreateCylinder(options: {
  24215. height?: number;
  24216. diameterTop?: number;
  24217. diameterBottom?: number;
  24218. diameter?: number;
  24219. tessellation?: number;
  24220. subdivisions?: number;
  24221. arc?: number;
  24222. faceColors?: Color4[];
  24223. faceUV?: Vector4[];
  24224. hasRings?: boolean;
  24225. enclose?: boolean;
  24226. sideOrientation?: number;
  24227. frontUVs?: Vector4;
  24228. backUVs?: Vector4;
  24229. }): VertexData;
  24230. /**
  24231. * Creates the VertexData for a torus
  24232. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24233. * * diameter the diameter of the torus, optional default 1
  24234. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24235. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24237. * * 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)
  24238. * * 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)
  24239. * @returns the VertexData of the torus
  24240. */
  24241. static CreateTorus(options: {
  24242. diameter?: number;
  24243. thickness?: number;
  24244. tessellation?: number;
  24245. sideOrientation?: number;
  24246. frontUVs?: Vector4;
  24247. backUVs?: Vector4;
  24248. }): VertexData;
  24249. /**
  24250. * Creates the VertexData of the LineSystem
  24251. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24252. * - lines an array of lines, each line being an array of successive Vector3
  24253. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24254. * @returns the VertexData of the LineSystem
  24255. */
  24256. static CreateLineSystem(options: {
  24257. lines: Vector3[][];
  24258. colors?: Nullable<Color4[][]>;
  24259. }): VertexData;
  24260. /**
  24261. * Create the VertexData for a DashedLines
  24262. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24263. * - points an array successive Vector3
  24264. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24265. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24266. * - dashNb the intended total number of dashes, optional, default 200
  24267. * @returns the VertexData for the DashedLines
  24268. */
  24269. static CreateDashedLines(options: {
  24270. points: Vector3[];
  24271. dashSize?: number;
  24272. gapSize?: number;
  24273. dashNb?: number;
  24274. }): VertexData;
  24275. /**
  24276. * Creates the VertexData for a Ground
  24277. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24278. * - width the width (x direction) of the ground, optional, default 1
  24279. * - height the height (z direction) of the ground, optional, default 1
  24280. * - subdivisions the number of subdivisions per side, optional, default 1
  24281. * @returns the VertexData of the Ground
  24282. */
  24283. static CreateGround(options: {
  24284. width?: number;
  24285. height?: number;
  24286. subdivisions?: number;
  24287. subdivisionsX?: number;
  24288. subdivisionsY?: number;
  24289. }): VertexData;
  24290. /**
  24291. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24292. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24293. * * xmin the ground minimum X coordinate, optional, default -1
  24294. * * zmin the ground minimum Z coordinate, optional, default -1
  24295. * * xmax the ground maximum X coordinate, optional, default 1
  24296. * * zmax the ground maximum Z coordinate, optional, default 1
  24297. * * 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}
  24298. * * 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}
  24299. * @returns the VertexData of the TiledGround
  24300. */
  24301. static CreateTiledGround(options: {
  24302. xmin: number;
  24303. zmin: number;
  24304. xmax: number;
  24305. zmax: number;
  24306. subdivisions?: {
  24307. w: number;
  24308. h: number;
  24309. };
  24310. precision?: {
  24311. w: number;
  24312. h: number;
  24313. };
  24314. }): VertexData;
  24315. /**
  24316. * Creates the VertexData of the Ground designed from a heightmap
  24317. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24318. * * width the width (x direction) of the ground
  24319. * * height the height (z direction) of the ground
  24320. * * subdivisions the number of subdivisions per side
  24321. * * minHeight the minimum altitude on the ground, optional, default 0
  24322. * * maxHeight the maximum altitude on the ground, optional default 1
  24323. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24324. * * buffer the array holding the image color data
  24325. * * bufferWidth the width of image
  24326. * * bufferHeight the height of image
  24327. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24328. * @returns the VertexData of the Ground designed from a heightmap
  24329. */
  24330. static CreateGroundFromHeightMap(options: {
  24331. width: number;
  24332. height: number;
  24333. subdivisions: number;
  24334. minHeight: number;
  24335. maxHeight: number;
  24336. colorFilter: Color3;
  24337. buffer: Uint8Array;
  24338. bufferWidth: number;
  24339. bufferHeight: number;
  24340. alphaFilter: number;
  24341. }): VertexData;
  24342. /**
  24343. * Creates the VertexData for a Plane
  24344. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24345. * * size sets the width and height of the plane to the value of size, optional default 1
  24346. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24347. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24348. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24349. * * 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)
  24350. * * 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)
  24351. * @returns the VertexData of the box
  24352. */
  24353. static CreatePlane(options: {
  24354. size?: number;
  24355. width?: number;
  24356. height?: number;
  24357. sideOrientation?: number;
  24358. frontUVs?: Vector4;
  24359. backUVs?: Vector4;
  24360. }): VertexData;
  24361. /**
  24362. * Creates the VertexData of the Disc or regular Polygon
  24363. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24364. * * radius the radius of the disc, optional default 0.5
  24365. * * tessellation the number of polygon sides, optional, default 64
  24366. * * 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
  24367. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24368. * * 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)
  24369. * * 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)
  24370. * @returns the VertexData of the box
  24371. */
  24372. static CreateDisc(options: {
  24373. radius?: number;
  24374. tessellation?: number;
  24375. arc?: number;
  24376. sideOrientation?: number;
  24377. frontUVs?: Vector4;
  24378. backUVs?: Vector4;
  24379. }): VertexData;
  24380. /**
  24381. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24382. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24383. * @param polygon a mesh built from polygonTriangulation.build()
  24384. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24385. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24386. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24387. * @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)
  24388. * @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)
  24389. * @returns the VertexData of the Polygon
  24390. */
  24391. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24392. /**
  24393. * Creates the VertexData of the IcoSphere
  24394. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24395. * * radius the radius of the IcoSphere, optional default 1
  24396. * * radiusX allows stretching in the x direction, optional, default radius
  24397. * * radiusY allows stretching in the y direction, optional, default radius
  24398. * * radiusZ allows stretching in the z direction, optional, default radius
  24399. * * flat when true creates a flat shaded mesh, optional, default true
  24400. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24402. * * 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)
  24403. * * 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)
  24404. * @returns the VertexData of the IcoSphere
  24405. */
  24406. static CreateIcoSphere(options: {
  24407. radius?: number;
  24408. radiusX?: number;
  24409. radiusY?: number;
  24410. radiusZ?: number;
  24411. flat?: boolean;
  24412. subdivisions?: number;
  24413. sideOrientation?: number;
  24414. frontUVs?: Vector4;
  24415. backUVs?: Vector4;
  24416. }): VertexData;
  24417. /**
  24418. * Creates the VertexData for a Polyhedron
  24419. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24420. * * type provided types are:
  24421. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24422. * * 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)
  24423. * * size the size of the IcoSphere, optional default 1
  24424. * * sizeX allows stretching in the x direction, optional, default size
  24425. * * sizeY allows stretching in the y direction, optional, default size
  24426. * * sizeZ allows stretching in the z direction, optional, default size
  24427. * * 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
  24428. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24429. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24430. * * flat when true creates a flat shaded mesh, optional, default true
  24431. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24433. * * 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)
  24434. * * 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)
  24435. * @returns the VertexData of the Polyhedron
  24436. */
  24437. static CreatePolyhedron(options: {
  24438. type?: number;
  24439. size?: number;
  24440. sizeX?: number;
  24441. sizeY?: number;
  24442. sizeZ?: number;
  24443. custom?: any;
  24444. faceUV?: Vector4[];
  24445. faceColors?: Color4[];
  24446. flat?: boolean;
  24447. sideOrientation?: number;
  24448. frontUVs?: Vector4;
  24449. backUVs?: Vector4;
  24450. }): VertexData;
  24451. /**
  24452. * Creates the VertexData for a TorusKnot
  24453. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24454. * * radius the radius of the torus knot, optional, default 2
  24455. * * tube the thickness of the tube, optional, default 0.5
  24456. * * radialSegments the number of sides on each tube segments, optional, default 32
  24457. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24458. * * p the number of windings around the z axis, optional, default 2
  24459. * * q the number of windings around the x axis, optional, default 3
  24460. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24461. * * 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)
  24462. * * 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)
  24463. * @returns the VertexData of the Torus Knot
  24464. */
  24465. static CreateTorusKnot(options: {
  24466. radius?: number;
  24467. tube?: number;
  24468. radialSegments?: number;
  24469. tubularSegments?: number;
  24470. p?: number;
  24471. q?: number;
  24472. sideOrientation?: number;
  24473. frontUVs?: Vector4;
  24474. backUVs?: Vector4;
  24475. }): VertexData;
  24476. /**
  24477. * Compute normals for given positions and indices
  24478. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24479. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24480. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24481. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24482. * * facetNormals : optional array of facet normals (vector3)
  24483. * * facetPositions : optional array of facet positions (vector3)
  24484. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24485. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24486. * * bInfo : optional bounding info, required for facetPartitioning computation
  24487. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24488. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24489. * * useRightHandedSystem: optional boolean to for right handed system computation
  24490. * * depthSort : optional boolean to enable the facet depth sort computation
  24491. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24492. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24493. */
  24494. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24495. facetNormals?: any;
  24496. facetPositions?: any;
  24497. facetPartitioning?: any;
  24498. ratio?: number;
  24499. bInfo?: any;
  24500. bbSize?: Vector3;
  24501. subDiv?: any;
  24502. useRightHandedSystem?: boolean;
  24503. depthSort?: boolean;
  24504. distanceTo?: Vector3;
  24505. depthSortedFacets?: any;
  24506. }): void;
  24507. /** @hidden */
  24508. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24509. /**
  24510. * Applies VertexData created from the imported parameters to the geometry
  24511. * @param parsedVertexData the parsed data from an imported file
  24512. * @param geometry the geometry to apply the VertexData to
  24513. */
  24514. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24515. }
  24516. }
  24517. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24518. import { Nullable } from "babylonjs/types";
  24519. import { Scene } from "babylonjs/scene";
  24520. import { Vector4 } from "babylonjs/Maths/math";
  24521. import { Mesh } from "babylonjs/Meshes/mesh";
  24522. /**
  24523. * Class containing static functions to help procedurally build meshes
  24524. */
  24525. export class DiscBuilder {
  24526. /**
  24527. * Creates a plane polygonal mesh. By default, this is a disc
  24528. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24529. * * 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
  24530. * * 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
  24531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24534. * @param name defines the name of the mesh
  24535. * @param options defines the options used to create the mesh
  24536. * @param scene defines the hosting scene
  24537. * @returns the plane polygonal mesh
  24538. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24539. */
  24540. static CreateDisc(name: string, options: {
  24541. radius?: number;
  24542. tessellation?: number;
  24543. arc?: number;
  24544. updatable?: boolean;
  24545. sideOrientation?: number;
  24546. frontUVs?: Vector4;
  24547. backUVs?: Vector4;
  24548. }, scene?: Nullable<Scene>): Mesh;
  24549. }
  24550. }
  24551. declare module "babylonjs/Particles/solidParticleSystem" {
  24552. import { Vector3 } from "babylonjs/Maths/math";
  24553. import { Mesh } from "babylonjs/Meshes/mesh";
  24554. import { Scene, IDisposable } from "babylonjs/scene";
  24555. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24556. /**
  24557. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24558. *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.
  24559. * The SPS is also a particle system. It provides some methods to manage the particles.
  24560. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24561. *
  24562. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24563. */
  24564. export class SolidParticleSystem implements IDisposable {
  24565. /**
  24566. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24567. * Example : var p = SPS.particles[i];
  24568. */
  24569. particles: SolidParticle[];
  24570. /**
  24571. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24572. */
  24573. nbParticles: number;
  24574. /**
  24575. * If the particles must ever face the camera (default false). Useful for planar particles.
  24576. */
  24577. billboard: boolean;
  24578. /**
  24579. * Recompute normals when adding a shape
  24580. */
  24581. recomputeNormals: boolean;
  24582. /**
  24583. * This a counter ofr your own usage. It's not set by any SPS functions.
  24584. */
  24585. counter: number;
  24586. /**
  24587. * The SPS name. This name is also given to the underlying mesh.
  24588. */
  24589. name: string;
  24590. /**
  24591. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24592. */
  24593. mesh: Mesh;
  24594. /**
  24595. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24596. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24597. */
  24598. vars: any;
  24599. /**
  24600. * This array is populated when the SPS is set as 'pickable'.
  24601. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24602. * Each element of this array is an object `{idx: int, faceId: int}`.
  24603. * `idx` is the picked particle index in the `SPS.particles` array
  24604. * `faceId` is the picked face index counted within this particle.
  24605. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24606. */
  24607. pickedParticles: {
  24608. idx: number;
  24609. faceId: number;
  24610. }[];
  24611. /**
  24612. * This array is populated when `enableDepthSort` is set to true.
  24613. * Each element of this array is an instance of the class DepthSortedParticle.
  24614. */
  24615. depthSortedParticles: DepthSortedParticle[];
  24616. /**
  24617. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24618. * @hidden
  24619. */
  24620. _bSphereOnly: boolean;
  24621. /**
  24622. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24623. * @hidden
  24624. */
  24625. _bSphereRadiusFactor: number;
  24626. private _scene;
  24627. private _positions;
  24628. private _indices;
  24629. private _normals;
  24630. private _colors;
  24631. private _uvs;
  24632. private _indices32;
  24633. private _positions32;
  24634. private _normals32;
  24635. private _fixedNormal32;
  24636. private _colors32;
  24637. private _uvs32;
  24638. private _index;
  24639. private _updatable;
  24640. private _pickable;
  24641. private _isVisibilityBoxLocked;
  24642. private _alwaysVisible;
  24643. private _depthSort;
  24644. private _shapeCounter;
  24645. private _copy;
  24646. private _color;
  24647. private _computeParticleColor;
  24648. private _computeParticleTexture;
  24649. private _computeParticleRotation;
  24650. private _computeParticleVertex;
  24651. private _computeBoundingBox;
  24652. private _depthSortParticles;
  24653. private _camera;
  24654. private _mustUnrotateFixedNormals;
  24655. private _particlesIntersect;
  24656. private _needs32Bits;
  24657. /**
  24658. * Creates a SPS (Solid Particle System) object.
  24659. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24660. * @param scene (Scene) is the scene in which the SPS is added.
  24661. * @param options defines the options of the sps e.g.
  24662. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24663. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24664. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24665. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24666. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24667. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24668. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24669. */
  24670. constructor(name: string, scene: Scene, options?: {
  24671. updatable?: boolean;
  24672. isPickable?: boolean;
  24673. enableDepthSort?: boolean;
  24674. particleIntersection?: boolean;
  24675. boundingSphereOnly?: boolean;
  24676. bSphereRadiusFactor?: number;
  24677. });
  24678. /**
  24679. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24680. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24681. * @returns the created mesh
  24682. */
  24683. buildMesh(): Mesh;
  24684. /**
  24685. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24686. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24687. * Thus the particles generated from `digest()` have their property `position` set yet.
  24688. * @param mesh ( Mesh ) is the mesh to be digested
  24689. * @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
  24690. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24691. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24692. * @returns the current SPS
  24693. */
  24694. digest(mesh: Mesh, options?: {
  24695. facetNb?: number;
  24696. number?: number;
  24697. delta?: number;
  24698. }): SolidParticleSystem;
  24699. private _unrotateFixedNormals;
  24700. private _resetCopy;
  24701. private _meshBuilder;
  24702. private _posToShape;
  24703. private _uvsToShapeUV;
  24704. private _addParticle;
  24705. /**
  24706. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24707. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24708. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24709. * @param nb (positive integer) the number of particles to be created from this model
  24710. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24711. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24712. * @returns the number of shapes in the system
  24713. */
  24714. addShape(mesh: Mesh, nb: number, options?: {
  24715. positionFunction?: any;
  24716. vertexFunction?: any;
  24717. }): number;
  24718. private _rebuildParticle;
  24719. /**
  24720. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24721. * @returns the SPS.
  24722. */
  24723. rebuildMesh(): SolidParticleSystem;
  24724. /**
  24725. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24726. * This method calls `updateParticle()` for each particle of the SPS.
  24727. * For an animated SPS, it is usually called within the render loop.
  24728. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24729. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24730. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24731. * @returns the SPS.
  24732. */
  24733. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24734. /**
  24735. * Disposes the SPS.
  24736. */
  24737. dispose(): void;
  24738. /**
  24739. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24740. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24741. * @returns the SPS.
  24742. */
  24743. refreshVisibleSize(): SolidParticleSystem;
  24744. /**
  24745. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24746. * @param size the size (float) of the visibility box
  24747. * note : this doesn't lock the SPS mesh bounding box.
  24748. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24749. */
  24750. setVisibilityBox(size: number): void;
  24751. /**
  24752. * Gets whether the SPS as always visible or not
  24753. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24754. */
  24755. /**
  24756. * Sets the SPS as always visible or not
  24757. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24758. */
  24759. isAlwaysVisible: boolean;
  24760. /**
  24761. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24762. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24763. */
  24764. /**
  24765. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24766. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24767. */
  24768. isVisibilityBoxLocked: boolean;
  24769. /**
  24770. * Tells to `setParticles()` to compute the particle rotations or not.
  24771. * Default value : true. The SPS is faster when it's set to false.
  24772. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24773. */
  24774. /**
  24775. * Gets if `setParticles()` computes the particle rotations or not.
  24776. * Default value : true. The SPS is faster when it's set to false.
  24777. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24778. */
  24779. computeParticleRotation: boolean;
  24780. /**
  24781. * Tells to `setParticles()` to compute the particle colors or not.
  24782. * Default value : true. The SPS is faster when it's set to false.
  24783. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24784. */
  24785. /**
  24786. * Gets if `setParticles()` computes the particle colors or not.
  24787. * Default value : true. The SPS is faster when it's set to false.
  24788. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24789. */
  24790. computeParticleColor: boolean;
  24791. /**
  24792. * Gets if `setParticles()` computes the particle textures or not.
  24793. * Default value : true. The SPS is faster when it's set to false.
  24794. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24795. */
  24796. computeParticleTexture: boolean;
  24797. /**
  24798. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24799. * Default value : false. The SPS is faster when it's set to false.
  24800. * Note : the particle custom vertex positions aren't stored values.
  24801. */
  24802. /**
  24803. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24804. * Default value : false. The SPS is faster when it's set to false.
  24805. * Note : the particle custom vertex positions aren't stored values.
  24806. */
  24807. computeParticleVertex: boolean;
  24808. /**
  24809. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24810. */
  24811. /**
  24812. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24813. */
  24814. computeBoundingBox: boolean;
  24815. /**
  24816. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24817. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24818. * Default : `true`
  24819. */
  24820. /**
  24821. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24822. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24823. * Default : `true`
  24824. */
  24825. depthSortParticles: boolean;
  24826. /**
  24827. * This function does nothing. It may be overwritten to set all the particle first values.
  24828. * The SPS doesn't call this function, you may have to call it by your own.
  24829. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24830. */
  24831. initParticles(): void;
  24832. /**
  24833. * This function does nothing. It may be overwritten to recycle a particle.
  24834. * The SPS doesn't call this function, you may have to call it by your own.
  24835. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24836. * @param particle The particle to recycle
  24837. * @returns the recycled particle
  24838. */
  24839. recycleParticle(particle: SolidParticle): SolidParticle;
  24840. /**
  24841. * Updates a particle : this function should be overwritten by the user.
  24842. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24843. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24844. * @example : just set a particle position or velocity and recycle conditions
  24845. * @param particle The particle to update
  24846. * @returns the updated particle
  24847. */
  24848. updateParticle(particle: SolidParticle): SolidParticle;
  24849. /**
  24850. * Updates a vertex of a particle : it can be overwritten by the user.
  24851. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24852. * @param particle the current particle
  24853. * @param vertex the current index of the current particle
  24854. * @param pt the index of the current vertex in the particle shape
  24855. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24856. * @example : just set a vertex particle position
  24857. * @returns the updated vertex
  24858. */
  24859. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24860. /**
  24861. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24862. * This does nothing and may be overwritten by the user.
  24863. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24864. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24865. * @param update the boolean update value actually passed to setParticles()
  24866. */
  24867. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24868. /**
  24869. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24870. * This will be passed three parameters.
  24871. * This does nothing and may be overwritten by the user.
  24872. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24873. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24874. * @param update the boolean update value actually passed to setParticles()
  24875. */
  24876. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24877. }
  24878. }
  24879. declare module "babylonjs/Particles/solidParticle" {
  24880. import { Nullable } from "babylonjs/types";
  24881. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24882. import { Mesh } from "babylonjs/Meshes/mesh";
  24883. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24884. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24885. /**
  24886. * Represents one particle of a solid particle system.
  24887. */
  24888. export class SolidParticle {
  24889. /**
  24890. * particle global index
  24891. */
  24892. idx: number;
  24893. /**
  24894. * The color of the particle
  24895. */
  24896. color: Nullable<Color4>;
  24897. /**
  24898. * The world space position of the particle.
  24899. */
  24900. position: Vector3;
  24901. /**
  24902. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24903. */
  24904. rotation: Vector3;
  24905. /**
  24906. * The world space rotation quaternion of the particle.
  24907. */
  24908. rotationQuaternion: Nullable<Quaternion>;
  24909. /**
  24910. * The scaling of the particle.
  24911. */
  24912. scaling: Vector3;
  24913. /**
  24914. * The uvs of the particle.
  24915. */
  24916. uvs: Vector4;
  24917. /**
  24918. * The current speed of the particle.
  24919. */
  24920. velocity: Vector3;
  24921. /**
  24922. * The pivot point in the particle local space.
  24923. */
  24924. pivot: Vector3;
  24925. /**
  24926. * Must the particle be translated from its pivot point in its local space ?
  24927. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24928. * Default : false
  24929. */
  24930. translateFromPivot: boolean;
  24931. /**
  24932. * Is the particle active or not ?
  24933. */
  24934. alive: boolean;
  24935. /**
  24936. * Is the particle visible or not ?
  24937. */
  24938. isVisible: boolean;
  24939. /**
  24940. * Index of this particle in the global "positions" array (Internal use)
  24941. * @hidden
  24942. */
  24943. _pos: number;
  24944. /**
  24945. * @hidden Index of this particle in the global "indices" array (Internal use)
  24946. */
  24947. _ind: number;
  24948. /**
  24949. * @hidden ModelShape of this particle (Internal use)
  24950. */
  24951. _model: ModelShape;
  24952. /**
  24953. * ModelShape id of this particle
  24954. */
  24955. shapeId: number;
  24956. /**
  24957. * Index of the particle in its shape id (Internal use)
  24958. */
  24959. idxInShape: number;
  24960. /**
  24961. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24962. */
  24963. _modelBoundingInfo: BoundingInfo;
  24964. /**
  24965. * @hidden Particle BoundingInfo object (Internal use)
  24966. */
  24967. _boundingInfo: BoundingInfo;
  24968. /**
  24969. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24970. */
  24971. _sps: SolidParticleSystem;
  24972. /**
  24973. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24974. */
  24975. _stillInvisible: boolean;
  24976. /**
  24977. * @hidden Last computed particle rotation matrix
  24978. */
  24979. _rotationMatrix: number[];
  24980. /**
  24981. * Parent particle Id, if any.
  24982. * Default null.
  24983. */
  24984. parentId: Nullable<number>;
  24985. /**
  24986. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24987. * The possible values are :
  24988. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24989. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24990. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24991. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24992. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24993. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24994. * */
  24995. cullingStrategy: number;
  24996. /**
  24997. * @hidden Internal global position in the SPS.
  24998. */
  24999. _globalPosition: Vector3;
  25000. /**
  25001. * Creates a Solid Particle object.
  25002. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25003. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25004. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25005. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25006. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25007. * @param shapeId (integer) is the model shape identifier in the SPS.
  25008. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25009. * @param sps defines the sps it is associated to
  25010. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25011. */
  25012. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25013. /**
  25014. * Legacy support, changed scale to scaling
  25015. */
  25016. /**
  25017. * Legacy support, changed scale to scaling
  25018. */
  25019. scale: Vector3;
  25020. /**
  25021. * Legacy support, changed quaternion to rotationQuaternion
  25022. */
  25023. /**
  25024. * Legacy support, changed quaternion to rotationQuaternion
  25025. */
  25026. quaternion: Nullable<Quaternion>;
  25027. /**
  25028. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25029. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25030. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25031. * @returns true if it intersects
  25032. */
  25033. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25034. /**
  25035. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25036. * A particle is in the frustum if its bounding box intersects the frustum
  25037. * @param frustumPlanes defines the frustum to test
  25038. * @returns true if the particle is in the frustum planes
  25039. */
  25040. isInFrustum(frustumPlanes: Plane[]): boolean;
  25041. /**
  25042. * get the rotation matrix of the particle
  25043. * @hidden
  25044. */
  25045. getRotationMatrix(m: Matrix): void;
  25046. }
  25047. /**
  25048. * Represents the shape of the model used by one particle of a solid particle system.
  25049. * SPS internal tool, don't use it manually.
  25050. */
  25051. export class ModelShape {
  25052. /**
  25053. * The shape id
  25054. * @hidden
  25055. */
  25056. shapeID: number;
  25057. /**
  25058. * flat array of model positions (internal use)
  25059. * @hidden
  25060. */
  25061. _shape: Vector3[];
  25062. /**
  25063. * flat array of model UVs (internal use)
  25064. * @hidden
  25065. */
  25066. _shapeUV: number[];
  25067. /**
  25068. * length of the shape in the model indices array (internal use)
  25069. * @hidden
  25070. */
  25071. _indicesLength: number;
  25072. /**
  25073. * Custom position function (internal use)
  25074. * @hidden
  25075. */
  25076. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25077. /**
  25078. * Custom vertex function (internal use)
  25079. * @hidden
  25080. */
  25081. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25082. /**
  25083. * 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.
  25084. * SPS internal tool, don't use it manually.
  25085. * @hidden
  25086. */
  25087. 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>);
  25088. }
  25089. /**
  25090. * Represents a Depth Sorted Particle in the solid particle system.
  25091. */
  25092. export class DepthSortedParticle {
  25093. /**
  25094. * Index of the particle in the "indices" array
  25095. */
  25096. ind: number;
  25097. /**
  25098. * Length of the particle shape in the "indices" array
  25099. */
  25100. indicesLength: number;
  25101. /**
  25102. * Squared distance from the particle to the camera
  25103. */
  25104. sqDistance: number;
  25105. }
  25106. }
  25107. declare module "babylonjs/Collisions/meshCollisionData" {
  25108. import { Collider } from "babylonjs/Collisions/collider";
  25109. import { Vector3 } from "babylonjs/Maths/math";
  25110. import { Nullable } from "babylonjs/types";
  25111. import { Observer } from "babylonjs/Misc/observable";
  25112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25113. /**
  25114. * @hidden
  25115. */
  25116. export class _MeshCollisionData {
  25117. _checkCollisions: boolean;
  25118. _collisionMask: number;
  25119. _collisionGroup: number;
  25120. _collider: Nullable<Collider>;
  25121. _oldPositionForCollisions: Vector3;
  25122. _diffPositionForCollisions: Vector3;
  25123. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25124. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25125. }
  25126. }
  25127. declare module "babylonjs/Meshes/abstractMesh" {
  25128. import { Observable } from "babylonjs/Misc/observable";
  25129. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25130. import { Camera } from "babylonjs/Cameras/camera";
  25131. import { Scene, IDisposable } from "babylonjs/scene";
  25132. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25133. import { Node } from "babylonjs/node";
  25134. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25135. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25136. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25137. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25138. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25139. import { Material } from "babylonjs/Materials/material";
  25140. import { Light } from "babylonjs/Lights/light";
  25141. import { Skeleton } from "babylonjs/Bones/skeleton";
  25142. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25143. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25144. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25145. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  25146. import { Ray } from "babylonjs/Culling/ray";
  25147. import { Collider } from "babylonjs/Collisions/collider";
  25148. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25149. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25150. /** @hidden */
  25151. class _FacetDataStorage {
  25152. facetPositions: Vector3[];
  25153. facetNormals: Vector3[];
  25154. facetPartitioning: number[][];
  25155. facetNb: number;
  25156. partitioningSubdivisions: number;
  25157. partitioningBBoxRatio: number;
  25158. facetDataEnabled: boolean;
  25159. facetParameters: any;
  25160. bbSize: Vector3;
  25161. subDiv: {
  25162. max: number;
  25163. X: number;
  25164. Y: number;
  25165. Z: number;
  25166. };
  25167. facetDepthSort: boolean;
  25168. facetDepthSortEnabled: boolean;
  25169. depthSortedIndices: IndicesArray;
  25170. depthSortedFacets: {
  25171. ind: number;
  25172. sqDistance: number;
  25173. }[];
  25174. facetDepthSortFunction: (f1: {
  25175. ind: number;
  25176. sqDistance: number;
  25177. }, f2: {
  25178. ind: number;
  25179. sqDistance: number;
  25180. }) => number;
  25181. facetDepthSortFrom: Vector3;
  25182. facetDepthSortOrigin: Vector3;
  25183. invertedMatrix: Matrix;
  25184. }
  25185. /**
  25186. * @hidden
  25187. **/
  25188. class _InternalAbstractMeshDataInfo {
  25189. _hasVertexAlpha: boolean;
  25190. _useVertexColors: boolean;
  25191. _numBoneInfluencers: number;
  25192. _applyFog: boolean;
  25193. _receiveShadows: boolean;
  25194. _facetData: _FacetDataStorage;
  25195. _visibility: number;
  25196. _skeleton: Nullable<Skeleton>;
  25197. _layerMask: number;
  25198. _computeBonesUsingShaders: boolean;
  25199. _isActive: boolean;
  25200. _onlyForInstances: boolean;
  25201. _isActiveIntermediate: boolean;
  25202. _onlyForInstancesIntermediate: boolean;
  25203. }
  25204. /**
  25205. * Class used to store all common mesh properties
  25206. */
  25207. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25208. /** No occlusion */
  25209. static OCCLUSION_TYPE_NONE: number;
  25210. /** Occlusion set to optimisitic */
  25211. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25212. /** Occlusion set to strict */
  25213. static OCCLUSION_TYPE_STRICT: number;
  25214. /** Use an accurante occlusion algorithm */
  25215. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25216. /** Use a conservative occlusion algorithm */
  25217. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25218. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25219. * Test order :
  25220. * Is the bounding sphere outside the frustum ?
  25221. * If not, are the bounding box vertices outside the frustum ?
  25222. * It not, then the cullable object is in the frustum.
  25223. */
  25224. static readonly CULLINGSTRATEGY_STANDARD: number;
  25225. /** Culling strategy : Bounding Sphere Only.
  25226. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25227. * It's also less accurate than the standard because some not visible objects can still be selected.
  25228. * Test : is the bounding sphere outside the frustum ?
  25229. * If not, then the cullable object is in the frustum.
  25230. */
  25231. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25232. /** Culling strategy : Optimistic Inclusion.
  25233. * This in an inclusion test first, then the standard exclusion test.
  25234. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25235. * 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.
  25236. * Anyway, it's as accurate as the standard strategy.
  25237. * Test :
  25238. * Is the cullable object bounding sphere center in the frustum ?
  25239. * If not, apply the default culling strategy.
  25240. */
  25241. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25242. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25243. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25244. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25245. * 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.
  25246. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25247. * Test :
  25248. * Is the cullable object bounding sphere center in the frustum ?
  25249. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25250. */
  25251. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25252. /**
  25253. * No billboard
  25254. */
  25255. static readonly BILLBOARDMODE_NONE: number;
  25256. /** Billboard on X axis */
  25257. static readonly BILLBOARDMODE_X: number;
  25258. /** Billboard on Y axis */
  25259. static readonly BILLBOARDMODE_Y: number;
  25260. /** Billboard on Z axis */
  25261. static readonly BILLBOARDMODE_Z: number;
  25262. /** Billboard on all axes */
  25263. static readonly BILLBOARDMODE_ALL: number;
  25264. /** @hidden */
  25265. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25266. /**
  25267. * The culling strategy to use to check whether the mesh must be rendered or not.
  25268. * This value can be changed at any time and will be used on the next render mesh selection.
  25269. * The possible values are :
  25270. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25271. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25272. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25273. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25274. * Please read each static variable documentation to get details about the culling process.
  25275. * */
  25276. cullingStrategy: number;
  25277. /**
  25278. * Gets the number of facets in the mesh
  25279. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25280. */
  25281. readonly facetNb: number;
  25282. /**
  25283. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25284. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25285. */
  25286. partitioningSubdivisions: number;
  25287. /**
  25288. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25289. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25290. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25291. */
  25292. partitioningBBoxRatio: number;
  25293. /**
  25294. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25295. * Works only for updatable meshes.
  25296. * Doesn't work with multi-materials
  25297. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25298. */
  25299. mustDepthSortFacets: boolean;
  25300. /**
  25301. * The location (Vector3) where the facet depth sort must be computed from.
  25302. * By default, the active camera position.
  25303. * Used only when facet depth sort is enabled
  25304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25305. */
  25306. facetDepthSortFrom: Vector3;
  25307. /**
  25308. * gets a boolean indicating if facetData is enabled
  25309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25310. */
  25311. readonly isFacetDataEnabled: boolean;
  25312. /** @hidden */
  25313. _updateNonUniformScalingState(value: boolean): boolean;
  25314. /**
  25315. * An event triggered when this mesh collides with another one
  25316. */
  25317. onCollideObservable: Observable<AbstractMesh>;
  25318. /** Set a function to call when this mesh collides with another one */
  25319. onCollide: () => void;
  25320. /**
  25321. * An event triggered when the collision's position changes
  25322. */
  25323. onCollisionPositionChangeObservable: Observable<Vector3>;
  25324. /** Set a function to call when the collision's position changes */
  25325. onCollisionPositionChange: () => void;
  25326. /**
  25327. * An event triggered when material is changed
  25328. */
  25329. onMaterialChangedObservable: Observable<AbstractMesh>;
  25330. /**
  25331. * Gets or sets the orientation for POV movement & rotation
  25332. */
  25333. definedFacingForward: boolean;
  25334. /** @hidden */
  25335. _occlusionQuery: Nullable<WebGLQuery>;
  25336. /** @hidden */
  25337. _renderingGroup: Nullable<RenderingGroup>;
  25338. /**
  25339. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25340. */
  25341. /**
  25342. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25343. */
  25344. visibility: number;
  25345. /** Gets or sets the alpha index used to sort transparent meshes
  25346. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25347. */
  25348. alphaIndex: number;
  25349. /**
  25350. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25351. */
  25352. isVisible: boolean;
  25353. /**
  25354. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25355. */
  25356. isPickable: boolean;
  25357. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25358. showSubMeshesBoundingBox: boolean;
  25359. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25360. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25361. */
  25362. isBlocker: boolean;
  25363. /**
  25364. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25365. */
  25366. enablePointerMoveEvents: boolean;
  25367. /**
  25368. * Specifies the rendering group id for this mesh (0 by default)
  25369. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25370. */
  25371. renderingGroupId: number;
  25372. private _material;
  25373. /** Gets or sets current material */
  25374. material: Nullable<Material>;
  25375. /**
  25376. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25377. * @see http://doc.babylonjs.com/babylon101/shadows
  25378. */
  25379. receiveShadows: boolean;
  25380. /** Defines color to use when rendering outline */
  25381. outlineColor: Color3;
  25382. /** Define width to use when rendering outline */
  25383. outlineWidth: number;
  25384. /** Defines color to use when rendering overlay */
  25385. overlayColor: Color3;
  25386. /** Defines alpha to use when rendering overlay */
  25387. overlayAlpha: number;
  25388. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25389. hasVertexAlpha: boolean;
  25390. /** 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) */
  25391. useVertexColors: boolean;
  25392. /**
  25393. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25394. */
  25395. computeBonesUsingShaders: boolean;
  25396. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25397. numBoneInfluencers: number;
  25398. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25399. applyFog: boolean;
  25400. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25401. useOctreeForRenderingSelection: boolean;
  25402. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25403. useOctreeForPicking: boolean;
  25404. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25405. useOctreeForCollisions: boolean;
  25406. /**
  25407. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25408. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25409. */
  25410. layerMask: number;
  25411. /**
  25412. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25413. */
  25414. alwaysSelectAsActiveMesh: boolean;
  25415. /**
  25416. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25417. */
  25418. doNotSyncBoundingInfo: boolean;
  25419. /**
  25420. * Gets or sets the current action manager
  25421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25422. */
  25423. actionManager: Nullable<AbstractActionManager>;
  25424. private _meshCollisionData;
  25425. /**
  25426. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25427. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25428. */
  25429. ellipsoid: Vector3;
  25430. /**
  25431. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25432. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25433. */
  25434. ellipsoidOffset: Vector3;
  25435. /**
  25436. * Gets or sets a collision mask used to mask collisions (default is -1).
  25437. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25438. */
  25439. collisionMask: number;
  25440. /**
  25441. * Gets or sets the current collision group mask (-1 by default).
  25442. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25443. */
  25444. collisionGroup: number;
  25445. /**
  25446. * Defines edge width used when edgesRenderer is enabled
  25447. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25448. */
  25449. edgesWidth: number;
  25450. /**
  25451. * Defines edge color used when edgesRenderer is enabled
  25452. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25453. */
  25454. edgesColor: Color4;
  25455. /** @hidden */
  25456. _edgesRenderer: Nullable<IEdgesRenderer>;
  25457. /** @hidden */
  25458. _masterMesh: Nullable<AbstractMesh>;
  25459. /** @hidden */
  25460. _boundingInfo: Nullable<BoundingInfo>;
  25461. /** @hidden */
  25462. _renderId: number;
  25463. /**
  25464. * Gets or sets the list of subMeshes
  25465. * @see http://doc.babylonjs.com/how_to/multi_materials
  25466. */
  25467. subMeshes: SubMesh[];
  25468. /** @hidden */
  25469. _intersectionsInProgress: AbstractMesh[];
  25470. /** @hidden */
  25471. _unIndexed: boolean;
  25472. /** @hidden */
  25473. _lightSources: Light[];
  25474. /** Gets the list of lights affecting that mesh */
  25475. readonly lightSources: Light[];
  25476. /** @hidden */
  25477. readonly _positions: Nullable<Vector3[]>;
  25478. /** @hidden */
  25479. _waitingData: {
  25480. lods: Nullable<any>;
  25481. actions: Nullable<any>;
  25482. freezeWorldMatrix: Nullable<boolean>;
  25483. };
  25484. /** @hidden */
  25485. _bonesTransformMatrices: Nullable<Float32Array>;
  25486. /** @hidden */
  25487. _transformMatrixTexture: Nullable<RawTexture>;
  25488. /**
  25489. * Gets or sets a skeleton to apply skining transformations
  25490. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25491. */
  25492. skeleton: Nullable<Skeleton>;
  25493. /**
  25494. * An event triggered when the mesh is rebuilt.
  25495. */
  25496. onRebuildObservable: Observable<AbstractMesh>;
  25497. /**
  25498. * Creates a new AbstractMesh
  25499. * @param name defines the name of the mesh
  25500. * @param scene defines the hosting scene
  25501. */
  25502. constructor(name: string, scene?: Nullable<Scene>);
  25503. /**
  25504. * Returns the string "AbstractMesh"
  25505. * @returns "AbstractMesh"
  25506. */
  25507. getClassName(): string;
  25508. /**
  25509. * Gets a string representation of the current mesh
  25510. * @param fullDetails defines a boolean indicating if full details must be included
  25511. * @returns a string representation of the current mesh
  25512. */
  25513. toString(fullDetails?: boolean): string;
  25514. /**
  25515. * @hidden
  25516. */
  25517. protected _getEffectiveParent(): Nullable<Node>;
  25518. /** @hidden */
  25519. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25520. /** @hidden */
  25521. _rebuild(): void;
  25522. /** @hidden */
  25523. _resyncLightSources(): void;
  25524. /** @hidden */
  25525. _resyncLighSource(light: Light): void;
  25526. /** @hidden */
  25527. _unBindEffect(): void;
  25528. /** @hidden */
  25529. _removeLightSource(light: Light): void;
  25530. private _markSubMeshesAsDirty;
  25531. /** @hidden */
  25532. _markSubMeshesAsLightDirty(): void;
  25533. /** @hidden */
  25534. _markSubMeshesAsAttributesDirty(): void;
  25535. /** @hidden */
  25536. _markSubMeshesAsMiscDirty(): void;
  25537. /**
  25538. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25539. */
  25540. scaling: Vector3;
  25541. /**
  25542. * Returns true if the mesh is blocked. Implemented by child classes
  25543. */
  25544. readonly isBlocked: boolean;
  25545. /**
  25546. * Returns the mesh itself by default. Implemented by child classes
  25547. * @param camera defines the camera to use to pick the right LOD level
  25548. * @returns the currentAbstractMesh
  25549. */
  25550. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25551. /**
  25552. * Returns 0 by default. Implemented by child classes
  25553. * @returns an integer
  25554. */
  25555. getTotalVertices(): number;
  25556. /**
  25557. * Returns a positive integer : the total number of indices in this mesh geometry.
  25558. * @returns the numner of indices or zero if the mesh has no geometry.
  25559. */
  25560. getTotalIndices(): number;
  25561. /**
  25562. * Returns null by default. Implemented by child classes
  25563. * @returns null
  25564. */
  25565. getIndices(): Nullable<IndicesArray>;
  25566. /**
  25567. * Returns the array of the requested vertex data kind. Implemented by child classes
  25568. * @param kind defines the vertex data kind to use
  25569. * @returns null
  25570. */
  25571. getVerticesData(kind: string): Nullable<FloatArray>;
  25572. /**
  25573. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25574. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25575. * Note that a new underlying VertexBuffer object is created each call.
  25576. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25577. * @param kind defines vertex data kind:
  25578. * * VertexBuffer.PositionKind
  25579. * * VertexBuffer.UVKind
  25580. * * VertexBuffer.UV2Kind
  25581. * * VertexBuffer.UV3Kind
  25582. * * VertexBuffer.UV4Kind
  25583. * * VertexBuffer.UV5Kind
  25584. * * VertexBuffer.UV6Kind
  25585. * * VertexBuffer.ColorKind
  25586. * * VertexBuffer.MatricesIndicesKind
  25587. * * VertexBuffer.MatricesIndicesExtraKind
  25588. * * VertexBuffer.MatricesWeightsKind
  25589. * * VertexBuffer.MatricesWeightsExtraKind
  25590. * @param data defines the data source
  25591. * @param updatable defines if the data must be flagged as updatable (or static)
  25592. * @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
  25593. * @returns the current mesh
  25594. */
  25595. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25596. /**
  25597. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25598. * If the mesh has no geometry, it is simply returned as it is.
  25599. * @param kind defines vertex data kind:
  25600. * * VertexBuffer.PositionKind
  25601. * * VertexBuffer.UVKind
  25602. * * VertexBuffer.UV2Kind
  25603. * * VertexBuffer.UV3Kind
  25604. * * VertexBuffer.UV4Kind
  25605. * * VertexBuffer.UV5Kind
  25606. * * VertexBuffer.UV6Kind
  25607. * * VertexBuffer.ColorKind
  25608. * * VertexBuffer.MatricesIndicesKind
  25609. * * VertexBuffer.MatricesIndicesExtraKind
  25610. * * VertexBuffer.MatricesWeightsKind
  25611. * * VertexBuffer.MatricesWeightsExtraKind
  25612. * @param data defines the data source
  25613. * @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
  25614. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25615. * @returns the current mesh
  25616. */
  25617. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25618. /**
  25619. * Sets the mesh indices,
  25620. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25621. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25622. * @param totalVertices Defines the total number of vertices
  25623. * @returns the current mesh
  25624. */
  25625. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25626. /**
  25627. * Gets a boolean indicating if specific vertex data is present
  25628. * @param kind defines the vertex data kind to use
  25629. * @returns true is data kind is present
  25630. */
  25631. isVerticesDataPresent(kind: string): boolean;
  25632. /**
  25633. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25634. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25635. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25636. * @returns a BoundingInfo
  25637. */
  25638. getBoundingInfo(): BoundingInfo;
  25639. /**
  25640. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25641. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25642. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25643. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25644. * @returns the current mesh
  25645. */
  25646. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25647. /**
  25648. * Overwrite the current bounding info
  25649. * @param boundingInfo defines the new bounding info
  25650. * @returns the current mesh
  25651. */
  25652. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25653. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25654. readonly useBones: boolean;
  25655. /** @hidden */
  25656. _preActivate(): void;
  25657. /** @hidden */
  25658. _preActivateForIntermediateRendering(renderId: number): void;
  25659. /** @hidden */
  25660. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25661. /** @hidden */
  25662. _postActivate(): void;
  25663. /** @hidden */
  25664. _freeze(): void;
  25665. /** @hidden */
  25666. _unFreeze(): void;
  25667. /**
  25668. * Gets the current world matrix
  25669. * @returns a Matrix
  25670. */
  25671. getWorldMatrix(): Matrix;
  25672. /** @hidden */
  25673. _getWorldMatrixDeterminant(): number;
  25674. /**
  25675. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25676. */
  25677. readonly isAnInstance: boolean;
  25678. /**
  25679. * Perform relative position change from the point of view of behind the front of the mesh.
  25680. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25681. * Supports definition of mesh facing forward or backward
  25682. * @param amountRight defines the distance on the right axis
  25683. * @param amountUp defines the distance on the up axis
  25684. * @param amountForward defines the distance on the forward axis
  25685. * @returns the current mesh
  25686. */
  25687. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25688. /**
  25689. * Calculate relative position change from the point of view of behind the front of the mesh.
  25690. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25691. * Supports definition of mesh facing forward or backward
  25692. * @param amountRight defines the distance on the right axis
  25693. * @param amountUp defines the distance on the up axis
  25694. * @param amountForward defines the distance on the forward axis
  25695. * @returns the new displacement vector
  25696. */
  25697. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25698. /**
  25699. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25700. * Supports definition of mesh facing forward or backward
  25701. * @param flipBack defines the flip
  25702. * @param twirlClockwise defines the twirl
  25703. * @param tiltRight defines the tilt
  25704. * @returns the current mesh
  25705. */
  25706. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25707. /**
  25708. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25709. * Supports definition of mesh facing forward or backward.
  25710. * @param flipBack defines the flip
  25711. * @param twirlClockwise defines the twirl
  25712. * @param tiltRight defines the tilt
  25713. * @returns the new rotation vector
  25714. */
  25715. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25716. /**
  25717. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25718. * This means the mesh underlying bounding box and sphere are recomputed.
  25719. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25720. * @returns the current mesh
  25721. */
  25722. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25723. /** @hidden */
  25724. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25725. /** @hidden */
  25726. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25727. /** @hidden */
  25728. _updateBoundingInfo(): AbstractMesh;
  25729. /** @hidden */
  25730. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25731. /** @hidden */
  25732. protected _afterComputeWorldMatrix(): void;
  25733. /** @hidden */
  25734. readonly _effectiveMesh: AbstractMesh;
  25735. /**
  25736. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25737. * A mesh is in the frustum if its bounding box intersects the frustum
  25738. * @param frustumPlanes defines the frustum to test
  25739. * @returns true if the mesh is in the frustum planes
  25740. */
  25741. isInFrustum(frustumPlanes: Plane[]): boolean;
  25742. /**
  25743. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25744. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25745. * @param frustumPlanes defines the frustum to test
  25746. * @returns true if the mesh is completely in the frustum planes
  25747. */
  25748. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25749. /**
  25750. * True if the mesh intersects another mesh or a SolidParticle object
  25751. * @param mesh defines a target mesh or SolidParticle to test
  25752. * @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)
  25753. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25754. * @returns true if there is an intersection
  25755. */
  25756. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25757. /**
  25758. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25759. * @param point defines the point to test
  25760. * @returns true if there is an intersection
  25761. */
  25762. intersectsPoint(point: Vector3): boolean;
  25763. /**
  25764. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25765. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25766. */
  25767. checkCollisions: boolean;
  25768. /**
  25769. * Gets Collider object used to compute collisions (not physics)
  25770. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25771. */
  25772. readonly collider: Nullable<Collider>;
  25773. /**
  25774. * Move the mesh using collision engine
  25775. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25776. * @param displacement defines the requested displacement vector
  25777. * @returns the current mesh
  25778. */
  25779. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25780. private _onCollisionPositionChange;
  25781. /** @hidden */
  25782. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25783. /** @hidden */
  25784. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25785. /** @hidden */
  25786. _checkCollision(collider: Collider): AbstractMesh;
  25787. /** @hidden */
  25788. _generatePointsArray(): boolean;
  25789. /**
  25790. * Checks if the passed Ray intersects with the mesh
  25791. * @param ray defines the ray to use
  25792. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25793. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25794. * @returns the picking info
  25795. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25796. */
  25797. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25798. /**
  25799. * Clones the current mesh
  25800. * @param name defines the mesh name
  25801. * @param newParent defines the new mesh parent
  25802. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25803. * @returns the new mesh
  25804. */
  25805. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25806. /**
  25807. * Disposes all the submeshes of the current meshnp
  25808. * @returns the current mesh
  25809. */
  25810. releaseSubMeshes(): AbstractMesh;
  25811. /**
  25812. * Releases resources associated with this abstract mesh.
  25813. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25814. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25815. */
  25816. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25817. /**
  25818. * Adds the passed mesh as a child to the current mesh
  25819. * @param mesh defines the child mesh
  25820. * @returns the current mesh
  25821. */
  25822. addChild(mesh: AbstractMesh): AbstractMesh;
  25823. /**
  25824. * Removes the passed mesh from the current mesh children list
  25825. * @param mesh defines the child mesh
  25826. * @returns the current mesh
  25827. */
  25828. removeChild(mesh: AbstractMesh): AbstractMesh;
  25829. /** @hidden */
  25830. private _initFacetData;
  25831. /**
  25832. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25833. * This method can be called within the render loop.
  25834. * 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
  25835. * @returns the current mesh
  25836. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25837. */
  25838. updateFacetData(): AbstractMesh;
  25839. /**
  25840. * Returns the facetLocalNormals array.
  25841. * The normals are expressed in the mesh local spac
  25842. * @returns an array of Vector3
  25843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25844. */
  25845. getFacetLocalNormals(): Vector3[];
  25846. /**
  25847. * Returns the facetLocalPositions array.
  25848. * The facet positions are expressed in the mesh local space
  25849. * @returns an array of Vector3
  25850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25851. */
  25852. getFacetLocalPositions(): Vector3[];
  25853. /**
  25854. * Returns the facetLocalPartioning array
  25855. * @returns an array of array of numbers
  25856. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25857. */
  25858. getFacetLocalPartitioning(): number[][];
  25859. /**
  25860. * Returns the i-th facet position in the world system.
  25861. * This method allocates a new Vector3 per call
  25862. * @param i defines the facet index
  25863. * @returns a new Vector3
  25864. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25865. */
  25866. getFacetPosition(i: number): Vector3;
  25867. /**
  25868. * Sets the reference Vector3 with the i-th facet position in the world system
  25869. * @param i defines the facet index
  25870. * @param ref defines the target vector
  25871. * @returns the current mesh
  25872. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25873. */
  25874. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25875. /**
  25876. * Returns the i-th facet normal in the world system.
  25877. * This method allocates a new Vector3 per call
  25878. * @param i defines the facet index
  25879. * @returns a new Vector3
  25880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25881. */
  25882. getFacetNormal(i: number): Vector3;
  25883. /**
  25884. * Sets the reference Vector3 with the i-th facet normal in the world system
  25885. * @param i defines the facet index
  25886. * @param ref defines the target vector
  25887. * @returns the current mesh
  25888. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25889. */
  25890. getFacetNormalToRef(i: number, ref: Vector3): this;
  25891. /**
  25892. * 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)
  25893. * @param x defines x coordinate
  25894. * @param y defines y coordinate
  25895. * @param z defines z coordinate
  25896. * @returns the array of facet indexes
  25897. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25898. */
  25899. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25900. /**
  25901. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25902. * @param projected sets as the (x,y,z) world projection on the facet
  25903. * @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
  25904. * @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
  25905. * @param x defines x coordinate
  25906. * @param y defines y coordinate
  25907. * @param z defines z coordinate
  25908. * @returns the face index if found (or null instead)
  25909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25910. */
  25911. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25912. /**
  25913. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25914. * @param projected sets as the (x,y,z) local projection on the facet
  25915. * @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
  25916. * @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
  25917. * @param x defines x coordinate
  25918. * @param y defines y coordinate
  25919. * @param z defines z coordinate
  25920. * @returns the face index if found (or null instead)
  25921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25922. */
  25923. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25924. /**
  25925. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25926. * @returns the parameters
  25927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25928. */
  25929. getFacetDataParameters(): any;
  25930. /**
  25931. * Disables the feature FacetData and frees the related memory
  25932. * @returns the current mesh
  25933. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25934. */
  25935. disableFacetData(): AbstractMesh;
  25936. /**
  25937. * Updates the AbstractMesh indices array
  25938. * @param indices defines the data source
  25939. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25940. * @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)
  25941. * @returns the current mesh
  25942. */
  25943. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25944. /**
  25945. * Creates new normals data for the mesh
  25946. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25947. * @returns the current mesh
  25948. */
  25949. createNormals(updatable: boolean): AbstractMesh;
  25950. /**
  25951. * Align the mesh with a normal
  25952. * @param normal defines the normal to use
  25953. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25954. * @returns the current mesh
  25955. */
  25956. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25957. /** @hidden */
  25958. _checkOcclusionQuery(): boolean;
  25959. /**
  25960. * Disables the mesh edge rendering mode
  25961. * @returns the currentAbstractMesh
  25962. */
  25963. disableEdgesRendering(): AbstractMesh;
  25964. /**
  25965. * Enables the edge rendering mode on the mesh.
  25966. * This mode makes the mesh edges visible
  25967. * @param epsilon defines the maximal distance between two angles to detect a face
  25968. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25969. * @returns the currentAbstractMesh
  25970. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25971. */
  25972. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25973. }
  25974. }
  25975. declare module "babylonjs/Actions/actionEvent" {
  25976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25977. import { Nullable } from "babylonjs/types";
  25978. import { Sprite } from "babylonjs/Sprites/sprite";
  25979. import { Scene } from "babylonjs/scene";
  25980. import { Vector2 } from "babylonjs/Maths/math";
  25981. /**
  25982. * Interface used to define ActionEvent
  25983. */
  25984. export interface IActionEvent {
  25985. /** The mesh or sprite that triggered the action */
  25986. source: any;
  25987. /** The X mouse cursor position at the time of the event */
  25988. pointerX: number;
  25989. /** The Y mouse cursor position at the time of the event */
  25990. pointerY: number;
  25991. /** The mesh that is currently pointed at (can be null) */
  25992. meshUnderPointer: Nullable<AbstractMesh>;
  25993. /** the original (browser) event that triggered the ActionEvent */
  25994. sourceEvent?: any;
  25995. /** additional data for the event */
  25996. additionalData?: any;
  25997. }
  25998. /**
  25999. * ActionEvent is the event being sent when an action is triggered.
  26000. */
  26001. export class ActionEvent implements IActionEvent {
  26002. /** The mesh or sprite that triggered the action */
  26003. source: any;
  26004. /** The X mouse cursor position at the time of the event */
  26005. pointerX: number;
  26006. /** The Y mouse cursor position at the time of the event */
  26007. pointerY: number;
  26008. /** The mesh that is currently pointed at (can be null) */
  26009. meshUnderPointer: Nullable<AbstractMesh>;
  26010. /** the original (browser) event that triggered the ActionEvent */
  26011. sourceEvent?: any;
  26012. /** additional data for the event */
  26013. additionalData?: any;
  26014. /**
  26015. * Creates a new ActionEvent
  26016. * @param source The mesh or sprite that triggered the action
  26017. * @param pointerX The X mouse cursor position at the time of the event
  26018. * @param pointerY The Y mouse cursor position at the time of the event
  26019. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26020. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26021. * @param additionalData additional data for the event
  26022. */
  26023. constructor(
  26024. /** The mesh or sprite that triggered the action */
  26025. source: any,
  26026. /** The X mouse cursor position at the time of the event */
  26027. pointerX: number,
  26028. /** The Y mouse cursor position at the time of the event */
  26029. pointerY: number,
  26030. /** The mesh that is currently pointed at (can be null) */
  26031. meshUnderPointer: Nullable<AbstractMesh>,
  26032. /** the original (browser) event that triggered the ActionEvent */
  26033. sourceEvent?: any,
  26034. /** additional data for the event */
  26035. additionalData?: any);
  26036. /**
  26037. * Helper function to auto-create an ActionEvent from a source mesh.
  26038. * @param source The source mesh that triggered the event
  26039. * @param evt The original (browser) event
  26040. * @param additionalData additional data for the event
  26041. * @returns the new ActionEvent
  26042. */
  26043. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26044. /**
  26045. * Helper function to auto-create an ActionEvent from a source sprite
  26046. * @param source The source sprite that triggered the event
  26047. * @param scene Scene associated with the sprite
  26048. * @param evt The original (browser) event
  26049. * @param additionalData additional data for the event
  26050. * @returns the new ActionEvent
  26051. */
  26052. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26053. /**
  26054. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26055. * @param scene the scene where the event occurred
  26056. * @param evt The original (browser) event
  26057. * @returns the new ActionEvent
  26058. */
  26059. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26060. /**
  26061. * Helper function to auto-create an ActionEvent from a primitive
  26062. * @param prim defines the target primitive
  26063. * @param pointerPos defines the pointer position
  26064. * @param evt The original (browser) event
  26065. * @param additionalData additional data for the event
  26066. * @returns the new ActionEvent
  26067. */
  26068. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26069. }
  26070. }
  26071. declare module "babylonjs/Actions/abstractActionManager" {
  26072. import { IDisposable } from "babylonjs/scene";
  26073. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  26074. import { IAction } from "babylonjs/Actions/action";
  26075. import { Nullable } from "babylonjs/types";
  26076. /**
  26077. * Abstract class used to decouple action Manager from scene and meshes.
  26078. * Do not instantiate.
  26079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26080. */
  26081. export abstract class AbstractActionManager implements IDisposable {
  26082. /** Gets the list of active triggers */
  26083. static Triggers: {
  26084. [key: string]: number;
  26085. };
  26086. /** Gets the cursor to use when hovering items */
  26087. hoverCursor: string;
  26088. /** Gets the list of actions */
  26089. actions: IAction[];
  26090. /**
  26091. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26092. */
  26093. isRecursive: boolean;
  26094. /**
  26095. * Releases all associated resources
  26096. */
  26097. abstract dispose(): void;
  26098. /**
  26099. * Does this action manager has pointer triggers
  26100. */
  26101. abstract readonly hasPointerTriggers: boolean;
  26102. /**
  26103. * Does this action manager has pick triggers
  26104. */
  26105. abstract readonly hasPickTriggers: boolean;
  26106. /**
  26107. * Process a specific trigger
  26108. * @param trigger defines the trigger to process
  26109. * @param evt defines the event details to be processed
  26110. */
  26111. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26112. /**
  26113. * Does this action manager handles actions of any of the given triggers
  26114. * @param triggers defines the triggers to be tested
  26115. * @return a boolean indicating whether one (or more) of the triggers is handled
  26116. */
  26117. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26118. /**
  26119. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26120. * speed.
  26121. * @param triggerA defines the trigger to be tested
  26122. * @param triggerB defines the trigger to be tested
  26123. * @return a boolean indicating whether one (or more) of the triggers is handled
  26124. */
  26125. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26126. /**
  26127. * Does this action manager handles actions of a given trigger
  26128. * @param trigger defines the trigger to be tested
  26129. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26130. * @return whether the trigger is handled
  26131. */
  26132. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26133. /**
  26134. * Serialize this manager to a JSON object
  26135. * @param name defines the property name to store this manager
  26136. * @returns a JSON representation of this manager
  26137. */
  26138. abstract serialize(name: string): any;
  26139. /**
  26140. * Registers an action to this action manager
  26141. * @param action defines the action to be registered
  26142. * @return the action amended (prepared) after registration
  26143. */
  26144. abstract registerAction(action: IAction): Nullable<IAction>;
  26145. /**
  26146. * Unregisters an action to this action manager
  26147. * @param action defines the action to be unregistered
  26148. * @return a boolean indicating whether the action has been unregistered
  26149. */
  26150. abstract unregisterAction(action: IAction): Boolean;
  26151. /**
  26152. * Does exist one action manager with at least one trigger
  26153. **/
  26154. static readonly HasTriggers: boolean;
  26155. /**
  26156. * Does exist one action manager with at least one pick trigger
  26157. **/
  26158. static readonly HasPickTriggers: boolean;
  26159. /**
  26160. * Does exist one action manager that handles actions of a given trigger
  26161. * @param trigger defines the trigger to be tested
  26162. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26163. **/
  26164. static HasSpecificTrigger(trigger: number): boolean;
  26165. }
  26166. }
  26167. declare module "babylonjs/node" {
  26168. import { Scene } from "babylonjs/scene";
  26169. import { Nullable } from "babylonjs/types";
  26170. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26171. import { Engine } from "babylonjs/Engines/engine";
  26172. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26173. import { Observable } from "babylonjs/Misc/observable";
  26174. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26175. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26176. import { Animatable } from "babylonjs/Animations/animatable";
  26177. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26178. import { Animation } from "babylonjs/Animations/animation";
  26179. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26181. /**
  26182. * Defines how a node can be built from a string name.
  26183. */
  26184. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26185. /**
  26186. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26187. */
  26188. export class Node implements IBehaviorAware<Node> {
  26189. /** @hidden */
  26190. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26191. private static _NodeConstructors;
  26192. /**
  26193. * Add a new node constructor
  26194. * @param type defines the type name of the node to construct
  26195. * @param constructorFunc defines the constructor function
  26196. */
  26197. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26198. /**
  26199. * Returns a node constructor based on type name
  26200. * @param type defines the type name
  26201. * @param name defines the new node name
  26202. * @param scene defines the hosting scene
  26203. * @param options defines optional options to transmit to constructors
  26204. * @returns the new constructor or null
  26205. */
  26206. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26207. /**
  26208. * Gets or sets the name of the node
  26209. */
  26210. name: string;
  26211. /**
  26212. * Gets or sets the id of the node
  26213. */
  26214. id: string;
  26215. /**
  26216. * Gets or sets the unique id of the node
  26217. */
  26218. uniqueId: number;
  26219. /**
  26220. * Gets or sets a string used to store user defined state for the node
  26221. */
  26222. state: string;
  26223. /**
  26224. * Gets or sets an object used to store user defined information for the node
  26225. */
  26226. metadata: any;
  26227. /**
  26228. * For internal use only. Please do not use.
  26229. */
  26230. reservedDataStore: any;
  26231. /**
  26232. * List of inspectable custom properties (used by the Inspector)
  26233. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26234. */
  26235. inspectableCustomProperties: IInspectable[];
  26236. /**
  26237. * Gets or sets a boolean used to define if the node must be serialized
  26238. */
  26239. doNotSerialize: boolean;
  26240. /** @hidden */
  26241. _isDisposed: boolean;
  26242. /**
  26243. * Gets a list of Animations associated with the node
  26244. */
  26245. animations: import("babylonjs/Animations/animation").Animation[];
  26246. protected _ranges: {
  26247. [name: string]: Nullable<AnimationRange>;
  26248. };
  26249. /**
  26250. * Callback raised when the node is ready to be used
  26251. */
  26252. onReady: Nullable<(node: Node) => void>;
  26253. private _isEnabled;
  26254. private _isParentEnabled;
  26255. private _isReady;
  26256. /** @hidden */
  26257. _currentRenderId: number;
  26258. private _parentUpdateId;
  26259. /** @hidden */
  26260. _childUpdateId: number;
  26261. /** @hidden */
  26262. _waitingParentId: Nullable<string>;
  26263. /** @hidden */
  26264. _scene: Scene;
  26265. /** @hidden */
  26266. _cache: any;
  26267. private _parentNode;
  26268. private _children;
  26269. /** @hidden */
  26270. _worldMatrix: Matrix;
  26271. /** @hidden */
  26272. _worldMatrixDeterminant: number;
  26273. /** @hidden */
  26274. _worldMatrixDeterminantIsDirty: boolean;
  26275. /** @hidden */
  26276. private _sceneRootNodesIndex;
  26277. /**
  26278. * Gets a boolean indicating if the node has been disposed
  26279. * @returns true if the node was disposed
  26280. */
  26281. isDisposed(): boolean;
  26282. /**
  26283. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26284. * @see https://doc.babylonjs.com/how_to/parenting
  26285. */
  26286. parent: Nullable<Node>;
  26287. private addToSceneRootNodes;
  26288. private removeFromSceneRootNodes;
  26289. private _animationPropertiesOverride;
  26290. /**
  26291. * Gets or sets the animation properties override
  26292. */
  26293. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26294. /**
  26295. * Gets a string idenfifying the name of the class
  26296. * @returns "Node" string
  26297. */
  26298. getClassName(): string;
  26299. /** @hidden */
  26300. readonly _isNode: boolean;
  26301. /**
  26302. * An event triggered when the mesh is disposed
  26303. */
  26304. onDisposeObservable: Observable<Node>;
  26305. private _onDisposeObserver;
  26306. /**
  26307. * Sets a callback that will be raised when the node will be disposed
  26308. */
  26309. onDispose: () => void;
  26310. /**
  26311. * Creates a new Node
  26312. * @param name the name and id to be given to this node
  26313. * @param scene the scene this node will be added to
  26314. * @param addToRootNodes the node will be added to scene.rootNodes
  26315. */
  26316. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26317. /**
  26318. * Gets the scene of the node
  26319. * @returns a scene
  26320. */
  26321. getScene(): Scene;
  26322. /**
  26323. * Gets the engine of the node
  26324. * @returns a Engine
  26325. */
  26326. getEngine(): Engine;
  26327. private _behaviors;
  26328. /**
  26329. * Attach a behavior to the node
  26330. * @see http://doc.babylonjs.com/features/behaviour
  26331. * @param behavior defines the behavior to attach
  26332. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26333. * @returns the current Node
  26334. */
  26335. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26336. /**
  26337. * Remove an attached behavior
  26338. * @see http://doc.babylonjs.com/features/behaviour
  26339. * @param behavior defines the behavior to attach
  26340. * @returns the current Node
  26341. */
  26342. removeBehavior(behavior: Behavior<Node>): Node;
  26343. /**
  26344. * Gets the list of attached behaviors
  26345. * @see http://doc.babylonjs.com/features/behaviour
  26346. */
  26347. readonly behaviors: Behavior<Node>[];
  26348. /**
  26349. * Gets an attached behavior by name
  26350. * @param name defines the name of the behavior to look for
  26351. * @see http://doc.babylonjs.com/features/behaviour
  26352. * @returns null if behavior was not found else the requested behavior
  26353. */
  26354. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26355. /**
  26356. * Returns the latest update of the World matrix
  26357. * @returns a Matrix
  26358. */
  26359. getWorldMatrix(): Matrix;
  26360. /** @hidden */
  26361. _getWorldMatrixDeterminant(): number;
  26362. /**
  26363. * Returns directly the latest state of the mesh World matrix.
  26364. * A Matrix is returned.
  26365. */
  26366. readonly worldMatrixFromCache: Matrix;
  26367. /** @hidden */
  26368. _initCache(): void;
  26369. /** @hidden */
  26370. updateCache(force?: boolean): void;
  26371. /** @hidden */
  26372. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26373. /** @hidden */
  26374. _updateCache(ignoreParentClass?: boolean): void;
  26375. /** @hidden */
  26376. _isSynchronized(): boolean;
  26377. /** @hidden */
  26378. _markSyncedWithParent(): void;
  26379. /** @hidden */
  26380. isSynchronizedWithParent(): boolean;
  26381. /** @hidden */
  26382. isSynchronized(): boolean;
  26383. /**
  26384. * Is this node ready to be used/rendered
  26385. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26386. * @return true if the node is ready
  26387. */
  26388. isReady(completeCheck?: boolean): boolean;
  26389. /**
  26390. * Is this node enabled?
  26391. * 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
  26392. * @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
  26393. * @return whether this node (and its parent) is enabled
  26394. */
  26395. isEnabled(checkAncestors?: boolean): boolean;
  26396. /** @hidden */
  26397. protected _syncParentEnabledState(): void;
  26398. /**
  26399. * Set the enabled state of this node
  26400. * @param value defines the new enabled state
  26401. */
  26402. setEnabled(value: boolean): void;
  26403. /**
  26404. * Is this node a descendant of the given node?
  26405. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26406. * @param ancestor defines the parent node to inspect
  26407. * @returns a boolean indicating if this node is a descendant of the given node
  26408. */
  26409. isDescendantOf(ancestor: Node): boolean;
  26410. /** @hidden */
  26411. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26412. /**
  26413. * Will return all nodes that have this node as ascendant
  26414. * @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
  26415. * @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
  26416. * @return all children nodes of all types
  26417. */
  26418. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26419. /**
  26420. * Get all child-meshes of this node
  26421. * @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)
  26422. * @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
  26423. * @returns an array of AbstractMesh
  26424. */
  26425. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26426. /**
  26427. * Get all direct children of this node
  26428. * @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
  26429. * @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)
  26430. * @returns an array of Node
  26431. */
  26432. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26433. /** @hidden */
  26434. _setReady(state: boolean): void;
  26435. /**
  26436. * Get an animation by name
  26437. * @param name defines the name of the animation to look for
  26438. * @returns null if not found else the requested animation
  26439. */
  26440. getAnimationByName(name: string): Nullable<Animation>;
  26441. /**
  26442. * Creates an animation range for this node
  26443. * @param name defines the name of the range
  26444. * @param from defines the starting key
  26445. * @param to defines the end key
  26446. */
  26447. createAnimationRange(name: string, from: number, to: number): void;
  26448. /**
  26449. * Delete a specific animation range
  26450. * @param name defines the name of the range to delete
  26451. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26452. */
  26453. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26454. /**
  26455. * Get an animation range by name
  26456. * @param name defines the name of the animation range to look for
  26457. * @returns null if not found else the requested animation range
  26458. */
  26459. getAnimationRange(name: string): Nullable<AnimationRange>;
  26460. /**
  26461. * Gets the list of all animation ranges defined on this node
  26462. * @returns an array
  26463. */
  26464. getAnimationRanges(): Nullable<AnimationRange>[];
  26465. /**
  26466. * Will start the animation sequence
  26467. * @param name defines the range frames for animation sequence
  26468. * @param loop defines if the animation should loop (false by default)
  26469. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26470. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26471. * @returns the object created for this animation. If range does not exist, it will return null
  26472. */
  26473. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26474. /**
  26475. * Serialize animation ranges into a JSON compatible object
  26476. * @returns serialization object
  26477. */
  26478. serializeAnimationRanges(): any;
  26479. /**
  26480. * Computes the world matrix of the node
  26481. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26482. * @returns the world matrix
  26483. */
  26484. computeWorldMatrix(force?: boolean): Matrix;
  26485. /**
  26486. * Releases resources associated with this node.
  26487. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26488. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26489. */
  26490. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26491. /**
  26492. * Parse animation range data from a serialization object and store them into a given node
  26493. * @param node defines where to store the animation ranges
  26494. * @param parsedNode defines the serialization object to read data from
  26495. * @param scene defines the hosting scene
  26496. */
  26497. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26498. /**
  26499. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26500. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26501. * @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
  26502. * @returns the new bounding vectors
  26503. */
  26504. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26505. min: Vector3;
  26506. max: Vector3;
  26507. };
  26508. }
  26509. }
  26510. declare module "babylonjs/Animations/animation" {
  26511. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26512. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26513. import { Nullable } from "babylonjs/types";
  26514. import { Scene } from "babylonjs/scene";
  26515. import { IAnimatable } from "babylonjs/Misc/tools";
  26516. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26517. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26518. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26519. import { Node } from "babylonjs/node";
  26520. import { Animatable } from "babylonjs/Animations/animatable";
  26521. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26522. /**
  26523. * @hidden
  26524. */
  26525. export class _IAnimationState {
  26526. key: number;
  26527. repeatCount: number;
  26528. workValue?: any;
  26529. loopMode?: number;
  26530. offsetValue?: any;
  26531. highLimitValue?: any;
  26532. }
  26533. /**
  26534. * Class used to store any kind of animation
  26535. */
  26536. export class Animation {
  26537. /**Name of the animation */
  26538. name: string;
  26539. /**Property to animate */
  26540. targetProperty: string;
  26541. /**The frames per second of the animation */
  26542. framePerSecond: number;
  26543. /**The data type of the animation */
  26544. dataType: number;
  26545. /**The loop mode of the animation */
  26546. loopMode?: number | undefined;
  26547. /**Specifies if blending should be enabled */
  26548. enableBlending?: boolean | undefined;
  26549. /**
  26550. * Use matrix interpolation instead of using direct key value when animating matrices
  26551. */
  26552. static AllowMatricesInterpolation: boolean;
  26553. /**
  26554. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26555. */
  26556. static AllowMatrixDecomposeForInterpolation: boolean;
  26557. /**
  26558. * Stores the key frames of the animation
  26559. */
  26560. private _keys;
  26561. /**
  26562. * Stores the easing function of the animation
  26563. */
  26564. private _easingFunction;
  26565. /**
  26566. * @hidden Internal use only
  26567. */
  26568. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26569. /**
  26570. * The set of event that will be linked to this animation
  26571. */
  26572. private _events;
  26573. /**
  26574. * Stores an array of target property paths
  26575. */
  26576. targetPropertyPath: string[];
  26577. /**
  26578. * Stores the blending speed of the animation
  26579. */
  26580. blendingSpeed: number;
  26581. /**
  26582. * Stores the animation ranges for the animation
  26583. */
  26584. private _ranges;
  26585. /**
  26586. * @hidden Internal use
  26587. */
  26588. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26589. /**
  26590. * Sets up an animation
  26591. * @param property The property to animate
  26592. * @param animationType The animation type to apply
  26593. * @param framePerSecond The frames per second of the animation
  26594. * @param easingFunction The easing function used in the animation
  26595. * @returns The created animation
  26596. */
  26597. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26598. /**
  26599. * Create and start an animation on a node
  26600. * @param name defines the name of the global animation that will be run on all nodes
  26601. * @param node defines the root node where the animation will take place
  26602. * @param targetProperty defines property to animate
  26603. * @param framePerSecond defines the number of frame per second yo use
  26604. * @param totalFrame defines the number of frames in total
  26605. * @param from defines the initial value
  26606. * @param to defines the final value
  26607. * @param loopMode defines which loop mode you want to use (off by default)
  26608. * @param easingFunction defines the easing function to use (linear by default)
  26609. * @param onAnimationEnd defines the callback to call when animation end
  26610. * @returns the animatable created for this animation
  26611. */
  26612. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26613. /**
  26614. * Create and start an animation on a node and its descendants
  26615. * @param name defines the name of the global animation that will be run on all nodes
  26616. * @param node defines the root node where the animation will take place
  26617. * @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
  26618. * @param targetProperty defines property to animate
  26619. * @param framePerSecond defines the number of frame per second to use
  26620. * @param totalFrame defines the number of frames in total
  26621. * @param from defines the initial value
  26622. * @param to defines the final value
  26623. * @param loopMode defines which loop mode you want to use (off by default)
  26624. * @param easingFunction defines the easing function to use (linear by default)
  26625. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26626. * @returns the list of animatables created for all nodes
  26627. * @example https://www.babylonjs-playground.com/#MH0VLI
  26628. */
  26629. 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[]>;
  26630. /**
  26631. * Creates a new animation, merges it with the existing animations and starts it
  26632. * @param name Name of the animation
  26633. * @param node Node which contains the scene that begins the animations
  26634. * @param targetProperty Specifies which property to animate
  26635. * @param framePerSecond The frames per second of the animation
  26636. * @param totalFrame The total number of frames
  26637. * @param from The frame at the beginning of the animation
  26638. * @param to The frame at the end of the animation
  26639. * @param loopMode Specifies the loop mode of the animation
  26640. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26641. * @param onAnimationEnd Callback to run once the animation is complete
  26642. * @returns Nullable animation
  26643. */
  26644. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26645. /**
  26646. * Transition property of an host to the target Value
  26647. * @param property The property to transition
  26648. * @param targetValue The target Value of the property
  26649. * @param host The object where the property to animate belongs
  26650. * @param scene Scene used to run the animation
  26651. * @param frameRate Framerate (in frame/s) to use
  26652. * @param transition The transition type we want to use
  26653. * @param duration The duration of the animation, in milliseconds
  26654. * @param onAnimationEnd Callback trigger at the end of the animation
  26655. * @returns Nullable animation
  26656. */
  26657. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26658. /**
  26659. * Return the array of runtime animations currently using this animation
  26660. */
  26661. readonly runtimeAnimations: RuntimeAnimation[];
  26662. /**
  26663. * Specifies if any of the runtime animations are currently running
  26664. */
  26665. readonly hasRunningRuntimeAnimations: boolean;
  26666. /**
  26667. * Initializes the animation
  26668. * @param name Name of the animation
  26669. * @param targetProperty Property to animate
  26670. * @param framePerSecond The frames per second of the animation
  26671. * @param dataType The data type of the animation
  26672. * @param loopMode The loop mode of the animation
  26673. * @param enableBlending Specifies if blending should be enabled
  26674. */
  26675. constructor(
  26676. /**Name of the animation */
  26677. name: string,
  26678. /**Property to animate */
  26679. targetProperty: string,
  26680. /**The frames per second of the animation */
  26681. framePerSecond: number,
  26682. /**The data type of the animation */
  26683. dataType: number,
  26684. /**The loop mode of the animation */
  26685. loopMode?: number | undefined,
  26686. /**Specifies if blending should be enabled */
  26687. enableBlending?: boolean | undefined);
  26688. /**
  26689. * Converts the animation to a string
  26690. * @param fullDetails support for multiple levels of logging within scene loading
  26691. * @returns String form of the animation
  26692. */
  26693. toString(fullDetails?: boolean): string;
  26694. /**
  26695. * Add an event to this animation
  26696. * @param event Event to add
  26697. */
  26698. addEvent(event: AnimationEvent): void;
  26699. /**
  26700. * Remove all events found at the given frame
  26701. * @param frame The frame to remove events from
  26702. */
  26703. removeEvents(frame: number): void;
  26704. /**
  26705. * Retrieves all the events from the animation
  26706. * @returns Events from the animation
  26707. */
  26708. getEvents(): AnimationEvent[];
  26709. /**
  26710. * Creates an animation range
  26711. * @param name Name of the animation range
  26712. * @param from Starting frame of the animation range
  26713. * @param to Ending frame of the animation
  26714. */
  26715. createRange(name: string, from: number, to: number): void;
  26716. /**
  26717. * Deletes an animation range by name
  26718. * @param name Name of the animation range to delete
  26719. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26720. */
  26721. deleteRange(name: string, deleteFrames?: boolean): void;
  26722. /**
  26723. * Gets the animation range by name, or null if not defined
  26724. * @param name Name of the animation range
  26725. * @returns Nullable animation range
  26726. */
  26727. getRange(name: string): Nullable<AnimationRange>;
  26728. /**
  26729. * Gets the key frames from the animation
  26730. * @returns The key frames of the animation
  26731. */
  26732. getKeys(): Array<IAnimationKey>;
  26733. /**
  26734. * Gets the highest frame rate of the animation
  26735. * @returns Highest frame rate of the animation
  26736. */
  26737. getHighestFrame(): number;
  26738. /**
  26739. * Gets the easing function of the animation
  26740. * @returns Easing function of the animation
  26741. */
  26742. getEasingFunction(): IEasingFunction;
  26743. /**
  26744. * Sets the easing function of the animation
  26745. * @param easingFunction A custom mathematical formula for animation
  26746. */
  26747. setEasingFunction(easingFunction: EasingFunction): void;
  26748. /**
  26749. * Interpolates a scalar linearly
  26750. * @param startValue Start value of the animation curve
  26751. * @param endValue End value of the animation curve
  26752. * @param gradient Scalar amount to interpolate
  26753. * @returns Interpolated scalar value
  26754. */
  26755. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26756. /**
  26757. * Interpolates a scalar cubically
  26758. * @param startValue Start value of the animation curve
  26759. * @param outTangent End tangent of the animation
  26760. * @param endValue End value of the animation curve
  26761. * @param inTangent Start tangent of the animation curve
  26762. * @param gradient Scalar amount to interpolate
  26763. * @returns Interpolated scalar value
  26764. */
  26765. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26766. /**
  26767. * Interpolates a quaternion using a spherical linear interpolation
  26768. * @param startValue Start value of the animation curve
  26769. * @param endValue End value of the animation curve
  26770. * @param gradient Scalar amount to interpolate
  26771. * @returns Interpolated quaternion value
  26772. */
  26773. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26774. /**
  26775. * Interpolates a quaternion cubically
  26776. * @param startValue Start value of the animation curve
  26777. * @param outTangent End tangent of the animation curve
  26778. * @param endValue End value of the animation curve
  26779. * @param inTangent Start tangent of the animation curve
  26780. * @param gradient Scalar amount to interpolate
  26781. * @returns Interpolated quaternion value
  26782. */
  26783. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26784. /**
  26785. * Interpolates a Vector3 linearl
  26786. * @param startValue Start value of the animation curve
  26787. * @param endValue End value of the animation curve
  26788. * @param gradient Scalar amount to interpolate
  26789. * @returns Interpolated scalar value
  26790. */
  26791. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26792. /**
  26793. * Interpolates a Vector3 cubically
  26794. * @param startValue Start value of the animation curve
  26795. * @param outTangent End tangent of the animation
  26796. * @param endValue End value of the animation curve
  26797. * @param inTangent Start tangent of the animation curve
  26798. * @param gradient Scalar amount to interpolate
  26799. * @returns InterpolatedVector3 value
  26800. */
  26801. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26802. /**
  26803. * Interpolates a Vector2 linearly
  26804. * @param startValue Start value of the animation curve
  26805. * @param endValue End value of the animation curve
  26806. * @param gradient Scalar amount to interpolate
  26807. * @returns Interpolated Vector2 value
  26808. */
  26809. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26810. /**
  26811. * Interpolates a Vector2 cubically
  26812. * @param startValue Start value of the animation curve
  26813. * @param outTangent End tangent of the animation
  26814. * @param endValue End value of the animation curve
  26815. * @param inTangent Start tangent of the animation curve
  26816. * @param gradient Scalar amount to interpolate
  26817. * @returns Interpolated Vector2 value
  26818. */
  26819. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26820. /**
  26821. * Interpolates a size linearly
  26822. * @param startValue Start value of the animation curve
  26823. * @param endValue End value of the animation curve
  26824. * @param gradient Scalar amount to interpolate
  26825. * @returns Interpolated Size value
  26826. */
  26827. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26828. /**
  26829. * Interpolates a Color3 linearly
  26830. * @param startValue Start value of the animation curve
  26831. * @param endValue End value of the animation curve
  26832. * @param gradient Scalar amount to interpolate
  26833. * @returns Interpolated Color3 value
  26834. */
  26835. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26836. /**
  26837. * @hidden Internal use only
  26838. */
  26839. _getKeyValue(value: any): any;
  26840. /**
  26841. * @hidden Internal use only
  26842. */
  26843. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26844. /**
  26845. * Defines the function to use to interpolate matrices
  26846. * @param startValue defines the start matrix
  26847. * @param endValue defines the end matrix
  26848. * @param gradient defines the gradient between both matrices
  26849. * @param result defines an optional target matrix where to store the interpolation
  26850. * @returns the interpolated matrix
  26851. */
  26852. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26853. /**
  26854. * Makes a copy of the animation
  26855. * @returns Cloned animation
  26856. */
  26857. clone(): Animation;
  26858. /**
  26859. * Sets the key frames of the animation
  26860. * @param values The animation key frames to set
  26861. */
  26862. setKeys(values: Array<IAnimationKey>): void;
  26863. /**
  26864. * Serializes the animation to an object
  26865. * @returns Serialized object
  26866. */
  26867. serialize(): any;
  26868. /**
  26869. * Float animation type
  26870. */
  26871. private static _ANIMATIONTYPE_FLOAT;
  26872. /**
  26873. * Vector3 animation type
  26874. */
  26875. private static _ANIMATIONTYPE_VECTOR3;
  26876. /**
  26877. * Quaternion animation type
  26878. */
  26879. private static _ANIMATIONTYPE_QUATERNION;
  26880. /**
  26881. * Matrix animation type
  26882. */
  26883. private static _ANIMATIONTYPE_MATRIX;
  26884. /**
  26885. * Color3 animation type
  26886. */
  26887. private static _ANIMATIONTYPE_COLOR3;
  26888. /**
  26889. * Vector2 animation type
  26890. */
  26891. private static _ANIMATIONTYPE_VECTOR2;
  26892. /**
  26893. * Size animation type
  26894. */
  26895. private static _ANIMATIONTYPE_SIZE;
  26896. /**
  26897. * Relative Loop Mode
  26898. */
  26899. private static _ANIMATIONLOOPMODE_RELATIVE;
  26900. /**
  26901. * Cycle Loop Mode
  26902. */
  26903. private static _ANIMATIONLOOPMODE_CYCLE;
  26904. /**
  26905. * Constant Loop Mode
  26906. */
  26907. private static _ANIMATIONLOOPMODE_CONSTANT;
  26908. /**
  26909. * Get the float animation type
  26910. */
  26911. static readonly ANIMATIONTYPE_FLOAT: number;
  26912. /**
  26913. * Get the Vector3 animation type
  26914. */
  26915. static readonly ANIMATIONTYPE_VECTOR3: number;
  26916. /**
  26917. * Get the Vector2 animation type
  26918. */
  26919. static readonly ANIMATIONTYPE_VECTOR2: number;
  26920. /**
  26921. * Get the Size animation type
  26922. */
  26923. static readonly ANIMATIONTYPE_SIZE: number;
  26924. /**
  26925. * Get the Quaternion animation type
  26926. */
  26927. static readonly ANIMATIONTYPE_QUATERNION: number;
  26928. /**
  26929. * Get the Matrix animation type
  26930. */
  26931. static readonly ANIMATIONTYPE_MATRIX: number;
  26932. /**
  26933. * Get the Color3 animation type
  26934. */
  26935. static readonly ANIMATIONTYPE_COLOR3: number;
  26936. /**
  26937. * Get the Relative Loop Mode
  26938. */
  26939. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26940. /**
  26941. * Get the Cycle Loop Mode
  26942. */
  26943. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26944. /**
  26945. * Get the Constant Loop Mode
  26946. */
  26947. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26948. /** @hidden */
  26949. static _UniversalLerp(left: any, right: any, amount: number): any;
  26950. /**
  26951. * Parses an animation object and creates an animation
  26952. * @param parsedAnimation Parsed animation object
  26953. * @returns Animation object
  26954. */
  26955. static Parse(parsedAnimation: any): Animation;
  26956. /**
  26957. * Appends the serialized animations from the source animations
  26958. * @param source Source containing the animations
  26959. * @param destination Target to store the animations
  26960. */
  26961. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26962. }
  26963. }
  26964. declare module "babylonjs/Materials/Textures/baseTexture" {
  26965. import { Observable } from "babylonjs/Misc/observable";
  26966. import { IAnimatable } from "babylonjs/Misc/tools";
  26967. import { Nullable } from "babylonjs/types";
  26968. import { Scene } from "babylonjs/scene";
  26969. import { Matrix, ISize } from "babylonjs/Maths/math";
  26970. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26971. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26972. /**
  26973. * Base class of all the textures in babylon.
  26974. * It groups all the common properties the materials, post process, lights... might need
  26975. * in order to make a correct use of the texture.
  26976. */
  26977. export class BaseTexture implements IAnimatable {
  26978. /**
  26979. * Default anisotropic filtering level for the application.
  26980. * It is set to 4 as a good tradeoff between perf and quality.
  26981. */
  26982. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26983. /**
  26984. * Gets or sets the unique id of the texture
  26985. */
  26986. uniqueId: number;
  26987. /**
  26988. * Define the name of the texture.
  26989. */
  26990. name: string;
  26991. /**
  26992. * Gets or sets an object used to store user defined information.
  26993. */
  26994. metadata: any;
  26995. /**
  26996. * For internal use only. Please do not use.
  26997. */
  26998. reservedDataStore: any;
  26999. private _hasAlpha;
  27000. /**
  27001. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27002. */
  27003. hasAlpha: boolean;
  27004. /**
  27005. * Defines if the alpha value should be determined via the rgb values.
  27006. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27007. */
  27008. getAlphaFromRGB: boolean;
  27009. /**
  27010. * Intensity or strength of the texture.
  27011. * It is commonly used by materials to fine tune the intensity of the texture
  27012. */
  27013. level: number;
  27014. /**
  27015. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27016. * This is part of the texture as textures usually maps to one uv set.
  27017. */
  27018. coordinatesIndex: number;
  27019. private _coordinatesMode;
  27020. /**
  27021. * How a texture is mapped.
  27022. *
  27023. * | Value | Type | Description |
  27024. * | ----- | ----------------------------------- | ----------- |
  27025. * | 0 | EXPLICIT_MODE | |
  27026. * | 1 | SPHERICAL_MODE | |
  27027. * | 2 | PLANAR_MODE | |
  27028. * | 3 | CUBIC_MODE | |
  27029. * | 4 | PROJECTION_MODE | |
  27030. * | 5 | SKYBOX_MODE | |
  27031. * | 6 | INVCUBIC_MODE | |
  27032. * | 7 | EQUIRECTANGULAR_MODE | |
  27033. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27034. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27035. */
  27036. coordinatesMode: number;
  27037. /**
  27038. * | Value | Type | Description |
  27039. * | ----- | ------------------ | ----------- |
  27040. * | 0 | CLAMP_ADDRESSMODE | |
  27041. * | 1 | WRAP_ADDRESSMODE | |
  27042. * | 2 | MIRROR_ADDRESSMODE | |
  27043. */
  27044. wrapU: number;
  27045. /**
  27046. * | Value | Type | Description |
  27047. * | ----- | ------------------ | ----------- |
  27048. * | 0 | CLAMP_ADDRESSMODE | |
  27049. * | 1 | WRAP_ADDRESSMODE | |
  27050. * | 2 | MIRROR_ADDRESSMODE | |
  27051. */
  27052. wrapV: number;
  27053. /**
  27054. * | Value | Type | Description |
  27055. * | ----- | ------------------ | ----------- |
  27056. * | 0 | CLAMP_ADDRESSMODE | |
  27057. * | 1 | WRAP_ADDRESSMODE | |
  27058. * | 2 | MIRROR_ADDRESSMODE | |
  27059. */
  27060. wrapR: number;
  27061. /**
  27062. * With compliant hardware and browser (supporting anisotropic filtering)
  27063. * this defines the level of anisotropic filtering in the texture.
  27064. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27065. */
  27066. anisotropicFilteringLevel: number;
  27067. /**
  27068. * Define if the texture is a cube texture or if false a 2d texture.
  27069. */
  27070. isCube: boolean;
  27071. /**
  27072. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27073. */
  27074. is3D: boolean;
  27075. /**
  27076. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27077. * HDR texture are usually stored in linear space.
  27078. * This only impacts the PBR and Background materials
  27079. */
  27080. gammaSpace: boolean;
  27081. /**
  27082. * Gets whether or not the texture contains RGBD data.
  27083. */
  27084. readonly isRGBD: boolean;
  27085. /**
  27086. * Is Z inverted in the texture (useful in a cube texture).
  27087. */
  27088. invertZ: boolean;
  27089. /**
  27090. * Are mip maps generated for this texture or not.
  27091. */
  27092. readonly noMipmap: boolean;
  27093. /**
  27094. * @hidden
  27095. */
  27096. lodLevelInAlpha: boolean;
  27097. /**
  27098. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27099. */
  27100. lodGenerationOffset: number;
  27101. /**
  27102. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27103. */
  27104. lodGenerationScale: number;
  27105. /**
  27106. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27107. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27108. * average roughness values.
  27109. */
  27110. linearSpecularLOD: boolean;
  27111. /**
  27112. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27113. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27114. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27115. */
  27116. irradianceTexture: Nullable<BaseTexture>;
  27117. /**
  27118. * Define if the texture is a render target.
  27119. */
  27120. isRenderTarget: boolean;
  27121. /**
  27122. * Define the unique id of the texture in the scene.
  27123. */
  27124. readonly uid: string;
  27125. /**
  27126. * Return a string representation of the texture.
  27127. * @returns the texture as a string
  27128. */
  27129. toString(): string;
  27130. /**
  27131. * Get the class name of the texture.
  27132. * @returns "BaseTexture"
  27133. */
  27134. getClassName(): string;
  27135. /**
  27136. * Define the list of animation attached to the texture.
  27137. */
  27138. animations: import("babylonjs/Animations/animation").Animation[];
  27139. /**
  27140. * An event triggered when the texture is disposed.
  27141. */
  27142. onDisposeObservable: Observable<BaseTexture>;
  27143. private _onDisposeObserver;
  27144. /**
  27145. * Callback triggered when the texture has been disposed.
  27146. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27147. */
  27148. onDispose: () => void;
  27149. /**
  27150. * Define the current state of the loading sequence when in delayed load mode.
  27151. */
  27152. delayLoadState: number;
  27153. private _scene;
  27154. /** @hidden */
  27155. _texture: Nullable<InternalTexture>;
  27156. private _uid;
  27157. /**
  27158. * Define if the texture is preventinga material to render or not.
  27159. * If not and the texture is not ready, the engine will use a default black texture instead.
  27160. */
  27161. readonly isBlocking: boolean;
  27162. /**
  27163. * Instantiates a new BaseTexture.
  27164. * Base class of all the textures in babylon.
  27165. * It groups all the common properties the materials, post process, lights... might need
  27166. * in order to make a correct use of the texture.
  27167. * @param scene Define the scene the texture blongs to
  27168. */
  27169. constructor(scene: Nullable<Scene>);
  27170. /**
  27171. * Get the scene the texture belongs to.
  27172. * @returns the scene or null if undefined
  27173. */
  27174. getScene(): Nullable<Scene>;
  27175. /**
  27176. * Get the texture transform matrix used to offset tile the texture for istance.
  27177. * @returns the transformation matrix
  27178. */
  27179. getTextureMatrix(): Matrix;
  27180. /**
  27181. * Get the texture reflection matrix used to rotate/transform the reflection.
  27182. * @returns the reflection matrix
  27183. */
  27184. getReflectionTextureMatrix(): Matrix;
  27185. /**
  27186. * Get the underlying lower level texture from Babylon.
  27187. * @returns the insternal texture
  27188. */
  27189. getInternalTexture(): Nullable<InternalTexture>;
  27190. /**
  27191. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27192. * @returns true if ready or not blocking
  27193. */
  27194. isReadyOrNotBlocking(): boolean;
  27195. /**
  27196. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27197. * @returns true if fully ready
  27198. */
  27199. isReady(): boolean;
  27200. private _cachedSize;
  27201. /**
  27202. * Get the size of the texture.
  27203. * @returns the texture size.
  27204. */
  27205. getSize(): ISize;
  27206. /**
  27207. * Get the base size of the texture.
  27208. * It can be different from the size if the texture has been resized for POT for instance
  27209. * @returns the base size
  27210. */
  27211. getBaseSize(): ISize;
  27212. /**
  27213. * Update the sampling mode of the texture.
  27214. * Default is Trilinear mode.
  27215. *
  27216. * | Value | Type | Description |
  27217. * | ----- | ------------------ | ----------- |
  27218. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27219. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27220. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27221. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27222. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27223. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27224. * | 7 | NEAREST_LINEAR | |
  27225. * | 8 | NEAREST_NEAREST | |
  27226. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27227. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27228. * | 11 | LINEAR_LINEAR | |
  27229. * | 12 | LINEAR_NEAREST | |
  27230. *
  27231. * > _mag_: magnification filter (close to the viewer)
  27232. * > _min_: minification filter (far from the viewer)
  27233. * > _mip_: filter used between mip map levels
  27234. *@param samplingMode Define the new sampling mode of the texture
  27235. */
  27236. updateSamplingMode(samplingMode: number): void;
  27237. /**
  27238. * Scales the texture if is `canRescale()`
  27239. * @param ratio the resize factor we want to use to rescale
  27240. */
  27241. scale(ratio: number): void;
  27242. /**
  27243. * Get if the texture can rescale.
  27244. */
  27245. readonly canRescale: boolean;
  27246. /** @hidden */
  27247. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27248. /** @hidden */
  27249. _rebuild(): void;
  27250. /**
  27251. * Triggers the load sequence in delayed load mode.
  27252. */
  27253. delayLoad(): void;
  27254. /**
  27255. * Clones the texture.
  27256. * @returns the cloned texture
  27257. */
  27258. clone(): Nullable<BaseTexture>;
  27259. /**
  27260. * Get the texture underlying type (INT, FLOAT...)
  27261. */
  27262. readonly textureType: number;
  27263. /**
  27264. * Get the texture underlying format (RGB, RGBA...)
  27265. */
  27266. readonly textureFormat: number;
  27267. /**
  27268. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27269. * This will returns an RGBA array buffer containing either in values (0-255) or
  27270. * float values (0-1) depending of the underlying buffer type.
  27271. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27272. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27273. * @param buffer defines a user defined buffer to fill with data (can be null)
  27274. * @returns The Array buffer containing the pixels data.
  27275. */
  27276. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27277. /**
  27278. * Release and destroy the underlying lower level texture aka internalTexture.
  27279. */
  27280. releaseInternalTexture(): void;
  27281. /**
  27282. * Get the polynomial representation of the texture data.
  27283. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27284. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27285. */
  27286. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27287. /** @hidden */
  27288. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27289. /** @hidden */
  27290. readonly _lodTextureMid: Nullable<BaseTexture>;
  27291. /** @hidden */
  27292. readonly _lodTextureLow: Nullable<BaseTexture>;
  27293. /**
  27294. * Dispose the texture and release its associated resources.
  27295. */
  27296. dispose(): void;
  27297. /**
  27298. * Serialize the texture into a JSON representation that can be parsed later on.
  27299. * @returns the JSON representation of the texture
  27300. */
  27301. serialize(): any;
  27302. /**
  27303. * Helper function to be called back once a list of texture contains only ready textures.
  27304. * @param textures Define the list of textures to wait for
  27305. * @param callback Define the callback triggered once the entire list will be ready
  27306. */
  27307. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27308. }
  27309. }
  27310. declare module "babylonjs/Materials/uniformBuffer" {
  27311. import { Nullable, FloatArray } from "babylonjs/types";
  27312. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27313. import { Engine } from "babylonjs/Engines/engine";
  27314. import { Effect } from "babylonjs/Materials/effect";
  27315. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27316. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27317. /**
  27318. * Uniform buffer objects.
  27319. *
  27320. * Handles blocks of uniform on the GPU.
  27321. *
  27322. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27323. *
  27324. * For more information, please refer to :
  27325. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27326. */
  27327. export class UniformBuffer {
  27328. private _engine;
  27329. private _buffer;
  27330. private _data;
  27331. private _bufferData;
  27332. private _dynamic?;
  27333. private _uniformLocations;
  27334. private _uniformSizes;
  27335. private _uniformLocationPointer;
  27336. private _needSync;
  27337. private _noUBO;
  27338. private _currentEffect;
  27339. private static _MAX_UNIFORM_SIZE;
  27340. private static _tempBuffer;
  27341. /**
  27342. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27343. * This is dynamic to allow compat with webgl 1 and 2.
  27344. * You will need to pass the name of the uniform as well as the value.
  27345. */
  27346. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27347. /**
  27348. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27349. * This is dynamic to allow compat with webgl 1 and 2.
  27350. * You will need to pass the name of the uniform as well as the value.
  27351. */
  27352. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27353. /**
  27354. * Lambda to Update a single float in a uniform buffer.
  27355. * This is dynamic to allow compat with webgl 1 and 2.
  27356. * You will need to pass the name of the uniform as well as the value.
  27357. */
  27358. updateFloat: (name: string, x: number) => void;
  27359. /**
  27360. * Lambda to Update a vec2 of float in a uniform buffer.
  27361. * This is dynamic to allow compat with webgl 1 and 2.
  27362. * You will need to pass the name of the uniform as well as the value.
  27363. */
  27364. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27365. /**
  27366. * Lambda to Update a vec3 of float in a uniform buffer.
  27367. * This is dynamic to allow compat with webgl 1 and 2.
  27368. * You will need to pass the name of the uniform as well as the value.
  27369. */
  27370. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27371. /**
  27372. * Lambda to Update a vec4 of float in a uniform buffer.
  27373. * This is dynamic to allow compat with webgl 1 and 2.
  27374. * You will need to pass the name of the uniform as well as the value.
  27375. */
  27376. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27377. /**
  27378. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27379. * This is dynamic to allow compat with webgl 1 and 2.
  27380. * You will need to pass the name of the uniform as well as the value.
  27381. */
  27382. updateMatrix: (name: string, mat: Matrix) => void;
  27383. /**
  27384. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27385. * This is dynamic to allow compat with webgl 1 and 2.
  27386. * You will need to pass the name of the uniform as well as the value.
  27387. */
  27388. updateVector3: (name: string, vector: Vector3) => void;
  27389. /**
  27390. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27391. * This is dynamic to allow compat with webgl 1 and 2.
  27392. * You will need to pass the name of the uniform as well as the value.
  27393. */
  27394. updateVector4: (name: string, vector: Vector4) => void;
  27395. /**
  27396. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27397. * This is dynamic to allow compat with webgl 1 and 2.
  27398. * You will need to pass the name of the uniform as well as the value.
  27399. */
  27400. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27401. /**
  27402. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27403. * This is dynamic to allow compat with webgl 1 and 2.
  27404. * You will need to pass the name of the uniform as well as the value.
  27405. */
  27406. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27407. /**
  27408. * Instantiates a new Uniform buffer objects.
  27409. *
  27410. * Handles blocks of uniform on the GPU.
  27411. *
  27412. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27413. *
  27414. * For more information, please refer to :
  27415. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27416. * @param engine Define the engine the buffer is associated with
  27417. * @param data Define the data contained in the buffer
  27418. * @param dynamic Define if the buffer is updatable
  27419. */
  27420. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27421. /**
  27422. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27423. * or just falling back on setUniformXXX calls.
  27424. */
  27425. readonly useUbo: boolean;
  27426. /**
  27427. * Indicates if the WebGL underlying uniform buffer is in sync
  27428. * with the javascript cache data.
  27429. */
  27430. readonly isSync: boolean;
  27431. /**
  27432. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27433. * Also, a dynamic UniformBuffer will disable cache verification and always
  27434. * update the underlying WebGL uniform buffer to the GPU.
  27435. * @returns if Dynamic, otherwise false
  27436. */
  27437. isDynamic(): boolean;
  27438. /**
  27439. * The data cache on JS side.
  27440. * @returns the underlying data as a float array
  27441. */
  27442. getData(): Float32Array;
  27443. /**
  27444. * The underlying WebGL Uniform buffer.
  27445. * @returns the webgl buffer
  27446. */
  27447. getBuffer(): Nullable<DataBuffer>;
  27448. /**
  27449. * std140 layout specifies how to align data within an UBO structure.
  27450. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27451. * for specs.
  27452. */
  27453. private _fillAlignment;
  27454. /**
  27455. * Adds an uniform in the buffer.
  27456. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27457. * for the layout to be correct !
  27458. * @param name Name of the uniform, as used in the uniform block in the shader.
  27459. * @param size Data size, or data directly.
  27460. */
  27461. addUniform(name: string, size: number | number[]): void;
  27462. /**
  27463. * Adds a Matrix 4x4 to the uniform buffer.
  27464. * @param name Name of the uniform, as used in the uniform block in the shader.
  27465. * @param mat A 4x4 matrix.
  27466. */
  27467. addMatrix(name: string, mat: Matrix): void;
  27468. /**
  27469. * Adds a vec2 to the uniform buffer.
  27470. * @param name Name of the uniform, as used in the uniform block in the shader.
  27471. * @param x Define the x component value of the vec2
  27472. * @param y Define the y component value of the vec2
  27473. */
  27474. addFloat2(name: string, x: number, y: number): void;
  27475. /**
  27476. * Adds a vec3 to the uniform buffer.
  27477. * @param name Name of the uniform, as used in the uniform block in the shader.
  27478. * @param x Define the x component value of the vec3
  27479. * @param y Define the y component value of the vec3
  27480. * @param z Define the z component value of the vec3
  27481. */
  27482. addFloat3(name: string, x: number, y: number, z: number): void;
  27483. /**
  27484. * Adds a vec3 to the uniform buffer.
  27485. * @param name Name of the uniform, as used in the uniform block in the shader.
  27486. * @param color Define the vec3 from a Color
  27487. */
  27488. addColor3(name: string, color: Color3): void;
  27489. /**
  27490. * Adds a vec4 to the uniform buffer.
  27491. * @param name Name of the uniform, as used in the uniform block in the shader.
  27492. * @param color Define the rgb components from a Color
  27493. * @param alpha Define the a component of the vec4
  27494. */
  27495. addColor4(name: string, color: Color3, alpha: number): void;
  27496. /**
  27497. * Adds a vec3 to the uniform buffer.
  27498. * @param name Name of the uniform, as used in the uniform block in the shader.
  27499. * @param vector Define the vec3 components from a Vector
  27500. */
  27501. addVector3(name: string, vector: Vector3): void;
  27502. /**
  27503. * Adds a Matrix 3x3 to the uniform buffer.
  27504. * @param name Name of the uniform, as used in the uniform block in the shader.
  27505. */
  27506. addMatrix3x3(name: string): void;
  27507. /**
  27508. * Adds a Matrix 2x2 to the uniform buffer.
  27509. * @param name Name of the uniform, as used in the uniform block in the shader.
  27510. */
  27511. addMatrix2x2(name: string): void;
  27512. /**
  27513. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27514. */
  27515. create(): void;
  27516. /** @hidden */
  27517. _rebuild(): void;
  27518. /**
  27519. * Updates the WebGL Uniform Buffer on the GPU.
  27520. * If the `dynamic` flag is set to true, no cache comparison is done.
  27521. * Otherwise, the buffer will be updated only if the cache differs.
  27522. */
  27523. update(): void;
  27524. /**
  27525. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27526. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27527. * @param data Define the flattened data
  27528. * @param size Define the size of the data.
  27529. */
  27530. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27531. private _updateMatrix3x3ForUniform;
  27532. private _updateMatrix3x3ForEffect;
  27533. private _updateMatrix2x2ForEffect;
  27534. private _updateMatrix2x2ForUniform;
  27535. private _updateFloatForEffect;
  27536. private _updateFloatForUniform;
  27537. private _updateFloat2ForEffect;
  27538. private _updateFloat2ForUniform;
  27539. private _updateFloat3ForEffect;
  27540. private _updateFloat3ForUniform;
  27541. private _updateFloat4ForEffect;
  27542. private _updateFloat4ForUniform;
  27543. private _updateMatrixForEffect;
  27544. private _updateMatrixForUniform;
  27545. private _updateVector3ForEffect;
  27546. private _updateVector3ForUniform;
  27547. private _updateVector4ForEffect;
  27548. private _updateVector4ForUniform;
  27549. private _updateColor3ForEffect;
  27550. private _updateColor3ForUniform;
  27551. private _updateColor4ForEffect;
  27552. private _updateColor4ForUniform;
  27553. /**
  27554. * Sets a sampler uniform on the effect.
  27555. * @param name Define the name of the sampler.
  27556. * @param texture Define the texture to set in the sampler
  27557. */
  27558. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27559. /**
  27560. * Directly updates the value of the uniform in the cache AND on the GPU.
  27561. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27562. * @param data Define the flattened data
  27563. */
  27564. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27565. /**
  27566. * Binds this uniform buffer to an effect.
  27567. * @param effect Define the effect to bind the buffer to
  27568. * @param name Name of the uniform block in the shader.
  27569. */
  27570. bindToEffect(effect: Effect, name: string): void;
  27571. /**
  27572. * Disposes the uniform buffer.
  27573. */
  27574. dispose(): void;
  27575. }
  27576. }
  27577. declare module "babylonjs/Audio/analyser" {
  27578. import { Scene } from "babylonjs/scene";
  27579. /**
  27580. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27582. */
  27583. export class Analyser {
  27584. /**
  27585. * Gets or sets the smoothing
  27586. * @ignorenaming
  27587. */
  27588. SMOOTHING: number;
  27589. /**
  27590. * Gets or sets the FFT table size
  27591. * @ignorenaming
  27592. */
  27593. FFT_SIZE: number;
  27594. /**
  27595. * Gets or sets the bar graph amplitude
  27596. * @ignorenaming
  27597. */
  27598. BARGRAPHAMPLITUDE: number;
  27599. /**
  27600. * Gets or sets the position of the debug canvas
  27601. * @ignorenaming
  27602. */
  27603. DEBUGCANVASPOS: {
  27604. x: number;
  27605. y: number;
  27606. };
  27607. /**
  27608. * Gets or sets the debug canvas size
  27609. * @ignorenaming
  27610. */
  27611. DEBUGCANVASSIZE: {
  27612. width: number;
  27613. height: number;
  27614. };
  27615. private _byteFreqs;
  27616. private _byteTime;
  27617. private _floatFreqs;
  27618. private _webAudioAnalyser;
  27619. private _debugCanvas;
  27620. private _debugCanvasContext;
  27621. private _scene;
  27622. private _registerFunc;
  27623. private _audioEngine;
  27624. /**
  27625. * Creates a new analyser
  27626. * @param scene defines hosting scene
  27627. */
  27628. constructor(scene: Scene);
  27629. /**
  27630. * Get the number of data values you will have to play with for the visualization
  27631. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27632. * @returns a number
  27633. */
  27634. getFrequencyBinCount(): number;
  27635. /**
  27636. * Gets the current frequency data as a byte array
  27637. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27638. * @returns a Uint8Array
  27639. */
  27640. getByteFrequencyData(): Uint8Array;
  27641. /**
  27642. * Gets the current waveform as a byte array
  27643. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27644. * @returns a Uint8Array
  27645. */
  27646. getByteTimeDomainData(): Uint8Array;
  27647. /**
  27648. * Gets the current frequency data as a float array
  27649. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27650. * @returns a Float32Array
  27651. */
  27652. getFloatFrequencyData(): Float32Array;
  27653. /**
  27654. * Renders the debug canvas
  27655. */
  27656. drawDebugCanvas(): void;
  27657. /**
  27658. * Stops rendering the debug canvas and removes it
  27659. */
  27660. stopDebugCanvas(): void;
  27661. /**
  27662. * Connects two audio nodes
  27663. * @param inputAudioNode defines first node to connect
  27664. * @param outputAudioNode defines second node to connect
  27665. */
  27666. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27667. /**
  27668. * Releases all associated resources
  27669. */
  27670. dispose(): void;
  27671. }
  27672. }
  27673. declare module "babylonjs/Audio/audioEngine" {
  27674. import { IDisposable } from "babylonjs/scene";
  27675. import { Analyser } from "babylonjs/Audio/analyser";
  27676. import { Nullable } from "babylonjs/types";
  27677. import { Observable } from "babylonjs/Misc/observable";
  27678. /**
  27679. * This represents an audio engine and it is responsible
  27680. * to play, synchronize and analyse sounds throughout the application.
  27681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27682. */
  27683. export interface IAudioEngine extends IDisposable {
  27684. /**
  27685. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27686. */
  27687. readonly canUseWebAudio: boolean;
  27688. /**
  27689. * Gets the current AudioContext if available.
  27690. */
  27691. readonly audioContext: Nullable<AudioContext>;
  27692. /**
  27693. * The master gain node defines the global audio volume of your audio engine.
  27694. */
  27695. readonly masterGain: GainNode;
  27696. /**
  27697. * Gets whether or not mp3 are supported by your browser.
  27698. */
  27699. readonly isMP3supported: boolean;
  27700. /**
  27701. * Gets whether or not ogg are supported by your browser.
  27702. */
  27703. readonly isOGGsupported: boolean;
  27704. /**
  27705. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27706. * @ignoreNaming
  27707. */
  27708. WarnedWebAudioUnsupported: boolean;
  27709. /**
  27710. * Defines if the audio engine relies on a custom unlocked button.
  27711. * In this case, the embedded button will not be displayed.
  27712. */
  27713. useCustomUnlockedButton: boolean;
  27714. /**
  27715. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27716. */
  27717. readonly unlocked: boolean;
  27718. /**
  27719. * Event raised when audio has been unlocked on the browser.
  27720. */
  27721. onAudioUnlockedObservable: Observable<AudioEngine>;
  27722. /**
  27723. * Event raised when audio has been locked on the browser.
  27724. */
  27725. onAudioLockedObservable: Observable<AudioEngine>;
  27726. /**
  27727. * Flags the audio engine in Locked state.
  27728. * This happens due to new browser policies preventing audio to autoplay.
  27729. */
  27730. lock(): void;
  27731. /**
  27732. * Unlocks the audio engine once a user action has been done on the dom.
  27733. * This is helpful to resume play once browser policies have been satisfied.
  27734. */
  27735. unlock(): void;
  27736. }
  27737. /**
  27738. * This represents the default audio engine used in babylon.
  27739. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27741. */
  27742. export class AudioEngine implements IAudioEngine {
  27743. private _audioContext;
  27744. private _audioContextInitialized;
  27745. private _muteButton;
  27746. private _hostElement;
  27747. /**
  27748. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27749. */
  27750. canUseWebAudio: boolean;
  27751. /**
  27752. * The master gain node defines the global audio volume of your audio engine.
  27753. */
  27754. masterGain: GainNode;
  27755. /**
  27756. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27757. * @ignoreNaming
  27758. */
  27759. WarnedWebAudioUnsupported: boolean;
  27760. /**
  27761. * Gets whether or not mp3 are supported by your browser.
  27762. */
  27763. isMP3supported: boolean;
  27764. /**
  27765. * Gets whether or not ogg are supported by your browser.
  27766. */
  27767. isOGGsupported: boolean;
  27768. /**
  27769. * Gets whether audio has been unlocked on the device.
  27770. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27771. * a user interaction has happened.
  27772. */
  27773. unlocked: boolean;
  27774. /**
  27775. * Defines if the audio engine relies on a custom unlocked button.
  27776. * In this case, the embedded button will not be displayed.
  27777. */
  27778. useCustomUnlockedButton: boolean;
  27779. /**
  27780. * Event raised when audio has been unlocked on the browser.
  27781. */
  27782. onAudioUnlockedObservable: Observable<AudioEngine>;
  27783. /**
  27784. * Event raised when audio has been locked on the browser.
  27785. */
  27786. onAudioLockedObservable: Observable<AudioEngine>;
  27787. /**
  27788. * Gets the current AudioContext if available.
  27789. */
  27790. readonly audioContext: Nullable<AudioContext>;
  27791. private _connectedAnalyser;
  27792. /**
  27793. * Instantiates a new audio engine.
  27794. *
  27795. * There should be only one per page as some browsers restrict the number
  27796. * of audio contexts you can create.
  27797. * @param hostElement defines the host element where to display the mute icon if necessary
  27798. */
  27799. constructor(hostElement?: Nullable<HTMLElement>);
  27800. /**
  27801. * Flags the audio engine in Locked state.
  27802. * This happens due to new browser policies preventing audio to autoplay.
  27803. */
  27804. lock(): void;
  27805. /**
  27806. * Unlocks the audio engine once a user action has been done on the dom.
  27807. * This is helpful to resume play once browser policies have been satisfied.
  27808. */
  27809. unlock(): void;
  27810. private _resumeAudioContext;
  27811. private _initializeAudioContext;
  27812. private _tryToRun;
  27813. private _triggerRunningState;
  27814. private _triggerSuspendedState;
  27815. private _displayMuteButton;
  27816. private _moveButtonToTopLeft;
  27817. private _onResize;
  27818. private _hideMuteButton;
  27819. /**
  27820. * Destroy and release the resources associated with the audio ccontext.
  27821. */
  27822. dispose(): void;
  27823. /**
  27824. * Gets the global volume sets on the master gain.
  27825. * @returns the global volume if set or -1 otherwise
  27826. */
  27827. getGlobalVolume(): number;
  27828. /**
  27829. * Sets the global volume of your experience (sets on the master gain).
  27830. * @param newVolume Defines the new global volume of the application
  27831. */
  27832. setGlobalVolume(newVolume: number): void;
  27833. /**
  27834. * Connect the audio engine to an audio analyser allowing some amazing
  27835. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27837. * @param analyser The analyser to connect to the engine
  27838. */
  27839. connectToAnalyser(analyser: Analyser): void;
  27840. }
  27841. }
  27842. declare module "babylonjs/Loading/loadingScreen" {
  27843. /**
  27844. * Interface used to present a loading screen while loading a scene
  27845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27846. */
  27847. export interface ILoadingScreen {
  27848. /**
  27849. * Function called to display the loading screen
  27850. */
  27851. displayLoadingUI: () => void;
  27852. /**
  27853. * Function called to hide the loading screen
  27854. */
  27855. hideLoadingUI: () => void;
  27856. /**
  27857. * Gets or sets the color to use for the background
  27858. */
  27859. loadingUIBackgroundColor: string;
  27860. /**
  27861. * Gets or sets the text to display while loading
  27862. */
  27863. loadingUIText: string;
  27864. }
  27865. /**
  27866. * Class used for the default loading screen
  27867. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27868. */
  27869. export class DefaultLoadingScreen implements ILoadingScreen {
  27870. private _renderingCanvas;
  27871. private _loadingText;
  27872. private _loadingDivBackgroundColor;
  27873. private _loadingDiv;
  27874. private _loadingTextDiv;
  27875. /** Gets or sets the logo url to use for the default loading screen */
  27876. static DefaultLogoUrl: string;
  27877. /** Gets or sets the spinner url to use for the default loading screen */
  27878. static DefaultSpinnerUrl: string;
  27879. /**
  27880. * Creates a new default loading screen
  27881. * @param _renderingCanvas defines the canvas used to render the scene
  27882. * @param _loadingText defines the default text to display
  27883. * @param _loadingDivBackgroundColor defines the default background color
  27884. */
  27885. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27886. /**
  27887. * Function called to display the loading screen
  27888. */
  27889. displayLoadingUI(): void;
  27890. /**
  27891. * Function called to hide the loading screen
  27892. */
  27893. hideLoadingUI(): void;
  27894. /**
  27895. * Gets or sets the text to display while loading
  27896. */
  27897. loadingUIText: string;
  27898. /**
  27899. * Gets or sets the color to use for the background
  27900. */
  27901. loadingUIBackgroundColor: string;
  27902. private _resizeLoadingUI;
  27903. }
  27904. }
  27905. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27906. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27907. import { Engine } from "babylonjs/Engines/engine";
  27908. import { Nullable } from "babylonjs/types";
  27909. /** @hidden */
  27910. export class WebGLPipelineContext implements IPipelineContext {
  27911. engine: Engine;
  27912. program: Nullable<WebGLProgram>;
  27913. context?: WebGLRenderingContext;
  27914. vertexShader?: WebGLShader;
  27915. fragmentShader?: WebGLShader;
  27916. isParallelCompiled: boolean;
  27917. onCompiled?: () => void;
  27918. transformFeedback?: WebGLTransformFeedback | null;
  27919. readonly isAsync: boolean;
  27920. readonly isReady: boolean;
  27921. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27922. }
  27923. }
  27924. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27925. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27926. /** @hidden */
  27927. export class WebGLDataBuffer extends DataBuffer {
  27928. private _buffer;
  27929. constructor(resource: WebGLBuffer);
  27930. readonly underlyingResource: any;
  27931. }
  27932. }
  27933. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27934. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27935. /** @hidden */
  27936. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27937. attributeProcessor(attribute: string): string;
  27938. varyingProcessor(varying: string, isFragment: boolean): string;
  27939. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27940. }
  27941. }
  27942. declare module "babylonjs/Materials/Textures/videoTexture" {
  27943. import { Observable } from "babylonjs/Misc/observable";
  27944. import { Nullable } from "babylonjs/types";
  27945. import { Scene } from "babylonjs/scene";
  27946. import { Texture } from "babylonjs/Materials/Textures/texture";
  27947. /**
  27948. * Settings for finer control over video usage
  27949. */
  27950. export interface VideoTextureSettings {
  27951. /**
  27952. * Applies `autoplay` to video, if specified
  27953. */
  27954. autoPlay?: boolean;
  27955. /**
  27956. * Applies `loop` to video, if specified
  27957. */
  27958. loop?: boolean;
  27959. /**
  27960. * Automatically updates internal texture from video at every frame in the render loop
  27961. */
  27962. autoUpdateTexture: boolean;
  27963. /**
  27964. * Image src displayed during the video loading or until the user interacts with the video.
  27965. */
  27966. poster?: string;
  27967. }
  27968. /**
  27969. * If you want to display a video in your scene, this is the special texture for that.
  27970. * This special texture works similar to other textures, with the exception of a few parameters.
  27971. * @see https://doc.babylonjs.com/how_to/video_texture
  27972. */
  27973. export class VideoTexture extends Texture {
  27974. /**
  27975. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27976. */
  27977. readonly autoUpdateTexture: boolean;
  27978. /**
  27979. * The video instance used by the texture internally
  27980. */
  27981. readonly video: HTMLVideoElement;
  27982. private _onUserActionRequestedObservable;
  27983. /**
  27984. * Event triggerd when a dom action is required by the user to play the video.
  27985. * This happens due to recent changes in browser policies preventing video to auto start.
  27986. */
  27987. readonly onUserActionRequestedObservable: Observable<Texture>;
  27988. private _generateMipMaps;
  27989. private _engine;
  27990. private _stillImageCaptured;
  27991. private _displayingPosterTexture;
  27992. private _settings;
  27993. private _createInternalTextureOnEvent;
  27994. /**
  27995. * Creates a video texture.
  27996. * If you want to display a video in your scene, this is the special texture for that.
  27997. * This special texture works similar to other textures, with the exception of a few parameters.
  27998. * @see https://doc.babylonjs.com/how_to/video_texture
  27999. * @param name optional name, will detect from video source, if not defined
  28000. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28001. * @param scene is obviously the current scene.
  28002. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28003. * @param invertY is false by default but can be used to invert video on Y axis
  28004. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28005. * @param settings allows finer control over video usage
  28006. */
  28007. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28008. private _getName;
  28009. private _getVideo;
  28010. private _createInternalTexture;
  28011. private reset;
  28012. /**
  28013. * @hidden Internal method to initiate `update`.
  28014. */
  28015. _rebuild(): void;
  28016. /**
  28017. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28018. */
  28019. update(): void;
  28020. /**
  28021. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28022. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28023. */
  28024. updateTexture(isVisible: boolean): void;
  28025. protected _updateInternalTexture: () => void;
  28026. /**
  28027. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28028. * @param url New url.
  28029. */
  28030. updateURL(url: string): void;
  28031. /**
  28032. * Dispose the texture and release its associated resources.
  28033. */
  28034. dispose(): void;
  28035. /**
  28036. * Creates a video texture straight from a stream.
  28037. * @param scene Define the scene the texture should be created in
  28038. * @param stream Define the stream the texture should be created from
  28039. * @returns The created video texture as a promise
  28040. */
  28041. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28042. /**
  28043. * Creates a video texture straight from your WebCam video feed.
  28044. * @param scene Define the scene the texture should be created in
  28045. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28046. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28047. * @returns The created video texture as a promise
  28048. */
  28049. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28050. minWidth: number;
  28051. maxWidth: number;
  28052. minHeight: number;
  28053. maxHeight: number;
  28054. deviceId: string;
  28055. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28056. /**
  28057. * Creates a video texture straight from your WebCam video feed.
  28058. * @param scene Define the scene the texture should be created in
  28059. * @param onReady Define a callback to triggered once the texture will be ready
  28060. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28061. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28062. */
  28063. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28064. minWidth: number;
  28065. maxWidth: number;
  28066. minHeight: number;
  28067. maxHeight: number;
  28068. deviceId: string;
  28069. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28070. }
  28071. }
  28072. declare module "babylonjs/Engines/engine" {
  28073. import { Observable } from "babylonjs/Misc/observable";
  28074. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  28075. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  28076. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  28077. import { Camera } from "babylonjs/Cameras/camera";
  28078. import { Scene } from "babylonjs/scene";
  28079. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  28080. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28081. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28082. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  28083. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  28084. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28085. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28086. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  28087. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  28088. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  28089. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  28090. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  28091. import { WebRequest } from "babylonjs/Misc/webRequest";
  28092. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  28093. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28094. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28095. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  28096. import { Material } from "babylonjs/Materials/material";
  28097. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28098. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28099. /**
  28100. * Interface for attribute information associated with buffer instanciation
  28101. */
  28102. export class InstancingAttributeInfo {
  28103. /**
  28104. * Index/offset of the attribute in the vertex shader
  28105. */
  28106. index: number;
  28107. /**
  28108. * size of the attribute, 1, 2, 3 or 4
  28109. */
  28110. attributeSize: number;
  28111. /**
  28112. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28113. * default is FLOAT
  28114. */
  28115. attribyteType: number;
  28116. /**
  28117. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28118. */
  28119. normalized: boolean;
  28120. /**
  28121. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28122. */
  28123. offset: number;
  28124. /**
  28125. * Name of the GLSL attribute, for debugging purpose only
  28126. */
  28127. attributeName: string;
  28128. }
  28129. /**
  28130. * Define options used to create a depth texture
  28131. */
  28132. export class DepthTextureCreationOptions {
  28133. /** Specifies whether or not a stencil should be allocated in the texture */
  28134. generateStencil?: boolean;
  28135. /** Specifies whether or not bilinear filtering is enable on the texture */
  28136. bilinearFiltering?: boolean;
  28137. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28138. comparisonFunction?: number;
  28139. /** Specifies if the created texture is a cube texture */
  28140. isCube?: boolean;
  28141. }
  28142. /**
  28143. * Class used to describe the capabilities of the engine relatively to the current browser
  28144. */
  28145. export class EngineCapabilities {
  28146. /** Maximum textures units per fragment shader */
  28147. maxTexturesImageUnits: number;
  28148. /** Maximum texture units per vertex shader */
  28149. maxVertexTextureImageUnits: number;
  28150. /** Maximum textures units in the entire pipeline */
  28151. maxCombinedTexturesImageUnits: number;
  28152. /** Maximum texture size */
  28153. maxTextureSize: number;
  28154. /** Maximum cube texture size */
  28155. maxCubemapTextureSize: number;
  28156. /** Maximum render texture size */
  28157. maxRenderTextureSize: number;
  28158. /** Maximum number of vertex attributes */
  28159. maxVertexAttribs: number;
  28160. /** Maximum number of varyings */
  28161. maxVaryingVectors: number;
  28162. /** Maximum number of uniforms per vertex shader */
  28163. maxVertexUniformVectors: number;
  28164. /** Maximum number of uniforms per fragment shader */
  28165. maxFragmentUniformVectors: number;
  28166. /** Defines if standard derivates (dx/dy) are supported */
  28167. standardDerivatives: boolean;
  28168. /** Defines if s3tc texture compression is supported */
  28169. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28170. /** Defines if pvrtc texture compression is supported */
  28171. pvrtc: any;
  28172. /** Defines if etc1 texture compression is supported */
  28173. etc1: any;
  28174. /** Defines if etc2 texture compression is supported */
  28175. etc2: any;
  28176. /** Defines if astc texture compression is supported */
  28177. astc: any;
  28178. /** Defines if float textures are supported */
  28179. textureFloat: boolean;
  28180. /** Defines if vertex array objects are supported */
  28181. vertexArrayObject: boolean;
  28182. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28183. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28184. /** Gets the maximum level of anisotropy supported */
  28185. maxAnisotropy: number;
  28186. /** Defines if instancing is supported */
  28187. instancedArrays: boolean;
  28188. /** Defines if 32 bits indices are supported */
  28189. uintIndices: boolean;
  28190. /** Defines if high precision shaders are supported */
  28191. highPrecisionShaderSupported: boolean;
  28192. /** Defines if depth reading in the fragment shader is supported */
  28193. fragmentDepthSupported: boolean;
  28194. /** Defines if float texture linear filtering is supported*/
  28195. textureFloatLinearFiltering: boolean;
  28196. /** Defines if rendering to float textures is supported */
  28197. textureFloatRender: boolean;
  28198. /** Defines if half float textures are supported*/
  28199. textureHalfFloat: boolean;
  28200. /** Defines if half float texture linear filtering is supported*/
  28201. textureHalfFloatLinearFiltering: boolean;
  28202. /** Defines if rendering to half float textures is supported */
  28203. textureHalfFloatRender: boolean;
  28204. /** Defines if textureLOD shader command is supported */
  28205. textureLOD: boolean;
  28206. /** Defines if draw buffers extension is supported */
  28207. drawBuffersExtension: boolean;
  28208. /** Defines if depth textures are supported */
  28209. depthTextureExtension: boolean;
  28210. /** Defines if float color buffer are supported */
  28211. colorBufferFloat: boolean;
  28212. /** Gets disjoint timer query extension (null if not supported) */
  28213. timerQuery: EXT_disjoint_timer_query;
  28214. /** Defines if timestamp can be used with timer query */
  28215. canUseTimestampForTimerQuery: boolean;
  28216. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28217. multiview: any;
  28218. /** Function used to let the system compiles shaders in background */
  28219. parallelShaderCompile: {
  28220. COMPLETION_STATUS_KHR: number;
  28221. };
  28222. }
  28223. /** Interface defining initialization parameters for Engine class */
  28224. export interface EngineOptions extends WebGLContextAttributes {
  28225. /**
  28226. * Defines if the engine should no exceed a specified device ratio
  28227. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28228. */
  28229. limitDeviceRatio?: number;
  28230. /**
  28231. * Defines if webvr should be enabled automatically
  28232. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28233. */
  28234. autoEnableWebVR?: boolean;
  28235. /**
  28236. * Defines if webgl2 should be turned off even if supported
  28237. * @see http://doc.babylonjs.com/features/webgl2
  28238. */
  28239. disableWebGL2Support?: boolean;
  28240. /**
  28241. * Defines if webaudio should be initialized as well
  28242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28243. */
  28244. audioEngine?: boolean;
  28245. /**
  28246. * Defines if animations should run using a deterministic lock step
  28247. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28248. */
  28249. deterministicLockstep?: boolean;
  28250. /** Defines the maximum steps to use with deterministic lock step mode */
  28251. lockstepMaxSteps?: number;
  28252. /**
  28253. * Defines that engine should ignore context lost events
  28254. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28255. */
  28256. doNotHandleContextLost?: boolean;
  28257. /**
  28258. * Defines that engine should ignore modifying touch action attribute and style
  28259. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28260. */
  28261. doNotHandleTouchAction?: boolean;
  28262. /**
  28263. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28264. */
  28265. useHighPrecisionFloats?: boolean;
  28266. }
  28267. /**
  28268. * Defines the interface used by display changed events
  28269. */
  28270. export interface IDisplayChangedEventArgs {
  28271. /** Gets the vrDisplay object (if any) */
  28272. vrDisplay: Nullable<any>;
  28273. /** Gets a boolean indicating if webVR is supported */
  28274. vrSupported: boolean;
  28275. }
  28276. /**
  28277. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28278. */
  28279. export class Engine {
  28280. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28281. static ExceptionList: ({
  28282. key: string;
  28283. capture: string;
  28284. captureConstraint: number;
  28285. targets: string[];
  28286. } | {
  28287. key: string;
  28288. capture: null;
  28289. captureConstraint: null;
  28290. targets: string[];
  28291. })[];
  28292. /** Gets the list of created engines */
  28293. static readonly Instances: Engine[];
  28294. /**
  28295. * Gets the latest created engine
  28296. */
  28297. static readonly LastCreatedEngine: Nullable<Engine>;
  28298. /**
  28299. * Gets the latest created scene
  28300. */
  28301. static readonly LastCreatedScene: Nullable<Scene>;
  28302. /**
  28303. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28304. * @param flag defines which part of the materials must be marked as dirty
  28305. * @param predicate defines a predicate used to filter which materials should be affected
  28306. */
  28307. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28308. /** @hidden */
  28309. static _TextureLoaders: IInternalTextureLoader[];
  28310. /** Defines that alpha blending is disabled */
  28311. static readonly ALPHA_DISABLE: number;
  28312. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28313. static readonly ALPHA_ADD: number;
  28314. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28315. static readonly ALPHA_COMBINE: number;
  28316. /** Defines that alpha blending to DEST - SRC * DEST */
  28317. static readonly ALPHA_SUBTRACT: number;
  28318. /** Defines that alpha blending to SRC * DEST */
  28319. static readonly ALPHA_MULTIPLY: number;
  28320. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28321. static readonly ALPHA_MAXIMIZED: number;
  28322. /** Defines that alpha blending to SRC + DEST */
  28323. static readonly ALPHA_ONEONE: number;
  28324. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28325. static readonly ALPHA_PREMULTIPLIED: number;
  28326. /**
  28327. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28328. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28329. */
  28330. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28331. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28332. static readonly ALPHA_INTERPOLATE: number;
  28333. /**
  28334. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28335. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28336. */
  28337. static readonly ALPHA_SCREENMODE: number;
  28338. /** Defines that the ressource is not delayed*/
  28339. static readonly DELAYLOADSTATE_NONE: number;
  28340. /** Defines that the ressource was successfully delay loaded */
  28341. static readonly DELAYLOADSTATE_LOADED: number;
  28342. /** Defines that the ressource is currently delay loading */
  28343. static readonly DELAYLOADSTATE_LOADING: number;
  28344. /** Defines that the ressource is delayed and has not started loading */
  28345. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28346. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28347. static readonly NEVER: number;
  28348. /** 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 */
  28349. static readonly ALWAYS: number;
  28350. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28351. static readonly LESS: number;
  28352. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28353. static readonly EQUAL: number;
  28354. /** 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 */
  28355. static readonly LEQUAL: number;
  28356. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28357. static readonly GREATER: number;
  28358. /** 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 */
  28359. static readonly GEQUAL: number;
  28360. /** 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 */
  28361. static readonly NOTEQUAL: number;
  28362. /** Passed to stencilOperation to specify that stencil value must be kept */
  28363. static readonly KEEP: number;
  28364. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28365. static readonly REPLACE: number;
  28366. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28367. static readonly INCR: number;
  28368. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28369. static readonly DECR: number;
  28370. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28371. static readonly INVERT: number;
  28372. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28373. static readonly INCR_WRAP: number;
  28374. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28375. static readonly DECR_WRAP: number;
  28376. /** Texture is not repeating outside of 0..1 UVs */
  28377. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28378. /** Texture is repeating outside of 0..1 UVs */
  28379. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28380. /** Texture is repeating and mirrored */
  28381. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28382. /** ALPHA */
  28383. static readonly TEXTUREFORMAT_ALPHA: number;
  28384. /** LUMINANCE */
  28385. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28386. /** LUMINANCE_ALPHA */
  28387. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28388. /** RGB */
  28389. static readonly TEXTUREFORMAT_RGB: number;
  28390. /** RGBA */
  28391. static readonly TEXTUREFORMAT_RGBA: number;
  28392. /** RED */
  28393. static readonly TEXTUREFORMAT_RED: number;
  28394. /** RED (2nd reference) */
  28395. static readonly TEXTUREFORMAT_R: number;
  28396. /** RG */
  28397. static readonly TEXTUREFORMAT_RG: number;
  28398. /** RED_INTEGER */
  28399. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28400. /** RED_INTEGER (2nd reference) */
  28401. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28402. /** RG_INTEGER */
  28403. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28404. /** RGB_INTEGER */
  28405. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28406. /** RGBA_INTEGER */
  28407. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28408. /** UNSIGNED_BYTE */
  28409. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28410. /** UNSIGNED_BYTE (2nd reference) */
  28411. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28412. /** FLOAT */
  28413. static readonly TEXTURETYPE_FLOAT: number;
  28414. /** HALF_FLOAT */
  28415. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28416. /** BYTE */
  28417. static readonly TEXTURETYPE_BYTE: number;
  28418. /** SHORT */
  28419. static readonly TEXTURETYPE_SHORT: number;
  28420. /** UNSIGNED_SHORT */
  28421. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28422. /** INT */
  28423. static readonly TEXTURETYPE_INT: number;
  28424. /** UNSIGNED_INT */
  28425. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28426. /** UNSIGNED_SHORT_4_4_4_4 */
  28427. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28428. /** UNSIGNED_SHORT_5_5_5_1 */
  28429. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28430. /** UNSIGNED_SHORT_5_6_5 */
  28431. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28432. /** UNSIGNED_INT_2_10_10_10_REV */
  28433. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28434. /** UNSIGNED_INT_24_8 */
  28435. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28436. /** UNSIGNED_INT_10F_11F_11F_REV */
  28437. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28438. /** UNSIGNED_INT_5_9_9_9_REV */
  28439. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28440. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28441. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28442. /** nearest is mag = nearest and min = nearest and mip = linear */
  28443. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28444. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28445. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28446. /** Trilinear is mag = linear and min = linear and mip = linear */
  28447. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28448. /** nearest is mag = nearest and min = nearest and mip = linear */
  28449. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28450. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28451. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28452. /** Trilinear is mag = linear and min = linear and mip = linear */
  28453. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28454. /** mag = nearest and min = nearest and mip = nearest */
  28455. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28456. /** mag = nearest and min = linear and mip = nearest */
  28457. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28458. /** mag = nearest and min = linear and mip = linear */
  28459. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28460. /** mag = nearest and min = linear and mip = none */
  28461. static readonly TEXTURE_NEAREST_LINEAR: number;
  28462. /** mag = nearest and min = nearest and mip = none */
  28463. static readonly TEXTURE_NEAREST_NEAREST: number;
  28464. /** mag = linear and min = nearest and mip = nearest */
  28465. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28466. /** mag = linear and min = nearest and mip = linear */
  28467. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28468. /** mag = linear and min = linear and mip = none */
  28469. static readonly TEXTURE_LINEAR_LINEAR: number;
  28470. /** mag = linear and min = nearest and mip = none */
  28471. static readonly TEXTURE_LINEAR_NEAREST: number;
  28472. /** Explicit coordinates mode */
  28473. static readonly TEXTURE_EXPLICIT_MODE: number;
  28474. /** Spherical coordinates mode */
  28475. static readonly TEXTURE_SPHERICAL_MODE: number;
  28476. /** Planar coordinates mode */
  28477. static readonly TEXTURE_PLANAR_MODE: number;
  28478. /** Cubic coordinates mode */
  28479. static readonly TEXTURE_CUBIC_MODE: number;
  28480. /** Projection coordinates mode */
  28481. static readonly TEXTURE_PROJECTION_MODE: number;
  28482. /** Skybox coordinates mode */
  28483. static readonly TEXTURE_SKYBOX_MODE: number;
  28484. /** Inverse Cubic coordinates mode */
  28485. static readonly TEXTURE_INVCUBIC_MODE: number;
  28486. /** Equirectangular coordinates mode */
  28487. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28488. /** Equirectangular Fixed coordinates mode */
  28489. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28490. /** Equirectangular Fixed Mirrored coordinates mode */
  28491. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28492. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28493. static readonly SCALEMODE_FLOOR: number;
  28494. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28495. static readonly SCALEMODE_NEAREST: number;
  28496. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28497. static readonly SCALEMODE_CEILING: number;
  28498. /**
  28499. * Returns the current npm package of the sdk
  28500. */
  28501. static readonly NpmPackage: string;
  28502. /**
  28503. * Returns the current version of the framework
  28504. */
  28505. static readonly Version: string;
  28506. /**
  28507. * Returns a string describing the current engine
  28508. */
  28509. readonly description: string;
  28510. /**
  28511. * Gets or sets the epsilon value used by collision engine
  28512. */
  28513. static CollisionsEpsilon: number;
  28514. /**
  28515. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28516. */
  28517. static ShadersRepository: string;
  28518. /**
  28519. * Method called to create the default loading screen.
  28520. * This can be overriden in your own app.
  28521. * @param canvas The rendering canvas element
  28522. * @returns The loading screen
  28523. */
  28524. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28525. /**
  28526. * Method called to create the default rescale post process on each engine.
  28527. */
  28528. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28529. /** @hidden */
  28530. _shaderProcessor: IShaderProcessor;
  28531. /**
  28532. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28533. */
  28534. forcePOTTextures: boolean;
  28535. /**
  28536. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28537. */
  28538. isFullscreen: boolean;
  28539. /**
  28540. * Gets a boolean indicating if the pointer is currently locked
  28541. */
  28542. isPointerLock: boolean;
  28543. /**
  28544. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28545. */
  28546. cullBackFaces: boolean;
  28547. /**
  28548. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28549. */
  28550. renderEvenInBackground: boolean;
  28551. /**
  28552. * Gets or sets a boolean indicating that cache can be kept between frames
  28553. */
  28554. preventCacheWipeBetweenFrames: boolean;
  28555. /**
  28556. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28557. **/
  28558. enableOfflineSupport: boolean;
  28559. /**
  28560. * 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)
  28561. **/
  28562. disableManifestCheck: boolean;
  28563. /**
  28564. * Gets the list of created scenes
  28565. */
  28566. scenes: Scene[];
  28567. /**
  28568. * Event raised when a new scene is created
  28569. */
  28570. onNewSceneAddedObservable: Observable<Scene>;
  28571. /**
  28572. * Gets the list of created postprocesses
  28573. */
  28574. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28575. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28576. validateShaderPrograms: boolean;
  28577. /**
  28578. * Observable event triggered each time the rendering canvas is resized
  28579. */
  28580. onResizeObservable: Observable<Engine>;
  28581. /**
  28582. * Observable event triggered each time the canvas loses focus
  28583. */
  28584. onCanvasBlurObservable: Observable<Engine>;
  28585. /**
  28586. * Observable event triggered each time the canvas gains focus
  28587. */
  28588. onCanvasFocusObservable: Observable<Engine>;
  28589. /**
  28590. * Observable event triggered each time the canvas receives pointerout event
  28591. */
  28592. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28593. /**
  28594. * Observable event triggered before each texture is initialized
  28595. */
  28596. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28597. /**
  28598. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28599. */
  28600. disableUniformBuffers: boolean;
  28601. /** @hidden */
  28602. _uniformBuffers: UniformBuffer[];
  28603. /**
  28604. * Gets a boolean indicating that the engine supports uniform buffers
  28605. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28606. */
  28607. readonly supportsUniformBuffers: boolean;
  28608. /**
  28609. * Observable raised when the engine begins a new frame
  28610. */
  28611. onBeginFrameObservable: Observable<Engine>;
  28612. /**
  28613. * If set, will be used to request the next animation frame for the render loop
  28614. */
  28615. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28616. /**
  28617. * Observable raised when the engine ends the current frame
  28618. */
  28619. onEndFrameObservable: Observable<Engine>;
  28620. /**
  28621. * Observable raised when the engine is about to compile a shader
  28622. */
  28623. onBeforeShaderCompilationObservable: Observable<Engine>;
  28624. /**
  28625. * Observable raised when the engine has jsut compiled a shader
  28626. */
  28627. onAfterShaderCompilationObservable: Observable<Engine>;
  28628. /** @hidden */
  28629. _gl: WebGLRenderingContext;
  28630. private _renderingCanvas;
  28631. private _windowIsBackground;
  28632. private _webGLVersion;
  28633. protected _highPrecisionShadersAllowed: boolean;
  28634. /** @hidden */
  28635. readonly _shouldUseHighPrecisionShader: boolean;
  28636. /**
  28637. * Gets a boolean indicating that only power of 2 textures are supported
  28638. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28639. */
  28640. readonly needPOTTextures: boolean;
  28641. /** @hidden */
  28642. _badOS: boolean;
  28643. /** @hidden */
  28644. _badDesktopOS: boolean;
  28645. /**
  28646. * Gets the audio engine
  28647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28648. * @ignorenaming
  28649. */
  28650. static audioEngine: IAudioEngine;
  28651. /**
  28652. * Default AudioEngine factory responsible of creating the Audio Engine.
  28653. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28654. */
  28655. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28656. /**
  28657. * Default offline support factory responsible of creating a tool used to store data locally.
  28658. * By default, this will create a Database object if the workload has been embedded.
  28659. */
  28660. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28661. private _onFocus;
  28662. private _onBlur;
  28663. private _onCanvasPointerOut;
  28664. private _onCanvasBlur;
  28665. private _onCanvasFocus;
  28666. private _onFullscreenChange;
  28667. private _onPointerLockChange;
  28668. private _hardwareScalingLevel;
  28669. /** @hidden */
  28670. _caps: EngineCapabilities;
  28671. private _pointerLockRequested;
  28672. private _isStencilEnable;
  28673. private _colorWrite;
  28674. private _loadingScreen;
  28675. /** @hidden */
  28676. _drawCalls: PerfCounter;
  28677. private _glVersion;
  28678. private _glRenderer;
  28679. private _glVendor;
  28680. private _videoTextureSupported;
  28681. private _renderingQueueLaunched;
  28682. private _activeRenderLoops;
  28683. private _deterministicLockstep;
  28684. private _lockstepMaxSteps;
  28685. /**
  28686. * Observable signaled when a context lost event is raised
  28687. */
  28688. onContextLostObservable: Observable<Engine>;
  28689. /**
  28690. * Observable signaled when a context restored event is raised
  28691. */
  28692. onContextRestoredObservable: Observable<Engine>;
  28693. private _onContextLost;
  28694. private _onContextRestored;
  28695. private _contextWasLost;
  28696. /** @hidden */
  28697. _doNotHandleContextLost: boolean;
  28698. /**
  28699. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28700. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28701. */
  28702. doNotHandleContextLost: boolean;
  28703. private _performanceMonitor;
  28704. private _fps;
  28705. private _deltaTime;
  28706. /**
  28707. * Turn this value on if you want to pause FPS computation when in background
  28708. */
  28709. disablePerformanceMonitorInBackground: boolean;
  28710. /**
  28711. * Gets the performance monitor attached to this engine
  28712. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28713. */
  28714. readonly performanceMonitor: PerformanceMonitor;
  28715. /**
  28716. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28717. */
  28718. disableVertexArrayObjects: boolean;
  28719. /** @hidden */
  28720. protected _depthCullingState: _DepthCullingState;
  28721. /** @hidden */
  28722. protected _stencilState: _StencilState;
  28723. /** @hidden */
  28724. protected _alphaState: _AlphaState;
  28725. /** @hidden */
  28726. protected _alphaMode: number;
  28727. /** @hidden */
  28728. _internalTexturesCache: InternalTexture[];
  28729. /** @hidden */
  28730. protected _activeChannel: number;
  28731. private _currentTextureChannel;
  28732. /** @hidden */
  28733. protected _boundTexturesCache: {
  28734. [key: string]: Nullable<InternalTexture>;
  28735. };
  28736. /** @hidden */
  28737. protected _currentEffect: Nullable<Effect>;
  28738. /** @hidden */
  28739. protected _currentProgram: Nullable<WebGLProgram>;
  28740. private _compiledEffects;
  28741. private _vertexAttribArraysEnabled;
  28742. /** @hidden */
  28743. protected _cachedViewport: Nullable<Viewport>;
  28744. private _cachedVertexArrayObject;
  28745. /** @hidden */
  28746. protected _cachedVertexBuffers: any;
  28747. /** @hidden */
  28748. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28749. /** @hidden */
  28750. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28751. /** @hidden */
  28752. _currentRenderTarget: Nullable<InternalTexture>;
  28753. private _uintIndicesCurrentlySet;
  28754. private _currentBoundBuffer;
  28755. /** @hidden */
  28756. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28757. private _currentBufferPointers;
  28758. private _currentInstanceLocations;
  28759. private _currentInstanceBuffers;
  28760. private _textureUnits;
  28761. /** @hidden */
  28762. _workingCanvas: Nullable<HTMLCanvasElement>;
  28763. /** @hidden */
  28764. _workingContext: Nullable<CanvasRenderingContext2D>;
  28765. private _rescalePostProcess;
  28766. private _dummyFramebuffer;
  28767. private _externalData;
  28768. /** @hidden */
  28769. _bindedRenderFunction: any;
  28770. private _vaoRecordInProgress;
  28771. private _mustWipeVertexAttributes;
  28772. private _emptyTexture;
  28773. private _emptyCubeTexture;
  28774. private _emptyTexture3D;
  28775. /** @hidden */
  28776. _frameHandler: number;
  28777. private _nextFreeTextureSlots;
  28778. private _maxSimultaneousTextures;
  28779. private _activeRequests;
  28780. private _texturesSupported;
  28781. /** @hidden */
  28782. _textureFormatInUse: Nullable<string>;
  28783. /**
  28784. * Gets the list of texture formats supported
  28785. */
  28786. readonly texturesSupported: Array<string>;
  28787. /**
  28788. * Gets the list of texture formats in use
  28789. */
  28790. readonly textureFormatInUse: Nullable<string>;
  28791. /**
  28792. * Gets the current viewport
  28793. */
  28794. readonly currentViewport: Nullable<Viewport>;
  28795. /**
  28796. * Gets the default empty texture
  28797. */
  28798. readonly emptyTexture: InternalTexture;
  28799. /**
  28800. * Gets the default empty 3D texture
  28801. */
  28802. readonly emptyTexture3D: InternalTexture;
  28803. /**
  28804. * Gets the default empty cube texture
  28805. */
  28806. readonly emptyCubeTexture: InternalTexture;
  28807. /**
  28808. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28809. */
  28810. readonly premultipliedAlpha: boolean;
  28811. /**
  28812. * Creates a new engine
  28813. * @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
  28814. * @param antialias defines enable antialiasing (default: false)
  28815. * @param options defines further options to be sent to the getContext() function
  28816. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28817. */
  28818. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28819. /**
  28820. * Initializes a webVR display and starts listening to display change events
  28821. * The onVRDisplayChangedObservable will be notified upon these changes
  28822. * @returns The onVRDisplayChangedObservable
  28823. */
  28824. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28825. /** @hidden */
  28826. _prepareVRComponent(): void;
  28827. /** @hidden */
  28828. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28829. /** @hidden */
  28830. _submitVRFrame(): void;
  28831. /**
  28832. * Call this function to leave webVR mode
  28833. * Will do nothing if webVR is not supported or if there is no webVR device
  28834. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28835. */
  28836. disableVR(): void;
  28837. /**
  28838. * Gets a boolean indicating that the system is in VR mode and is presenting
  28839. * @returns true if VR mode is engaged
  28840. */
  28841. isVRPresenting(): boolean;
  28842. /** @hidden */
  28843. _requestVRFrame(): void;
  28844. private _disableTouchAction;
  28845. private _rebuildInternalTextures;
  28846. private _rebuildEffects;
  28847. /**
  28848. * Gets a boolean indicating if all created effects are ready
  28849. * @returns true if all effects are ready
  28850. */
  28851. areAllEffectsReady(): boolean;
  28852. private _rebuildBuffers;
  28853. private _initGLContext;
  28854. /**
  28855. * Gets version of the current webGL context
  28856. */
  28857. readonly webGLVersion: number;
  28858. /**
  28859. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28860. */
  28861. readonly isStencilEnable: boolean;
  28862. /** @hidden */
  28863. _prepareWorkingCanvas(): void;
  28864. /**
  28865. * Reset the texture cache to empty state
  28866. */
  28867. resetTextureCache(): void;
  28868. /**
  28869. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28870. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28871. * @returns true if engine is in deterministic lock step mode
  28872. */
  28873. isDeterministicLockStep(): boolean;
  28874. /**
  28875. * Gets the max steps when engine is running in deterministic lock step
  28876. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28877. * @returns the max steps
  28878. */
  28879. getLockstepMaxSteps(): number;
  28880. /**
  28881. * Gets an object containing information about the current webGL context
  28882. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28883. */
  28884. getGlInfo(): {
  28885. vendor: string;
  28886. renderer: string;
  28887. version: string;
  28888. };
  28889. /**
  28890. * Gets current aspect ratio
  28891. * @param camera defines the camera to use to get the aspect ratio
  28892. * @param useScreen defines if screen size must be used (or the current render target if any)
  28893. * @returns a number defining the aspect ratio
  28894. */
  28895. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28896. /**
  28897. * Gets current screen aspect ratio
  28898. * @returns a number defining the aspect ratio
  28899. */
  28900. getScreenAspectRatio(): number;
  28901. /**
  28902. * Gets the current render width
  28903. * @param useScreen defines if screen size must be used (or the current render target if any)
  28904. * @returns a number defining the current render width
  28905. */
  28906. getRenderWidth(useScreen?: boolean): number;
  28907. /**
  28908. * Gets the current render height
  28909. * @param useScreen defines if screen size must be used (or the current render target if any)
  28910. * @returns a number defining the current render height
  28911. */
  28912. getRenderHeight(useScreen?: boolean): number;
  28913. /**
  28914. * Gets the HTML canvas attached with the current webGL context
  28915. * @returns a HTML canvas
  28916. */
  28917. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28918. /**
  28919. * Gets the client rect of the HTML canvas attached with the current webGL context
  28920. * @returns a client rectanglee
  28921. */
  28922. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28923. /**
  28924. * Defines the hardware scaling level.
  28925. * By default the hardware scaling level is computed from the window device ratio.
  28926. * 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.
  28927. * @param level defines the level to use
  28928. */
  28929. setHardwareScalingLevel(level: number): void;
  28930. /**
  28931. * Gets the current hardware scaling level.
  28932. * By default the hardware scaling level is computed from the window device ratio.
  28933. * 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.
  28934. * @returns a number indicating the current hardware scaling level
  28935. */
  28936. getHardwareScalingLevel(): number;
  28937. /**
  28938. * Gets the list of loaded textures
  28939. * @returns an array containing all loaded textures
  28940. */
  28941. getLoadedTexturesCache(): InternalTexture[];
  28942. /**
  28943. * Gets the object containing all engine capabilities
  28944. * @returns the EngineCapabilities object
  28945. */
  28946. getCaps(): EngineCapabilities;
  28947. /**
  28948. * Gets the current depth function
  28949. * @returns a number defining the depth function
  28950. */
  28951. getDepthFunction(): Nullable<number>;
  28952. /**
  28953. * Sets the current depth function
  28954. * @param depthFunc defines the function to use
  28955. */
  28956. setDepthFunction(depthFunc: number): void;
  28957. /**
  28958. * Sets the current depth function to GREATER
  28959. */
  28960. setDepthFunctionToGreater(): void;
  28961. /**
  28962. * Sets the current depth function to GEQUAL
  28963. */
  28964. setDepthFunctionToGreaterOrEqual(): void;
  28965. /**
  28966. * Sets the current depth function to LESS
  28967. */
  28968. setDepthFunctionToLess(): void;
  28969. private _cachedStencilBuffer;
  28970. private _cachedStencilFunction;
  28971. private _cachedStencilMask;
  28972. private _cachedStencilOperationPass;
  28973. private _cachedStencilOperationFail;
  28974. private _cachedStencilOperationDepthFail;
  28975. private _cachedStencilReference;
  28976. /**
  28977. * Caches the the state of the stencil buffer
  28978. */
  28979. cacheStencilState(): void;
  28980. /**
  28981. * Restores the state of the stencil buffer
  28982. */
  28983. restoreStencilState(): void;
  28984. /**
  28985. * Sets the current depth function to LEQUAL
  28986. */
  28987. setDepthFunctionToLessOrEqual(): void;
  28988. /**
  28989. * Gets a boolean indicating if stencil buffer is enabled
  28990. * @returns the current stencil buffer state
  28991. */
  28992. getStencilBuffer(): boolean;
  28993. /**
  28994. * Enable or disable the stencil buffer
  28995. * @param enable defines if the stencil buffer must be enabled or disabled
  28996. */
  28997. setStencilBuffer(enable: boolean): void;
  28998. /**
  28999. * Gets the current stencil mask
  29000. * @returns a number defining the new stencil mask to use
  29001. */
  29002. getStencilMask(): number;
  29003. /**
  29004. * Sets the current stencil mask
  29005. * @param mask defines the new stencil mask to use
  29006. */
  29007. setStencilMask(mask: number): void;
  29008. /**
  29009. * Gets the current stencil function
  29010. * @returns a number defining the stencil function to use
  29011. */
  29012. getStencilFunction(): number;
  29013. /**
  29014. * Gets the current stencil reference value
  29015. * @returns a number defining the stencil reference value to use
  29016. */
  29017. getStencilFunctionReference(): number;
  29018. /**
  29019. * Gets the current stencil mask
  29020. * @returns a number defining the stencil mask to use
  29021. */
  29022. getStencilFunctionMask(): number;
  29023. /**
  29024. * Sets the current stencil function
  29025. * @param stencilFunc defines the new stencil function to use
  29026. */
  29027. setStencilFunction(stencilFunc: number): void;
  29028. /**
  29029. * Sets the current stencil reference
  29030. * @param reference defines the new stencil reference to use
  29031. */
  29032. setStencilFunctionReference(reference: number): void;
  29033. /**
  29034. * Sets the current stencil mask
  29035. * @param mask defines the new stencil mask to use
  29036. */
  29037. setStencilFunctionMask(mask: number): void;
  29038. /**
  29039. * Gets the current stencil operation when stencil fails
  29040. * @returns a number defining stencil operation to use when stencil fails
  29041. */
  29042. getStencilOperationFail(): number;
  29043. /**
  29044. * Gets the current stencil operation when depth fails
  29045. * @returns a number defining stencil operation to use when depth fails
  29046. */
  29047. getStencilOperationDepthFail(): number;
  29048. /**
  29049. * Gets the current stencil operation when stencil passes
  29050. * @returns a number defining stencil operation to use when stencil passes
  29051. */
  29052. getStencilOperationPass(): number;
  29053. /**
  29054. * Sets the stencil operation to use when stencil fails
  29055. * @param operation defines the stencil operation to use when stencil fails
  29056. */
  29057. setStencilOperationFail(operation: number): void;
  29058. /**
  29059. * Sets the stencil operation to use when depth fails
  29060. * @param operation defines the stencil operation to use when depth fails
  29061. */
  29062. setStencilOperationDepthFail(operation: number): void;
  29063. /**
  29064. * Sets the stencil operation to use when stencil passes
  29065. * @param operation defines the stencil operation to use when stencil passes
  29066. */
  29067. setStencilOperationPass(operation: number): void;
  29068. /**
  29069. * Sets a boolean indicating if the dithering state is enabled or disabled
  29070. * @param value defines the dithering state
  29071. */
  29072. setDitheringState(value: boolean): void;
  29073. /**
  29074. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29075. * @param value defines the rasterizer state
  29076. */
  29077. setRasterizerState(value: boolean): void;
  29078. /**
  29079. * stop executing a render loop function and remove it from the execution array
  29080. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29081. */
  29082. stopRenderLoop(renderFunction?: () => void): void;
  29083. /** @hidden */
  29084. _renderLoop(): void;
  29085. /**
  29086. * Register and execute a render loop. The engine can have more than one render function
  29087. * @param renderFunction defines the function to continuously execute
  29088. */
  29089. runRenderLoop(renderFunction: () => void): void;
  29090. /**
  29091. * Toggle full screen mode
  29092. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29093. */
  29094. switchFullscreen(requestPointerLock: boolean): void;
  29095. /**
  29096. * Enters full screen mode
  29097. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29098. */
  29099. enterFullscreen(requestPointerLock: boolean): void;
  29100. /**
  29101. * Exits full screen mode
  29102. */
  29103. exitFullscreen(): void;
  29104. /**
  29105. * Enters Pointerlock mode
  29106. */
  29107. enterPointerlock(): void;
  29108. /**
  29109. * Exits Pointerlock mode
  29110. */
  29111. exitPointerlock(): void;
  29112. /**
  29113. * Clear the current render buffer or the current render target (if any is set up)
  29114. * @param color defines the color to use
  29115. * @param backBuffer defines if the back buffer must be cleared
  29116. * @param depth defines if the depth buffer must be cleared
  29117. * @param stencil defines if the stencil buffer must be cleared
  29118. */
  29119. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29120. /**
  29121. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29122. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29123. * @param y defines the y-coordinate of the corner of the clear rectangle
  29124. * @param width defines the width of the clear rectangle
  29125. * @param height defines the height of the clear rectangle
  29126. * @param clearColor defines the clear color
  29127. */
  29128. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29129. /**
  29130. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29131. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29132. * @param y defines the y-coordinate of the corner of the clear rectangle
  29133. * @param width defines the width of the clear rectangle
  29134. * @param height defines the height of the clear rectangle
  29135. */
  29136. enableScissor(x: number, y: number, width: number, height: number): void;
  29137. /**
  29138. * Disable previously set scissor test rectangle
  29139. */
  29140. disableScissor(): void;
  29141. private _viewportCached;
  29142. /** @hidden */
  29143. _viewport(x: number, y: number, width: number, height: number): void;
  29144. /**
  29145. * Set the WebGL's viewport
  29146. * @param viewport defines the viewport element to be used
  29147. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29148. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29149. */
  29150. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29151. /**
  29152. * Directly set the WebGL Viewport
  29153. * @param x defines the x coordinate of the viewport (in screen space)
  29154. * @param y defines the y coordinate of the viewport (in screen space)
  29155. * @param width defines the width of the viewport (in screen space)
  29156. * @param height defines the height of the viewport (in screen space)
  29157. * @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
  29158. */
  29159. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29160. /**
  29161. * Begin a new frame
  29162. */
  29163. beginFrame(): void;
  29164. /**
  29165. * Enf the current frame
  29166. */
  29167. endFrame(): void;
  29168. /**
  29169. * Resize the view according to the canvas' size
  29170. */
  29171. resize(): void;
  29172. /**
  29173. * Force a specific size of the canvas
  29174. * @param width defines the new canvas' width
  29175. * @param height defines the new canvas' height
  29176. */
  29177. setSize(width: number, height: number): void;
  29178. /**
  29179. * Binds the frame buffer to the specified texture.
  29180. * @param texture The texture to render to or null for the default canvas
  29181. * @param faceIndex The face of the texture to render to in case of cube texture
  29182. * @param requiredWidth The width of the target to render to
  29183. * @param requiredHeight The height of the target to render to
  29184. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29185. * @param depthStencilTexture The depth stencil texture to use to render
  29186. * @param lodLevel defines le lod level to bind to the frame buffer
  29187. */
  29188. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29189. /** @hidden */
  29190. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29191. /**
  29192. * Unbind the current render target texture from the webGL context
  29193. * @param texture defines the render target texture to unbind
  29194. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29195. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29196. */
  29197. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29198. /**
  29199. * Force the mipmap generation for the given render target texture
  29200. * @param texture defines the render target texture to use
  29201. */
  29202. generateMipMapsForCubemap(texture: InternalTexture): void;
  29203. /**
  29204. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29205. */
  29206. flushFramebuffer(): void;
  29207. /**
  29208. * Unbind the current render target and bind the default framebuffer
  29209. */
  29210. restoreDefaultFramebuffer(): void;
  29211. /**
  29212. * Create an uniform buffer
  29213. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29214. * @param elements defines the content of the uniform buffer
  29215. * @returns the webGL uniform buffer
  29216. */
  29217. createUniformBuffer(elements: FloatArray): DataBuffer;
  29218. /**
  29219. * Create a dynamic uniform buffer
  29220. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29221. * @param elements defines the content of the uniform buffer
  29222. * @returns the webGL uniform buffer
  29223. */
  29224. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29225. /**
  29226. * Update an existing uniform buffer
  29227. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29228. * @param uniformBuffer defines the target uniform buffer
  29229. * @param elements defines the content to update
  29230. * @param offset defines the offset in the uniform buffer where update should start
  29231. * @param count defines the size of the data to update
  29232. */
  29233. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29234. private _resetVertexBufferBinding;
  29235. /**
  29236. * Creates a vertex buffer
  29237. * @param data the data for the vertex buffer
  29238. * @returns the new WebGL static buffer
  29239. */
  29240. createVertexBuffer(data: DataArray): DataBuffer;
  29241. /**
  29242. * Creates a dynamic vertex buffer
  29243. * @param data the data for the dynamic vertex buffer
  29244. * @returns the new WebGL dynamic buffer
  29245. */
  29246. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29247. /**
  29248. * Update a dynamic index buffer
  29249. * @param indexBuffer defines the target index buffer
  29250. * @param indices defines the data to update
  29251. * @param offset defines the offset in the target index buffer where update should start
  29252. */
  29253. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29254. /**
  29255. * Updates a dynamic vertex buffer.
  29256. * @param vertexBuffer the vertex buffer to update
  29257. * @param data the data used to update the vertex buffer
  29258. * @param byteOffset the byte offset of the data
  29259. * @param byteLength the byte length of the data
  29260. */
  29261. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29262. private _resetIndexBufferBinding;
  29263. /**
  29264. * Creates a new index buffer
  29265. * @param indices defines the content of the index buffer
  29266. * @param updatable defines if the index buffer must be updatable
  29267. * @returns a new webGL buffer
  29268. */
  29269. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29270. /**
  29271. * Bind a webGL buffer to the webGL context
  29272. * @param buffer defines the buffer to bind
  29273. */
  29274. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29275. /**
  29276. * Bind an uniform buffer to the current webGL context
  29277. * @param buffer defines the buffer to bind
  29278. */
  29279. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29280. /**
  29281. * Bind a buffer to the current webGL context at a given location
  29282. * @param buffer defines the buffer to bind
  29283. * @param location defines the index where to bind the buffer
  29284. */
  29285. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29286. /**
  29287. * Bind a specific block at a given index in a specific shader program
  29288. * @param pipelineContext defines the pipeline context to use
  29289. * @param blockName defines the block name
  29290. * @param index defines the index where to bind the block
  29291. */
  29292. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29293. private bindIndexBuffer;
  29294. private bindBuffer;
  29295. /**
  29296. * update the bound buffer with the given data
  29297. * @param data defines the data to update
  29298. */
  29299. updateArrayBuffer(data: Float32Array): void;
  29300. private _vertexAttribPointer;
  29301. private _bindIndexBufferWithCache;
  29302. private _bindVertexBuffersAttributes;
  29303. /**
  29304. * Records a vertex array object
  29305. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29306. * @param vertexBuffers defines the list of vertex buffers to store
  29307. * @param indexBuffer defines the index buffer to store
  29308. * @param effect defines the effect to store
  29309. * @returns the new vertex array object
  29310. */
  29311. recordVertexArrayObject(vertexBuffers: {
  29312. [key: string]: VertexBuffer;
  29313. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29314. /**
  29315. * Bind a specific vertex array object
  29316. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29317. * @param vertexArrayObject defines the vertex array object to bind
  29318. * @param indexBuffer defines the index buffer to bind
  29319. */
  29320. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29321. /**
  29322. * Bind webGl buffers directly to the webGL context
  29323. * @param vertexBuffer defines the vertex buffer to bind
  29324. * @param indexBuffer defines the index buffer to bind
  29325. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29326. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29327. * @param effect defines the effect associated with the vertex buffer
  29328. */
  29329. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29330. private _unbindVertexArrayObject;
  29331. /**
  29332. * Bind a list of vertex buffers to the webGL context
  29333. * @param vertexBuffers defines the list of vertex buffers to bind
  29334. * @param indexBuffer defines the index buffer to bind
  29335. * @param effect defines the effect associated with the vertex buffers
  29336. */
  29337. bindBuffers(vertexBuffers: {
  29338. [key: string]: Nullable<VertexBuffer>;
  29339. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29340. /**
  29341. * Unbind all instance attributes
  29342. */
  29343. unbindInstanceAttributes(): void;
  29344. /**
  29345. * Release and free the memory of a vertex array object
  29346. * @param vao defines the vertex array object to delete
  29347. */
  29348. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29349. /** @hidden */
  29350. _releaseBuffer(buffer: DataBuffer): boolean;
  29351. /**
  29352. * Creates a webGL buffer to use with instanciation
  29353. * @param capacity defines the size of the buffer
  29354. * @returns the webGL buffer
  29355. */
  29356. createInstancesBuffer(capacity: number): DataBuffer;
  29357. /**
  29358. * Delete a webGL buffer used with instanciation
  29359. * @param buffer defines the webGL buffer to delete
  29360. */
  29361. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29362. /**
  29363. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29364. * @param instancesBuffer defines the webGL buffer to update and bind
  29365. * @param data defines the data to store in the buffer
  29366. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29367. */
  29368. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29369. /**
  29370. * Apply all cached states (depth, culling, stencil and alpha)
  29371. */
  29372. applyStates(): void;
  29373. /**
  29374. * Send a draw order
  29375. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29376. * @param indexStart defines the starting index
  29377. * @param indexCount defines the number of index to draw
  29378. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29379. */
  29380. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29381. /**
  29382. * Draw a list of points
  29383. * @param verticesStart defines the index of first vertex to draw
  29384. * @param verticesCount defines the count of vertices to draw
  29385. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29386. */
  29387. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29388. /**
  29389. * Draw a list of unindexed primitives
  29390. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29391. * @param verticesStart defines the index of first vertex to draw
  29392. * @param verticesCount defines the count of vertices to draw
  29393. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29394. */
  29395. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29396. /**
  29397. * Draw a list of indexed primitives
  29398. * @param fillMode defines the primitive to use
  29399. * @param indexStart defines the starting index
  29400. * @param indexCount defines the number of index to draw
  29401. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29402. */
  29403. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29404. /**
  29405. * Draw a list of unindexed primitives
  29406. * @param fillMode defines the primitive to use
  29407. * @param verticesStart defines the index of first vertex to draw
  29408. * @param verticesCount defines the count of vertices to draw
  29409. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29410. */
  29411. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29412. private _drawMode;
  29413. /** @hidden */
  29414. _releaseEffect(effect: Effect): void;
  29415. /** @hidden */
  29416. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29417. /**
  29418. * Create a new effect (used to store vertex/fragment shaders)
  29419. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29420. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29421. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29422. * @param samplers defines an array of string used to represent textures
  29423. * @param defines defines the string containing the defines to use to compile the shaders
  29424. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29425. * @param onCompiled defines a function to call when the effect creation is successful
  29426. * @param onError defines a function to call when the effect creation has failed
  29427. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29428. * @returns the new Effect
  29429. */
  29430. 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;
  29431. private _compileShader;
  29432. private _compileRawShader;
  29433. /**
  29434. * Directly creates a webGL program
  29435. * @param pipelineContext defines the pipeline context to attach to
  29436. * @param vertexCode defines the vertex shader code to use
  29437. * @param fragmentCode defines the fragment shader code to use
  29438. * @param context defines the webGL context to use (if not set, the current one will be used)
  29439. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29440. * @returns the new webGL program
  29441. */
  29442. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29443. /**
  29444. * Creates a webGL program
  29445. * @param pipelineContext defines the pipeline context to attach to
  29446. * @param vertexCode defines the vertex shader code to use
  29447. * @param fragmentCode defines the fragment shader code to use
  29448. * @param defines defines the string containing the defines to use to compile the shaders
  29449. * @param context defines the webGL context to use (if not set, the current one will be used)
  29450. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29451. * @returns the new webGL program
  29452. */
  29453. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29454. /**
  29455. * Creates a new pipeline context
  29456. * @returns the new pipeline
  29457. */
  29458. createPipelineContext(): WebGLPipelineContext;
  29459. private _createShaderProgram;
  29460. private _finalizePipelineContext;
  29461. /** @hidden */
  29462. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29463. /** @hidden */
  29464. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29465. /** @hidden */
  29466. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29467. /**
  29468. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29469. * @param pipelineContext defines the pipeline context to use
  29470. * @param uniformsNames defines the list of uniform names
  29471. * @returns an array of webGL uniform locations
  29472. */
  29473. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29474. /**
  29475. * Gets the lsit of active attributes for a given webGL program
  29476. * @param pipelineContext defines the pipeline context to use
  29477. * @param attributesNames defines the list of attribute names to get
  29478. * @returns an array of indices indicating the offset of each attribute
  29479. */
  29480. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29481. /**
  29482. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29483. * @param effect defines the effect to activate
  29484. */
  29485. enableEffect(effect: Nullable<Effect>): void;
  29486. /**
  29487. * Set the value of an uniform to an array of int32
  29488. * @param uniform defines the webGL uniform location where to store the value
  29489. * @param array defines the array of int32 to store
  29490. */
  29491. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29492. /**
  29493. * Set the value of an uniform to an array of int32 (stored as vec2)
  29494. * @param uniform defines the webGL uniform location where to store the value
  29495. * @param array defines the array of int32 to store
  29496. */
  29497. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29498. /**
  29499. * Set the value of an uniform to an array of int32 (stored as vec3)
  29500. * @param uniform defines the webGL uniform location where to store the value
  29501. * @param array defines the array of int32 to store
  29502. */
  29503. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29504. /**
  29505. * Set the value of an uniform to an array of int32 (stored as vec4)
  29506. * @param uniform defines the webGL uniform location where to store the value
  29507. * @param array defines the array of int32 to store
  29508. */
  29509. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29510. /**
  29511. * Set the value of an uniform to an array of float32
  29512. * @param uniform defines the webGL uniform location where to store the value
  29513. * @param array defines the array of float32 to store
  29514. */
  29515. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29516. /**
  29517. * Set the value of an uniform to an array of float32 (stored as vec2)
  29518. * @param uniform defines the webGL uniform location where to store the value
  29519. * @param array defines the array of float32 to store
  29520. */
  29521. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29522. /**
  29523. * Set the value of an uniform to an array of float32 (stored as vec3)
  29524. * @param uniform defines the webGL uniform location where to store the value
  29525. * @param array defines the array of float32 to store
  29526. */
  29527. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29528. /**
  29529. * Set the value of an uniform to an array of float32 (stored as vec4)
  29530. * @param uniform defines the webGL uniform location where to store the value
  29531. * @param array defines the array of float32 to store
  29532. */
  29533. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29534. /**
  29535. * Set the value of an uniform to an array of number
  29536. * @param uniform defines the webGL uniform location where to store the value
  29537. * @param array defines the array of number to store
  29538. */
  29539. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29540. /**
  29541. * Set the value of an uniform to an array of number (stored as vec2)
  29542. * @param uniform defines the webGL uniform location where to store the value
  29543. * @param array defines the array of number to store
  29544. */
  29545. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29546. /**
  29547. * Set the value of an uniform to an array of number (stored as vec3)
  29548. * @param uniform defines the webGL uniform location where to store the value
  29549. * @param array defines the array of number to store
  29550. */
  29551. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29552. /**
  29553. * Set the value of an uniform to an array of number (stored as vec4)
  29554. * @param uniform defines the webGL uniform location where to store the value
  29555. * @param array defines the array of number to store
  29556. */
  29557. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29558. /**
  29559. * Set the value of an uniform to an array of float32 (stored as matrices)
  29560. * @param uniform defines the webGL uniform location where to store the value
  29561. * @param matrices defines the array of float32 to store
  29562. */
  29563. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29564. /**
  29565. * Set the value of an uniform to a matrix
  29566. * @param uniform defines the webGL uniform location where to store the value
  29567. * @param matrix defines the matrix to store
  29568. */
  29569. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29570. /**
  29571. * Set the value of an uniform to a matrix (3x3)
  29572. * @param uniform defines the webGL uniform location where to store the value
  29573. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29574. */
  29575. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29576. /**
  29577. * Set the value of an uniform to a matrix (2x2)
  29578. * @param uniform defines the webGL uniform location where to store the value
  29579. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29580. */
  29581. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29582. /**
  29583. * Set the value of an uniform to a number (int)
  29584. * @param uniform defines the webGL uniform location where to store the value
  29585. * @param value defines the int number to store
  29586. */
  29587. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29588. /**
  29589. * Set the value of an uniform to a number (float)
  29590. * @param uniform defines the webGL uniform location where to store the value
  29591. * @param value defines the float number to store
  29592. */
  29593. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29594. /**
  29595. * Set the value of an uniform to a vec2
  29596. * @param uniform defines the webGL uniform location where to store the value
  29597. * @param x defines the 1st component of the value
  29598. * @param y defines the 2nd component of the value
  29599. */
  29600. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29601. /**
  29602. * Set the value of an uniform to a vec3
  29603. * @param uniform defines the webGL uniform location where to store the value
  29604. * @param x defines the 1st component of the value
  29605. * @param y defines the 2nd component of the value
  29606. * @param z defines the 3rd component of the value
  29607. */
  29608. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29609. /**
  29610. * Set the value of an uniform to a boolean
  29611. * @param uniform defines the webGL uniform location where to store the value
  29612. * @param bool defines the boolean to store
  29613. */
  29614. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29615. /**
  29616. * Set the value of an uniform to a vec4
  29617. * @param uniform defines the webGL uniform location where to store the value
  29618. * @param x defines the 1st component of the value
  29619. * @param y defines the 2nd component of the value
  29620. * @param z defines the 3rd component of the value
  29621. * @param w defines the 4th component of the value
  29622. */
  29623. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29624. /**
  29625. * Set the value of an uniform to a Color3
  29626. * @param uniform defines the webGL uniform location where to store the value
  29627. * @param color3 defines the color to store
  29628. */
  29629. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29630. /**
  29631. * Set the value of an uniform to a Color3 and an alpha value
  29632. * @param uniform defines the webGL uniform location where to store the value
  29633. * @param color3 defines the color to store
  29634. * @param alpha defines the alpha component to store
  29635. */
  29636. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29637. /**
  29638. * Sets a Color4 on a uniform variable
  29639. * @param uniform defines the uniform location
  29640. * @param color4 defines the value to be set
  29641. */
  29642. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29643. /**
  29644. * Set various states to the webGL context
  29645. * @param culling defines backface culling state
  29646. * @param zOffset defines the value to apply to zOffset (0 by default)
  29647. * @param force defines if states must be applied even if cache is up to date
  29648. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29649. */
  29650. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29651. /**
  29652. * Set the z offset to apply to current rendering
  29653. * @param value defines the offset to apply
  29654. */
  29655. setZOffset(value: number): void;
  29656. /**
  29657. * Gets the current value of the zOffset
  29658. * @returns the current zOffset state
  29659. */
  29660. getZOffset(): number;
  29661. /**
  29662. * Enable or disable depth buffering
  29663. * @param enable defines the state to set
  29664. */
  29665. setDepthBuffer(enable: boolean): void;
  29666. /**
  29667. * Gets a boolean indicating if depth writing is enabled
  29668. * @returns the current depth writing state
  29669. */
  29670. getDepthWrite(): boolean;
  29671. /**
  29672. * Enable or disable depth writing
  29673. * @param enable defines the state to set
  29674. */
  29675. setDepthWrite(enable: boolean): void;
  29676. /**
  29677. * Enable or disable color writing
  29678. * @param enable defines the state to set
  29679. */
  29680. setColorWrite(enable: boolean): void;
  29681. /**
  29682. * Gets a boolean indicating if color writing is enabled
  29683. * @returns the current color writing state
  29684. */
  29685. getColorWrite(): boolean;
  29686. /**
  29687. * Sets alpha constants used by some alpha blending modes
  29688. * @param r defines the red component
  29689. * @param g defines the green component
  29690. * @param b defines the blue component
  29691. * @param a defines the alpha component
  29692. */
  29693. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29694. /**
  29695. * Sets the current alpha mode
  29696. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29697. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29698. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29699. */
  29700. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29701. /**
  29702. * Gets the current alpha mode
  29703. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29704. * @returns the current alpha mode
  29705. */
  29706. getAlphaMode(): number;
  29707. /**
  29708. * Clears the list of texture accessible through engine.
  29709. * This can help preventing texture load conflict due to name collision.
  29710. */
  29711. clearInternalTexturesCache(): void;
  29712. /**
  29713. * Force the entire cache to be cleared
  29714. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29715. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29716. */
  29717. wipeCaches(bruteForce?: boolean): void;
  29718. /**
  29719. * Set the compressed texture format to use, based on the formats you have, and the formats
  29720. * supported by the hardware / browser.
  29721. *
  29722. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29723. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29724. * to API arguments needed to compressed textures. This puts the burden on the container
  29725. * generator to house the arcane code for determining these for current & future formats.
  29726. *
  29727. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29728. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29729. *
  29730. * Note: The result of this call is not taken into account when a texture is base64.
  29731. *
  29732. * @param formatsAvailable defines the list of those format families you have created
  29733. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29734. *
  29735. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29736. * @returns The extension selected.
  29737. */
  29738. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29739. /** @hidden */
  29740. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29741. min: number;
  29742. mag: number;
  29743. };
  29744. /** @hidden */
  29745. _createTexture(): WebGLTexture;
  29746. /**
  29747. * Usually called from Texture.ts.
  29748. * Passed information to create a WebGLTexture
  29749. * @param urlArg defines a value which contains one of the following:
  29750. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29751. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29752. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29753. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29754. * @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)
  29755. * @param scene needed for loading to the correct scene
  29756. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29757. * @param onLoad optional callback to be called upon successful completion
  29758. * @param onError optional callback to be called upon failure
  29759. * @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
  29760. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29761. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29762. * @param forcedExtension defines the extension to use to pick the right loader
  29763. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29764. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29765. */
  29766. 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;
  29767. /**
  29768. * @hidden
  29769. * Rescales a texture
  29770. * @param source input texutre
  29771. * @param destination destination texture
  29772. * @param scene scene to use to render the resize
  29773. * @param internalFormat format to use when resizing
  29774. * @param onComplete callback to be called when resize has completed
  29775. */
  29776. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29777. private _unpackFlipYCached;
  29778. /**
  29779. * In case you are sharing the context with other applications, it might
  29780. * be interested to not cache the unpack flip y state to ensure a consistent
  29781. * value would be set.
  29782. */
  29783. enableUnpackFlipYCached: boolean;
  29784. /** @hidden */
  29785. _unpackFlipY(value: boolean): void;
  29786. /** @hidden */
  29787. _getUnpackAlignement(): number;
  29788. /**
  29789. * Creates a dynamic texture
  29790. * @param width defines the width of the texture
  29791. * @param height defines the height of the texture
  29792. * @param generateMipMaps defines if the engine should generate the mip levels
  29793. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29794. * @returns the dynamic texture inside an InternalTexture
  29795. */
  29796. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29797. /**
  29798. * Update the sampling mode of a given texture
  29799. * @param samplingMode defines the required sampling mode
  29800. * @param texture defines the texture to update
  29801. */
  29802. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29803. /**
  29804. * Update the content of a dynamic texture
  29805. * @param texture defines the texture to update
  29806. * @param canvas defines the canvas containing the source
  29807. * @param invertY defines if data must be stored with Y axis inverted
  29808. * @param premulAlpha defines if alpha is stored as premultiplied
  29809. * @param format defines the format of the data
  29810. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29811. */
  29812. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29813. /**
  29814. * Update a video texture
  29815. * @param texture defines the texture to update
  29816. * @param video defines the video element to use
  29817. * @param invertY defines if data must be stored with Y axis inverted
  29818. */
  29819. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29820. /**
  29821. * Updates a depth texture Comparison Mode and Function.
  29822. * If the comparison Function is equal to 0, the mode will be set to none.
  29823. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29824. * @param texture The texture to set the comparison function for
  29825. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29826. */
  29827. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29828. /** @hidden */
  29829. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29830. width: number;
  29831. height: number;
  29832. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29833. /**
  29834. * Creates a depth stencil texture.
  29835. * This is only available in WebGL 2 or with the depth texture extension available.
  29836. * @param size The size of face edge in the texture.
  29837. * @param options The options defining the texture.
  29838. * @returns The texture
  29839. */
  29840. createDepthStencilTexture(size: number | {
  29841. width: number;
  29842. height: number;
  29843. }, options: DepthTextureCreationOptions): InternalTexture;
  29844. /**
  29845. * Creates a depth stencil texture.
  29846. * This is only available in WebGL 2 or with the depth texture extension available.
  29847. * @param size The size of face edge in the texture.
  29848. * @param options The options defining the texture.
  29849. * @returns The texture
  29850. */
  29851. private _createDepthStencilTexture;
  29852. /**
  29853. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29854. * @param renderTarget The render target to set the frame buffer for
  29855. */
  29856. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29857. /**
  29858. * Creates a new render target texture
  29859. * @param size defines the size of the texture
  29860. * @param options defines the options used to create the texture
  29861. * @returns a new render target texture stored in an InternalTexture
  29862. */
  29863. createRenderTargetTexture(size: number | {
  29864. width: number;
  29865. height: number;
  29866. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29867. /** @hidden */
  29868. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29869. /**
  29870. * Updates the sample count of a render target texture
  29871. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29872. * @param texture defines the texture to update
  29873. * @param samples defines the sample count to set
  29874. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29875. */
  29876. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29877. /** @hidden */
  29878. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29879. /** @hidden */
  29880. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29881. /** @hidden */
  29882. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29883. /** @hidden */
  29884. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29885. /**
  29886. * @hidden
  29887. */
  29888. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29889. private _prepareWebGLTextureContinuation;
  29890. private _prepareWebGLTexture;
  29891. /** @hidden */
  29892. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29893. /** @hidden */
  29894. _releaseFramebufferObjects(texture: InternalTexture): void;
  29895. /** @hidden */
  29896. _releaseTexture(texture: InternalTexture): void;
  29897. private setProgram;
  29898. private _boundUniforms;
  29899. /**
  29900. * Binds an effect to the webGL context
  29901. * @param effect defines the effect to bind
  29902. */
  29903. bindSamplers(effect: Effect): void;
  29904. private _activateCurrentTexture;
  29905. /** @hidden */
  29906. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29907. /** @hidden */
  29908. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29909. /**
  29910. * Sets a texture to the webGL context from a postprocess
  29911. * @param channel defines the channel to use
  29912. * @param postProcess defines the source postprocess
  29913. */
  29914. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29915. /**
  29916. * Binds the output of the passed in post process to the texture channel specified
  29917. * @param channel The channel the texture should be bound to
  29918. * @param postProcess The post process which's output should be bound
  29919. */
  29920. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29921. /**
  29922. * Unbind all textures from the webGL context
  29923. */
  29924. unbindAllTextures(): void;
  29925. /**
  29926. * Sets a texture to the according uniform.
  29927. * @param channel The texture channel
  29928. * @param uniform The uniform to set
  29929. * @param texture The texture to apply
  29930. */
  29931. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29932. /**
  29933. * Sets a depth stencil texture from a render target to the according uniform.
  29934. * @param channel The texture channel
  29935. * @param uniform The uniform to set
  29936. * @param texture The render target texture containing the depth stencil texture to apply
  29937. */
  29938. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29939. private _bindSamplerUniformToChannel;
  29940. private _getTextureWrapMode;
  29941. private _setTexture;
  29942. /**
  29943. * Sets an array of texture to the webGL context
  29944. * @param channel defines the channel where the texture array must be set
  29945. * @param uniform defines the associated uniform location
  29946. * @param textures defines the array of textures to bind
  29947. */
  29948. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29949. /** @hidden */
  29950. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29951. private _setTextureParameterFloat;
  29952. private _setTextureParameterInteger;
  29953. /**
  29954. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29955. * @param x defines the x coordinate of the rectangle where pixels must be read
  29956. * @param y defines the y coordinate of the rectangle where pixels must be read
  29957. * @param width defines the width of the rectangle where pixels must be read
  29958. * @param height defines the height of the rectangle where pixels must be read
  29959. * @returns a Uint8Array containing RGBA colors
  29960. */
  29961. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29962. /**
  29963. * Add an externaly attached data from its key.
  29964. * This method call will fail and return false, if such key already exists.
  29965. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29966. * @param key the unique key that identifies the data
  29967. * @param data the data object to associate to the key for this Engine instance
  29968. * @return true if no such key were already present and the data was added successfully, false otherwise
  29969. */
  29970. addExternalData<T>(key: string, data: T): boolean;
  29971. /**
  29972. * Get an externaly attached data from its key
  29973. * @param key the unique key that identifies the data
  29974. * @return the associated data, if present (can be null), or undefined if not present
  29975. */
  29976. getExternalData<T>(key: string): T;
  29977. /**
  29978. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29979. * @param key the unique key that identifies the data
  29980. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29981. * @return the associated data, can be null if the factory returned null.
  29982. */
  29983. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29984. /**
  29985. * Remove an externaly attached data from the Engine instance
  29986. * @param key the unique key that identifies the data
  29987. * @return true if the data was successfully removed, false if it doesn't exist
  29988. */
  29989. removeExternalData(key: string): boolean;
  29990. /**
  29991. * Unbind all vertex attributes from the webGL context
  29992. */
  29993. unbindAllAttributes(): void;
  29994. /**
  29995. * 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
  29996. */
  29997. releaseEffects(): void;
  29998. /**
  29999. * Dispose and release all associated resources
  30000. */
  30001. dispose(): void;
  30002. /**
  30003. * Display the loading screen
  30004. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30005. */
  30006. displayLoadingUI(): void;
  30007. /**
  30008. * Hide the loading screen
  30009. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30010. */
  30011. hideLoadingUI(): void;
  30012. /**
  30013. * Gets the current loading screen object
  30014. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30015. */
  30016. /**
  30017. * Sets the current loading screen object
  30018. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30019. */
  30020. loadingScreen: ILoadingScreen;
  30021. /**
  30022. * Sets the current loading screen text
  30023. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30024. */
  30025. loadingUIText: string;
  30026. /**
  30027. * Sets the current loading screen background color
  30028. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30029. */
  30030. loadingUIBackgroundColor: string;
  30031. /**
  30032. * Attach a new callback raised when context lost event is fired
  30033. * @param callback defines the callback to call
  30034. */
  30035. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30036. /**
  30037. * Attach a new callback raised when context restored event is fired
  30038. * @param callback defines the callback to call
  30039. */
  30040. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30041. /**
  30042. * Gets the source code of the vertex shader associated with a specific webGL program
  30043. * @param program defines the program to use
  30044. * @returns a string containing the source code of the vertex shader associated with the program
  30045. */
  30046. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30047. /**
  30048. * Gets the source code of the fragment shader associated with a specific webGL program
  30049. * @param program defines the program to use
  30050. * @returns a string containing the source code of the fragment shader associated with the program
  30051. */
  30052. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30053. /**
  30054. * Get the current error code of the webGL context
  30055. * @returns the error code
  30056. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30057. */
  30058. getError(): number;
  30059. /**
  30060. * Gets the current framerate
  30061. * @returns a number representing the framerate
  30062. */
  30063. getFps(): number;
  30064. /**
  30065. * Gets the time spent between current and previous frame
  30066. * @returns a number representing the delta time in ms
  30067. */
  30068. getDeltaTime(): number;
  30069. private _measureFps;
  30070. /** @hidden */
  30071. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30072. private _canRenderToFloatFramebuffer;
  30073. private _canRenderToHalfFloatFramebuffer;
  30074. private _canRenderToFramebuffer;
  30075. /** @hidden */
  30076. _getWebGLTextureType(type: number): number;
  30077. /** @hidden */
  30078. _getInternalFormat(format: number): number;
  30079. /** @hidden */
  30080. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30081. /** @hidden */
  30082. _getRGBAMultiSampleBufferFormat(type: number): number;
  30083. /** @hidden */
  30084. _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;
  30085. /** @hidden */
  30086. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30087. /**
  30088. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30089. * @returns true if the engine can be created
  30090. * @ignorenaming
  30091. */
  30092. static isSupported(): boolean;
  30093. }
  30094. }
  30095. declare module "babylonjs/Materials/effect" {
  30096. import { Observable } from "babylonjs/Misc/observable";
  30097. import { Nullable } from "babylonjs/types";
  30098. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  30099. import { IDisposable } from "babylonjs/scene";
  30100. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30101. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30102. import { Engine } from "babylonjs/Engines/engine";
  30103. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30104. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30106. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30108. /**
  30109. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  30110. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  30111. */
  30112. export class EffectFallbacks {
  30113. private _defines;
  30114. private _currentRank;
  30115. private _maxRank;
  30116. private _mesh;
  30117. /**
  30118. * Removes the fallback from the bound mesh.
  30119. */
  30120. unBindMesh(): void;
  30121. /**
  30122. * Adds a fallback on the specified property.
  30123. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30124. * @param define The name of the define in the shader
  30125. */
  30126. addFallback(rank: number, define: string): void;
  30127. /**
  30128. * Sets the mesh to use CPU skinning when needing to fallback.
  30129. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30130. * @param mesh The mesh to use the fallbacks.
  30131. */
  30132. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30133. /**
  30134. * Checks to see if more fallbacks are still availible.
  30135. */
  30136. readonly isMoreFallbacks: boolean;
  30137. /**
  30138. * Removes the defines that should be removed when falling back.
  30139. * @param currentDefines defines the current define statements for the shader.
  30140. * @param effect defines the current effect we try to compile
  30141. * @returns The resulting defines with defines of the current rank removed.
  30142. */
  30143. reduce(currentDefines: string, effect: Effect): string;
  30144. }
  30145. /**
  30146. * Options to be used when creating an effect.
  30147. */
  30148. export class EffectCreationOptions {
  30149. /**
  30150. * Atrributes that will be used in the shader.
  30151. */
  30152. attributes: string[];
  30153. /**
  30154. * Uniform varible names that will be set in the shader.
  30155. */
  30156. uniformsNames: string[];
  30157. /**
  30158. * Uniform buffer varible names that will be set in the shader.
  30159. */
  30160. uniformBuffersNames: string[];
  30161. /**
  30162. * Sampler texture variable names that will be set in the shader.
  30163. */
  30164. samplers: string[];
  30165. /**
  30166. * Define statements that will be set in the shader.
  30167. */
  30168. defines: any;
  30169. /**
  30170. * Possible fallbacks for this effect to improve performance when needed.
  30171. */
  30172. fallbacks: Nullable<EffectFallbacks>;
  30173. /**
  30174. * Callback that will be called when the shader is compiled.
  30175. */
  30176. onCompiled: Nullable<(effect: Effect) => void>;
  30177. /**
  30178. * Callback that will be called if an error occurs during shader compilation.
  30179. */
  30180. onError: Nullable<(effect: Effect, errors: string) => void>;
  30181. /**
  30182. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30183. */
  30184. indexParameters: any;
  30185. /**
  30186. * Max number of lights that can be used in the shader.
  30187. */
  30188. maxSimultaneousLights: number;
  30189. /**
  30190. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30191. */
  30192. transformFeedbackVaryings: Nullable<string[]>;
  30193. }
  30194. /**
  30195. * Effect containing vertex and fragment shader that can be executed on an object.
  30196. */
  30197. export class Effect implements IDisposable {
  30198. /**
  30199. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30200. */
  30201. static ShadersRepository: string;
  30202. /**
  30203. * Name of the effect.
  30204. */
  30205. name: any;
  30206. /**
  30207. * String container all the define statements that should be set on the shader.
  30208. */
  30209. defines: string;
  30210. /**
  30211. * Callback that will be called when the shader is compiled.
  30212. */
  30213. onCompiled: Nullable<(effect: Effect) => void>;
  30214. /**
  30215. * Callback that will be called if an error occurs during shader compilation.
  30216. */
  30217. onError: Nullable<(effect: Effect, errors: string) => void>;
  30218. /**
  30219. * Callback that will be called when effect is bound.
  30220. */
  30221. onBind: Nullable<(effect: Effect) => void>;
  30222. /**
  30223. * Unique ID of the effect.
  30224. */
  30225. uniqueId: number;
  30226. /**
  30227. * Observable that will be called when the shader is compiled.
  30228. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30229. */
  30230. onCompileObservable: Observable<Effect>;
  30231. /**
  30232. * Observable that will be called if an error occurs during shader compilation.
  30233. */
  30234. onErrorObservable: Observable<Effect>;
  30235. /** @hidden */
  30236. _onBindObservable: Nullable<Observable<Effect>>;
  30237. /**
  30238. * Observable that will be called when effect is bound.
  30239. */
  30240. readonly onBindObservable: Observable<Effect>;
  30241. /** @hidden */
  30242. _bonesComputationForcedToCPU: boolean;
  30243. private static _uniqueIdSeed;
  30244. private _engine;
  30245. private _uniformBuffersNames;
  30246. private _uniformsNames;
  30247. private _samplerList;
  30248. private _samplers;
  30249. private _isReady;
  30250. private _compilationError;
  30251. private _attributesNames;
  30252. private _attributes;
  30253. private _uniforms;
  30254. /**
  30255. * Key for the effect.
  30256. * @hidden
  30257. */
  30258. _key: string;
  30259. private _indexParameters;
  30260. private _fallbacks;
  30261. private _vertexSourceCode;
  30262. private _fragmentSourceCode;
  30263. private _vertexSourceCodeOverride;
  30264. private _fragmentSourceCodeOverride;
  30265. private _transformFeedbackVaryings;
  30266. /**
  30267. * Compiled shader to webGL program.
  30268. * @hidden
  30269. */
  30270. _pipelineContext: Nullable<IPipelineContext>;
  30271. private _valueCache;
  30272. private static _baseCache;
  30273. /**
  30274. * Instantiates an effect.
  30275. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30276. * @param baseName Name of the effect.
  30277. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30278. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30279. * @param samplers List of sampler variables that will be passed to the shader.
  30280. * @param engine Engine to be used to render the effect
  30281. * @param defines Define statements to be added to the shader.
  30282. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30283. * @param onCompiled Callback that will be called when the shader is compiled.
  30284. * @param onError Callback that will be called if an error occurs during shader compilation.
  30285. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30286. */
  30287. 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);
  30288. private _useFinalCode;
  30289. /**
  30290. * Unique key for this effect
  30291. */
  30292. readonly key: string;
  30293. /**
  30294. * If the effect has been compiled and prepared.
  30295. * @returns if the effect is compiled and prepared.
  30296. */
  30297. isReady(): boolean;
  30298. /**
  30299. * The engine the effect was initialized with.
  30300. * @returns the engine.
  30301. */
  30302. getEngine(): Engine;
  30303. /**
  30304. * The pipeline context for this effect
  30305. * @returns the associated pipeline context
  30306. */
  30307. getPipelineContext(): Nullable<IPipelineContext>;
  30308. /**
  30309. * The set of names of attribute variables for the shader.
  30310. * @returns An array of attribute names.
  30311. */
  30312. getAttributesNames(): string[];
  30313. /**
  30314. * Returns the attribute at the given index.
  30315. * @param index The index of the attribute.
  30316. * @returns The location of the attribute.
  30317. */
  30318. getAttributeLocation(index: number): number;
  30319. /**
  30320. * Returns the attribute based on the name of the variable.
  30321. * @param name of the attribute to look up.
  30322. * @returns the attribute location.
  30323. */
  30324. getAttributeLocationByName(name: string): number;
  30325. /**
  30326. * The number of attributes.
  30327. * @returns the numnber of attributes.
  30328. */
  30329. getAttributesCount(): number;
  30330. /**
  30331. * Gets the index of a uniform variable.
  30332. * @param uniformName of the uniform to look up.
  30333. * @returns the index.
  30334. */
  30335. getUniformIndex(uniformName: string): number;
  30336. /**
  30337. * Returns the attribute based on the name of the variable.
  30338. * @param uniformName of the uniform to look up.
  30339. * @returns the location of the uniform.
  30340. */
  30341. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30342. /**
  30343. * Returns an array of sampler variable names
  30344. * @returns The array of sampler variable neames.
  30345. */
  30346. getSamplers(): string[];
  30347. /**
  30348. * The error from the last compilation.
  30349. * @returns the error string.
  30350. */
  30351. getCompilationError(): string;
  30352. /**
  30353. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30354. * @param func The callback to be used.
  30355. */
  30356. executeWhenCompiled(func: (effect: Effect) => void): void;
  30357. private _checkIsReady;
  30358. /** @hidden */
  30359. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30360. /** @hidden */
  30361. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30362. /** @hidden */
  30363. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30364. /**
  30365. * Recompiles the webGL program
  30366. * @param vertexSourceCode The source code for the vertex shader.
  30367. * @param fragmentSourceCode The source code for the fragment shader.
  30368. * @param onCompiled Callback called when completed.
  30369. * @param onError Callback called on error.
  30370. * @hidden
  30371. */
  30372. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30373. /**
  30374. * Prepares the effect
  30375. * @hidden
  30376. */
  30377. _prepareEffect(): void;
  30378. /**
  30379. * Checks if the effect is supported. (Must be called after compilation)
  30380. */
  30381. readonly isSupported: boolean;
  30382. /**
  30383. * Binds a texture to the engine to be used as output of the shader.
  30384. * @param channel Name of the output variable.
  30385. * @param texture Texture to bind.
  30386. * @hidden
  30387. */
  30388. _bindTexture(channel: string, texture: InternalTexture): void;
  30389. /**
  30390. * Sets a texture on the engine to be used in the shader.
  30391. * @param channel Name of the sampler variable.
  30392. * @param texture Texture to set.
  30393. */
  30394. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30395. /**
  30396. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30397. * @param channel Name of the sampler variable.
  30398. * @param texture Texture to set.
  30399. */
  30400. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30401. /**
  30402. * Sets an array of textures on the engine to be used in the shader.
  30403. * @param channel Name of the variable.
  30404. * @param textures Textures to set.
  30405. */
  30406. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30407. /**
  30408. * 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)
  30409. * @param channel Name of the sampler variable.
  30410. * @param postProcess Post process to get the input texture from.
  30411. */
  30412. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30413. /**
  30414. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30415. * 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)
  30416. * @param channel Name of the sampler variable.
  30417. * @param postProcess Post process to get the output texture from.
  30418. */
  30419. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30420. /** @hidden */
  30421. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30422. /** @hidden */
  30423. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30424. /** @hidden */
  30425. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30426. /** @hidden */
  30427. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30428. /**
  30429. * Binds a buffer to a uniform.
  30430. * @param buffer Buffer to bind.
  30431. * @param name Name of the uniform variable to bind to.
  30432. */
  30433. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30434. /**
  30435. * Binds block to a uniform.
  30436. * @param blockName Name of the block to bind.
  30437. * @param index Index to bind.
  30438. */
  30439. bindUniformBlock(blockName: string, index: number): void;
  30440. /**
  30441. * Sets an interger value on a uniform variable.
  30442. * @param uniformName Name of the variable.
  30443. * @param value Value to be set.
  30444. * @returns this effect.
  30445. */
  30446. setInt(uniformName: string, value: number): Effect;
  30447. /**
  30448. * Sets an int array on a uniform variable.
  30449. * @param uniformName Name of the variable.
  30450. * @param array array to be set.
  30451. * @returns this effect.
  30452. */
  30453. setIntArray(uniformName: string, array: Int32Array): Effect;
  30454. /**
  30455. * 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)
  30456. * @param uniformName Name of the variable.
  30457. * @param array array to be set.
  30458. * @returns this effect.
  30459. */
  30460. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30461. /**
  30462. * 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)
  30463. * @param uniformName Name of the variable.
  30464. * @param array array to be set.
  30465. * @returns this effect.
  30466. */
  30467. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30468. /**
  30469. * 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)
  30470. * @param uniformName Name of the variable.
  30471. * @param array array to be set.
  30472. * @returns this effect.
  30473. */
  30474. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30475. /**
  30476. * Sets an float array on a uniform variable.
  30477. * @param uniformName Name of the variable.
  30478. * @param array array to be set.
  30479. * @returns this effect.
  30480. */
  30481. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30482. /**
  30483. * 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)
  30484. * @param uniformName Name of the variable.
  30485. * @param array array to be set.
  30486. * @returns this effect.
  30487. */
  30488. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30489. /**
  30490. * 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)
  30491. * @param uniformName Name of the variable.
  30492. * @param array array to be set.
  30493. * @returns this effect.
  30494. */
  30495. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30496. /**
  30497. * 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)
  30498. * @param uniformName Name of the variable.
  30499. * @param array array to be set.
  30500. * @returns this effect.
  30501. */
  30502. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30503. /**
  30504. * Sets an array on a uniform variable.
  30505. * @param uniformName Name of the variable.
  30506. * @param array array to be set.
  30507. * @returns this effect.
  30508. */
  30509. setArray(uniformName: string, array: number[]): Effect;
  30510. /**
  30511. * 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)
  30512. * @param uniformName Name of the variable.
  30513. * @param array array to be set.
  30514. * @returns this effect.
  30515. */
  30516. setArray2(uniformName: string, array: number[]): Effect;
  30517. /**
  30518. * 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)
  30519. * @param uniformName Name of the variable.
  30520. * @param array array to be set.
  30521. * @returns this effect.
  30522. */
  30523. setArray3(uniformName: string, array: number[]): Effect;
  30524. /**
  30525. * 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)
  30526. * @param uniformName Name of the variable.
  30527. * @param array array to be set.
  30528. * @returns this effect.
  30529. */
  30530. setArray4(uniformName: string, array: number[]): Effect;
  30531. /**
  30532. * Sets matrices on a uniform variable.
  30533. * @param uniformName Name of the variable.
  30534. * @param matrices matrices to be set.
  30535. * @returns this effect.
  30536. */
  30537. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30538. /**
  30539. * Sets matrix on a uniform variable.
  30540. * @param uniformName Name of the variable.
  30541. * @param matrix matrix to be set.
  30542. * @returns this effect.
  30543. */
  30544. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30545. /**
  30546. * 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)
  30547. * @param uniformName Name of the variable.
  30548. * @param matrix matrix to be set.
  30549. * @returns this effect.
  30550. */
  30551. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30552. /**
  30553. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30554. * @param uniformName Name of the variable.
  30555. * @param matrix matrix to be set.
  30556. * @returns this effect.
  30557. */
  30558. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30559. /**
  30560. * Sets a float on a uniform variable.
  30561. * @param uniformName Name of the variable.
  30562. * @param value value to be set.
  30563. * @returns this effect.
  30564. */
  30565. setFloat(uniformName: string, value: number): Effect;
  30566. /**
  30567. * Sets a boolean on a uniform variable.
  30568. * @param uniformName Name of the variable.
  30569. * @param bool value to be set.
  30570. * @returns this effect.
  30571. */
  30572. setBool(uniformName: string, bool: boolean): Effect;
  30573. /**
  30574. * Sets a Vector2 on a uniform variable.
  30575. * @param uniformName Name of the variable.
  30576. * @param vector2 vector2 to be set.
  30577. * @returns this effect.
  30578. */
  30579. setVector2(uniformName: string, vector2: Vector2): Effect;
  30580. /**
  30581. * Sets a float2 on a uniform variable.
  30582. * @param uniformName Name of the variable.
  30583. * @param x First float in float2.
  30584. * @param y Second float in float2.
  30585. * @returns this effect.
  30586. */
  30587. setFloat2(uniformName: string, x: number, y: number): Effect;
  30588. /**
  30589. * Sets a Vector3 on a uniform variable.
  30590. * @param uniformName Name of the variable.
  30591. * @param vector3 Value to be set.
  30592. * @returns this effect.
  30593. */
  30594. setVector3(uniformName: string, vector3: Vector3): Effect;
  30595. /**
  30596. * Sets a float3 on a uniform variable.
  30597. * @param uniformName Name of the variable.
  30598. * @param x First float in float3.
  30599. * @param y Second float in float3.
  30600. * @param z Third float in float3.
  30601. * @returns this effect.
  30602. */
  30603. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30604. /**
  30605. * Sets a Vector4 on a uniform variable.
  30606. * @param uniformName Name of the variable.
  30607. * @param vector4 Value to be set.
  30608. * @returns this effect.
  30609. */
  30610. setVector4(uniformName: string, vector4: Vector4): Effect;
  30611. /**
  30612. * Sets a float4 on a uniform variable.
  30613. * @param uniformName Name of the variable.
  30614. * @param x First float in float4.
  30615. * @param y Second float in float4.
  30616. * @param z Third float in float4.
  30617. * @param w Fourth float in float4.
  30618. * @returns this effect.
  30619. */
  30620. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30621. /**
  30622. * Sets a Color3 on a uniform variable.
  30623. * @param uniformName Name of the variable.
  30624. * @param color3 Value to be set.
  30625. * @returns this effect.
  30626. */
  30627. setColor3(uniformName: string, color3: Color3): Effect;
  30628. /**
  30629. * Sets a Color4 on a uniform variable.
  30630. * @param uniformName Name of the variable.
  30631. * @param color3 Value to be set.
  30632. * @param alpha Alpha value to be set.
  30633. * @returns this effect.
  30634. */
  30635. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30636. /**
  30637. * Sets a Color4 on a uniform variable
  30638. * @param uniformName defines the name of the variable
  30639. * @param color4 defines the value to be set
  30640. * @returns this effect.
  30641. */
  30642. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30643. /** Release all associated resources */
  30644. dispose(): void;
  30645. /**
  30646. * This function will add a new shader to the shader store
  30647. * @param name the name of the shader
  30648. * @param pixelShader optional pixel shader content
  30649. * @param vertexShader optional vertex shader content
  30650. */
  30651. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30652. /**
  30653. * Store of each shader (The can be looked up using effect.key)
  30654. */
  30655. static ShadersStore: {
  30656. [key: string]: string;
  30657. };
  30658. /**
  30659. * Store of each included file for a shader (The can be looked up using effect.key)
  30660. */
  30661. static IncludesShadersStore: {
  30662. [key: string]: string;
  30663. };
  30664. /**
  30665. * Resets the cache of effects.
  30666. */
  30667. static ResetCache(): void;
  30668. }
  30669. }
  30670. declare module "babylonjs/Materials/colorCurves" {
  30671. import { Effect } from "babylonjs/Materials/effect";
  30672. /**
  30673. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30674. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30675. * 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;
  30676. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30677. */
  30678. export class ColorCurves {
  30679. private _dirty;
  30680. private _tempColor;
  30681. private _globalCurve;
  30682. private _highlightsCurve;
  30683. private _midtonesCurve;
  30684. private _shadowsCurve;
  30685. private _positiveCurve;
  30686. private _negativeCurve;
  30687. private _globalHue;
  30688. private _globalDensity;
  30689. private _globalSaturation;
  30690. private _globalExposure;
  30691. /**
  30692. * Gets the global Hue value.
  30693. * 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).
  30694. */
  30695. /**
  30696. * Sets the global Hue value.
  30697. * 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).
  30698. */
  30699. globalHue: number;
  30700. /**
  30701. * Gets the global Density value.
  30702. * 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.
  30703. * Values less than zero provide a filter of opposite hue.
  30704. */
  30705. /**
  30706. * Sets the global Density value.
  30707. * 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.
  30708. * Values less than zero provide a filter of opposite hue.
  30709. */
  30710. globalDensity: number;
  30711. /**
  30712. * Gets the global Saturation value.
  30713. * 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.
  30714. */
  30715. /**
  30716. * Sets the global Saturation value.
  30717. * 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.
  30718. */
  30719. globalSaturation: number;
  30720. /**
  30721. * Gets the global Exposure value.
  30722. * 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.
  30723. */
  30724. /**
  30725. * Sets the global Exposure value.
  30726. * 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.
  30727. */
  30728. globalExposure: number;
  30729. private _highlightsHue;
  30730. private _highlightsDensity;
  30731. private _highlightsSaturation;
  30732. private _highlightsExposure;
  30733. /**
  30734. * Gets the highlights Hue value.
  30735. * 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).
  30736. */
  30737. /**
  30738. * Sets the highlights Hue value.
  30739. * 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).
  30740. */
  30741. highlightsHue: number;
  30742. /**
  30743. * Gets the highlights Density value.
  30744. * 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.
  30745. * Values less than zero provide a filter of opposite hue.
  30746. */
  30747. /**
  30748. * Sets the highlights Density value.
  30749. * 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.
  30750. * Values less than zero provide a filter of opposite hue.
  30751. */
  30752. highlightsDensity: number;
  30753. /**
  30754. * Gets the highlights Saturation value.
  30755. * 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.
  30756. */
  30757. /**
  30758. * Sets the highlights Saturation value.
  30759. * 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.
  30760. */
  30761. highlightsSaturation: number;
  30762. /**
  30763. * Gets the highlights Exposure value.
  30764. * 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.
  30765. */
  30766. /**
  30767. * Sets the highlights Exposure value.
  30768. * 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.
  30769. */
  30770. highlightsExposure: number;
  30771. private _midtonesHue;
  30772. private _midtonesDensity;
  30773. private _midtonesSaturation;
  30774. private _midtonesExposure;
  30775. /**
  30776. * Gets the midtones Hue value.
  30777. * 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).
  30778. */
  30779. /**
  30780. * Sets the midtones Hue value.
  30781. * 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).
  30782. */
  30783. midtonesHue: number;
  30784. /**
  30785. * Gets the midtones Density value.
  30786. * 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.
  30787. * Values less than zero provide a filter of opposite hue.
  30788. */
  30789. /**
  30790. * Sets the midtones Density value.
  30791. * 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.
  30792. * Values less than zero provide a filter of opposite hue.
  30793. */
  30794. midtonesDensity: number;
  30795. /**
  30796. * Gets the midtones Saturation value.
  30797. * 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.
  30798. */
  30799. /**
  30800. * Sets the midtones Saturation value.
  30801. * 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.
  30802. */
  30803. midtonesSaturation: number;
  30804. /**
  30805. * Gets the midtones Exposure value.
  30806. * 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.
  30807. */
  30808. /**
  30809. * Sets the midtones Exposure value.
  30810. * 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.
  30811. */
  30812. midtonesExposure: number;
  30813. private _shadowsHue;
  30814. private _shadowsDensity;
  30815. private _shadowsSaturation;
  30816. private _shadowsExposure;
  30817. /**
  30818. * Gets the shadows Hue value.
  30819. * 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).
  30820. */
  30821. /**
  30822. * Sets the shadows Hue value.
  30823. * 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).
  30824. */
  30825. shadowsHue: number;
  30826. /**
  30827. * Gets the shadows Density value.
  30828. * 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.
  30829. * Values less than zero provide a filter of opposite hue.
  30830. */
  30831. /**
  30832. * Sets the shadows Density value.
  30833. * 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.
  30834. * Values less than zero provide a filter of opposite hue.
  30835. */
  30836. shadowsDensity: number;
  30837. /**
  30838. * Gets the shadows Saturation value.
  30839. * 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.
  30840. */
  30841. /**
  30842. * Sets the shadows Saturation value.
  30843. * 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.
  30844. */
  30845. shadowsSaturation: number;
  30846. /**
  30847. * Gets the shadows Exposure value.
  30848. * 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.
  30849. */
  30850. /**
  30851. * Sets the shadows Exposure value.
  30852. * 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.
  30853. */
  30854. shadowsExposure: number;
  30855. /**
  30856. * Returns the class name
  30857. * @returns The class name
  30858. */
  30859. getClassName(): string;
  30860. /**
  30861. * Binds the color curves to the shader.
  30862. * @param colorCurves The color curve to bind
  30863. * @param effect The effect to bind to
  30864. * @param positiveUniform The positive uniform shader parameter
  30865. * @param neutralUniform The neutral uniform shader parameter
  30866. * @param negativeUniform The negative uniform shader parameter
  30867. */
  30868. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30869. /**
  30870. * Prepare the list of uniforms associated with the ColorCurves effects.
  30871. * @param uniformsList The list of uniforms used in the effect
  30872. */
  30873. static PrepareUniforms(uniformsList: string[]): void;
  30874. /**
  30875. * Returns color grading data based on a hue, density, saturation and exposure value.
  30876. * @param filterHue The hue of the color filter.
  30877. * @param filterDensity The density of the color filter.
  30878. * @param saturation The saturation.
  30879. * @param exposure The exposure.
  30880. * @param result The result data container.
  30881. */
  30882. private getColorGradingDataToRef;
  30883. /**
  30884. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30885. * @param value The input slider value in range [-100,100].
  30886. * @returns Adjusted value.
  30887. */
  30888. private static applyColorGradingSliderNonlinear;
  30889. /**
  30890. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30891. * @param hue The hue (H) input.
  30892. * @param saturation The saturation (S) input.
  30893. * @param brightness The brightness (B) input.
  30894. * @result An RGBA color represented as Vector4.
  30895. */
  30896. private static fromHSBToRef;
  30897. /**
  30898. * Returns a value clamped between min and max
  30899. * @param value The value to clamp
  30900. * @param min The minimum of value
  30901. * @param max The maximum of value
  30902. * @returns The clamped value.
  30903. */
  30904. private static clamp;
  30905. /**
  30906. * Clones the current color curve instance.
  30907. * @return The cloned curves
  30908. */
  30909. clone(): ColorCurves;
  30910. /**
  30911. * Serializes the current color curve instance to a json representation.
  30912. * @return a JSON representation
  30913. */
  30914. serialize(): any;
  30915. /**
  30916. * Parses the color curve from a json representation.
  30917. * @param source the JSON source to parse
  30918. * @return The parsed curves
  30919. */
  30920. static Parse(source: any): ColorCurves;
  30921. }
  30922. }
  30923. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30924. import { Observable } from "babylonjs/Misc/observable";
  30925. import { Nullable } from "babylonjs/types";
  30926. import { Color4 } from "babylonjs/Maths/math";
  30927. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30928. import { Effect } from "babylonjs/Materials/effect";
  30929. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30930. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30931. /**
  30932. * Interface to follow in your material defines to integrate easily the
  30933. * Image proccessing functions.
  30934. * @hidden
  30935. */
  30936. export interface IImageProcessingConfigurationDefines {
  30937. IMAGEPROCESSING: boolean;
  30938. VIGNETTE: boolean;
  30939. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30940. VIGNETTEBLENDMODEOPAQUE: boolean;
  30941. TONEMAPPING: boolean;
  30942. TONEMAPPING_ACES: boolean;
  30943. CONTRAST: boolean;
  30944. EXPOSURE: boolean;
  30945. COLORCURVES: boolean;
  30946. COLORGRADING: boolean;
  30947. COLORGRADING3D: boolean;
  30948. SAMPLER3DGREENDEPTH: boolean;
  30949. SAMPLER3DBGRMAP: boolean;
  30950. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30951. }
  30952. /**
  30953. * @hidden
  30954. */
  30955. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30956. IMAGEPROCESSING: boolean;
  30957. VIGNETTE: boolean;
  30958. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30959. VIGNETTEBLENDMODEOPAQUE: boolean;
  30960. TONEMAPPING: boolean;
  30961. TONEMAPPING_ACES: boolean;
  30962. CONTRAST: boolean;
  30963. COLORCURVES: boolean;
  30964. COLORGRADING: boolean;
  30965. COLORGRADING3D: boolean;
  30966. SAMPLER3DGREENDEPTH: boolean;
  30967. SAMPLER3DBGRMAP: boolean;
  30968. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30969. EXPOSURE: boolean;
  30970. constructor();
  30971. }
  30972. /**
  30973. * This groups together the common properties used for image processing either in direct forward pass
  30974. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30975. * or not.
  30976. */
  30977. export class ImageProcessingConfiguration {
  30978. /**
  30979. * Default tone mapping applied in BabylonJS.
  30980. */
  30981. static readonly TONEMAPPING_STANDARD: number;
  30982. /**
  30983. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30984. * to other engines rendering to increase portability.
  30985. */
  30986. static readonly TONEMAPPING_ACES: number;
  30987. /**
  30988. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30989. */
  30990. colorCurves: Nullable<ColorCurves>;
  30991. private _colorCurvesEnabled;
  30992. /**
  30993. * Gets wether the color curves effect is enabled.
  30994. */
  30995. /**
  30996. * Sets wether the color curves effect is enabled.
  30997. */
  30998. colorCurvesEnabled: boolean;
  30999. private _colorGradingTexture;
  31000. /**
  31001. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  31002. */
  31003. /**
  31004. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  31005. */
  31006. colorGradingTexture: Nullable<BaseTexture>;
  31007. private _colorGradingEnabled;
  31008. /**
  31009. * Gets wether the color grading effect is enabled.
  31010. */
  31011. /**
  31012. * Sets wether the color grading effect is enabled.
  31013. */
  31014. colorGradingEnabled: boolean;
  31015. private _colorGradingWithGreenDepth;
  31016. /**
  31017. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  31018. */
  31019. /**
  31020. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  31021. */
  31022. colorGradingWithGreenDepth: boolean;
  31023. private _colorGradingBGR;
  31024. /**
  31025. * Gets wether the color grading texture contains BGR values.
  31026. */
  31027. /**
  31028. * Sets wether the color grading texture contains BGR values.
  31029. */
  31030. colorGradingBGR: boolean;
  31031. /** @hidden */
  31032. _exposure: number;
  31033. /**
  31034. * Gets the Exposure used in the effect.
  31035. */
  31036. /**
  31037. * Sets the Exposure used in the effect.
  31038. */
  31039. exposure: number;
  31040. private _toneMappingEnabled;
  31041. /**
  31042. * Gets wether the tone mapping effect is enabled.
  31043. */
  31044. /**
  31045. * Sets wether the tone mapping effect is enabled.
  31046. */
  31047. toneMappingEnabled: boolean;
  31048. private _toneMappingType;
  31049. /**
  31050. * Gets the type of tone mapping effect.
  31051. */
  31052. /**
  31053. * Sets the type of tone mapping effect used in BabylonJS.
  31054. */
  31055. toneMappingType: number;
  31056. protected _contrast: number;
  31057. /**
  31058. * Gets the contrast used in the effect.
  31059. */
  31060. /**
  31061. * Sets the contrast used in the effect.
  31062. */
  31063. contrast: number;
  31064. /**
  31065. * Vignette stretch size.
  31066. */
  31067. vignetteStretch: number;
  31068. /**
  31069. * Vignette centre X Offset.
  31070. */
  31071. vignetteCentreX: number;
  31072. /**
  31073. * Vignette centre Y Offset.
  31074. */
  31075. vignetteCentreY: number;
  31076. /**
  31077. * Vignette weight or intensity of the vignette effect.
  31078. */
  31079. vignetteWeight: number;
  31080. /**
  31081. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31082. * if vignetteEnabled is set to true.
  31083. */
  31084. vignetteColor: Color4;
  31085. /**
  31086. * Camera field of view used by the Vignette effect.
  31087. */
  31088. vignetteCameraFov: number;
  31089. private _vignetteBlendMode;
  31090. /**
  31091. * Gets the vignette blend mode allowing different kind of effect.
  31092. */
  31093. /**
  31094. * Sets the vignette blend mode allowing different kind of effect.
  31095. */
  31096. vignetteBlendMode: number;
  31097. private _vignetteEnabled;
  31098. /**
  31099. * Gets wether the vignette effect is enabled.
  31100. */
  31101. /**
  31102. * Sets wether the vignette effect is enabled.
  31103. */
  31104. vignetteEnabled: boolean;
  31105. private _applyByPostProcess;
  31106. /**
  31107. * Gets wether the image processing is applied through a post process or not.
  31108. */
  31109. /**
  31110. * Sets wether the image processing is applied through a post process or not.
  31111. */
  31112. applyByPostProcess: boolean;
  31113. private _isEnabled;
  31114. /**
  31115. * Gets wether the image processing is enabled or not.
  31116. */
  31117. /**
  31118. * Sets wether the image processing is enabled or not.
  31119. */
  31120. isEnabled: boolean;
  31121. /**
  31122. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31123. */
  31124. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31125. /**
  31126. * Method called each time the image processing information changes requires to recompile the effect.
  31127. */
  31128. protected _updateParameters(): void;
  31129. /**
  31130. * Gets the current class name.
  31131. * @return "ImageProcessingConfiguration"
  31132. */
  31133. getClassName(): string;
  31134. /**
  31135. * Prepare the list of uniforms associated with the Image Processing effects.
  31136. * @param uniforms The list of uniforms used in the effect
  31137. * @param defines the list of defines currently in use
  31138. */
  31139. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31140. /**
  31141. * Prepare the list of samplers associated with the Image Processing effects.
  31142. * @param samplersList The list of uniforms used in the effect
  31143. * @param defines the list of defines currently in use
  31144. */
  31145. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31146. /**
  31147. * Prepare the list of defines associated to the shader.
  31148. * @param defines the list of defines to complete
  31149. * @param forPostProcess Define if we are currently in post process mode or not
  31150. */
  31151. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31152. /**
  31153. * Returns true if all the image processing information are ready.
  31154. * @returns True if ready, otherwise, false
  31155. */
  31156. isReady(): boolean;
  31157. /**
  31158. * Binds the image processing to the shader.
  31159. * @param effect The effect to bind to
  31160. * @param aspectRatio Define the current aspect ratio of the effect
  31161. */
  31162. bind(effect: Effect, aspectRatio?: number): void;
  31163. /**
  31164. * Clones the current image processing instance.
  31165. * @return The cloned image processing
  31166. */
  31167. clone(): ImageProcessingConfiguration;
  31168. /**
  31169. * Serializes the current image processing instance to a json representation.
  31170. * @return a JSON representation
  31171. */
  31172. serialize(): any;
  31173. /**
  31174. * Parses the image processing from a json representation.
  31175. * @param source the JSON source to parse
  31176. * @return The parsed image processing
  31177. */
  31178. static Parse(source: any): ImageProcessingConfiguration;
  31179. private static _VIGNETTEMODE_MULTIPLY;
  31180. private static _VIGNETTEMODE_OPAQUE;
  31181. /**
  31182. * Used to apply the vignette as a mix with the pixel color.
  31183. */
  31184. static readonly VIGNETTEMODE_MULTIPLY: number;
  31185. /**
  31186. * Used to apply the vignette as a replacement of the pixel color.
  31187. */
  31188. static readonly VIGNETTEMODE_OPAQUE: number;
  31189. }
  31190. }
  31191. declare module "babylonjs/Materials/fresnelParameters" {
  31192. import { Color3 } from "babylonjs/Maths/math";
  31193. /**
  31194. * This represents all the required information to add a fresnel effect on a material:
  31195. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31196. */
  31197. export class FresnelParameters {
  31198. private _isEnabled;
  31199. /**
  31200. * Define if the fresnel effect is enable or not.
  31201. */
  31202. isEnabled: boolean;
  31203. /**
  31204. * Define the color used on edges (grazing angle)
  31205. */
  31206. leftColor: Color3;
  31207. /**
  31208. * Define the color used on center
  31209. */
  31210. rightColor: Color3;
  31211. /**
  31212. * Define bias applied to computed fresnel term
  31213. */
  31214. bias: number;
  31215. /**
  31216. * Defined the power exponent applied to fresnel term
  31217. */
  31218. power: number;
  31219. /**
  31220. * Clones the current fresnel and its valuues
  31221. * @returns a clone fresnel configuration
  31222. */
  31223. clone(): FresnelParameters;
  31224. /**
  31225. * Serializes the current fresnel parameters to a JSON representation.
  31226. * @return the JSON serialization
  31227. */
  31228. serialize(): any;
  31229. /**
  31230. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31231. * @param parsedFresnelParameters Define the JSON representation
  31232. * @returns the parsed parameters
  31233. */
  31234. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31235. }
  31236. }
  31237. declare module "babylonjs/Misc/decorators" {
  31238. import { Nullable } from "babylonjs/types";
  31239. import { Scene } from "babylonjs/scene";
  31240. import { IAnimatable } from "babylonjs/Misc/tools";
  31241. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31242. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31243. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31244. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31245. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31246. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31247. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31248. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31249. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31250. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31251. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31252. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31253. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31254. /**
  31255. * Decorator used to define property that can be serialized as reference to a camera
  31256. * @param sourceName defines the name of the property to decorate
  31257. */
  31258. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31259. /**
  31260. * Class used to help serialization objects
  31261. */
  31262. export class SerializationHelper {
  31263. /** @hidden */
  31264. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31265. /** @hidden */
  31266. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31267. /** @hidden */
  31268. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31269. /** @hidden */
  31270. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31271. /**
  31272. * Appends the serialized animations from the source animations
  31273. * @param source Source containing the animations
  31274. * @param destination Target to store the animations
  31275. */
  31276. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31277. /**
  31278. * Static function used to serialized a specific entity
  31279. * @param entity defines the entity to serialize
  31280. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31281. * @returns a JSON compatible object representing the serialization of the entity
  31282. */
  31283. static Serialize<T>(entity: T, serializationObject?: any): any;
  31284. /**
  31285. * Creates a new entity from a serialization data object
  31286. * @param creationFunction defines a function used to instanciated the new entity
  31287. * @param source defines the source serialization data
  31288. * @param scene defines the hosting scene
  31289. * @param rootUrl defines the root url for resources
  31290. * @returns a new entity
  31291. */
  31292. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31293. /**
  31294. * Clones an object
  31295. * @param creationFunction defines the function used to instanciate the new object
  31296. * @param source defines the source object
  31297. * @returns the cloned object
  31298. */
  31299. static Clone<T>(creationFunction: () => T, source: T): T;
  31300. /**
  31301. * Instanciates a new object based on a source one (some data will be shared between both object)
  31302. * @param creationFunction defines the function used to instanciate the new object
  31303. * @param source defines the source object
  31304. * @returns the new object
  31305. */
  31306. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31307. }
  31308. }
  31309. declare module "babylonjs/Cameras/camera" {
  31310. import { SmartArray } from "babylonjs/Misc/smartArray";
  31311. import { Observable } from "babylonjs/Misc/observable";
  31312. import { Nullable } from "babylonjs/types";
  31313. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31314. import { Scene } from "babylonjs/scene";
  31315. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31316. import { Node } from "babylonjs/node";
  31317. import { Mesh } from "babylonjs/Meshes/mesh";
  31318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31319. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31320. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31321. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31322. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31323. import { Ray } from "babylonjs/Culling/ray";
  31324. /**
  31325. * This is the base class of all the camera used in the application.
  31326. * @see http://doc.babylonjs.com/features/cameras
  31327. */
  31328. export class Camera extends Node {
  31329. /** @hidden */
  31330. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31331. /**
  31332. * This is the default projection mode used by the cameras.
  31333. * It helps recreating a feeling of perspective and better appreciate depth.
  31334. * This is the best way to simulate real life cameras.
  31335. */
  31336. static readonly PERSPECTIVE_CAMERA: number;
  31337. /**
  31338. * This helps creating camera with an orthographic mode.
  31339. * 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.
  31340. */
  31341. static readonly ORTHOGRAPHIC_CAMERA: number;
  31342. /**
  31343. * This is the default FOV mode for perspective cameras.
  31344. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31345. */
  31346. static readonly FOVMODE_VERTICAL_FIXED: number;
  31347. /**
  31348. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31349. */
  31350. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31351. /**
  31352. * This specifies ther is no need for a camera rig.
  31353. * Basically only one eye is rendered corresponding to the camera.
  31354. */
  31355. static readonly RIG_MODE_NONE: number;
  31356. /**
  31357. * Simulates a camera Rig with one blue eye and one red eye.
  31358. * This can be use with 3d blue and red glasses.
  31359. */
  31360. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31361. /**
  31362. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31363. */
  31364. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31365. /**
  31366. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31367. */
  31368. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31369. /**
  31370. * Defines that both eyes of the camera will be rendered over under each other.
  31371. */
  31372. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31373. /**
  31374. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31375. */
  31376. static readonly RIG_MODE_VR: number;
  31377. /**
  31378. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31379. */
  31380. static readonly RIG_MODE_WEBVR: number;
  31381. /**
  31382. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31383. */
  31384. static readonly RIG_MODE_CUSTOM: number;
  31385. /**
  31386. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31387. */
  31388. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31389. /**
  31390. * Define the input manager associated with the camera.
  31391. */
  31392. inputs: CameraInputsManager<Camera>;
  31393. /** @hidden */
  31394. _position: Vector3;
  31395. /**
  31396. * Define the current local position of the camera in the scene
  31397. */
  31398. position: Vector3;
  31399. /**
  31400. * The vector the camera should consider as up.
  31401. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31402. */
  31403. upVector: Vector3;
  31404. /**
  31405. * Define the current limit on the left side for an orthographic camera
  31406. * In scene unit
  31407. */
  31408. orthoLeft: Nullable<number>;
  31409. /**
  31410. * Define the current limit on the right side for an orthographic camera
  31411. * In scene unit
  31412. */
  31413. orthoRight: Nullable<number>;
  31414. /**
  31415. * Define the current limit on the bottom side for an orthographic camera
  31416. * In scene unit
  31417. */
  31418. orthoBottom: Nullable<number>;
  31419. /**
  31420. * Define the current limit on the top side for an orthographic camera
  31421. * In scene unit
  31422. */
  31423. orthoTop: Nullable<number>;
  31424. /**
  31425. * Field Of View is set in Radians. (default is 0.8)
  31426. */
  31427. fov: number;
  31428. /**
  31429. * Define the minimum distance the camera can see from.
  31430. * This is important to note that the depth buffer are not infinite and the closer it starts
  31431. * the more your scene might encounter depth fighting issue.
  31432. */
  31433. minZ: number;
  31434. /**
  31435. * Define the maximum distance the camera can see to.
  31436. * This is important to note that the depth buffer are not infinite and the further it end
  31437. * the more your scene might encounter depth fighting issue.
  31438. */
  31439. maxZ: number;
  31440. /**
  31441. * Define the default inertia of the camera.
  31442. * This helps giving a smooth feeling to the camera movement.
  31443. */
  31444. inertia: number;
  31445. /**
  31446. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  31447. */
  31448. mode: number;
  31449. /**
  31450. * Define wether the camera is intermediate.
  31451. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31452. */
  31453. isIntermediate: boolean;
  31454. /**
  31455. * Define the viewport of the camera.
  31456. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31457. */
  31458. viewport: Viewport;
  31459. /**
  31460. * Restricts the camera to viewing objects with the same layerMask.
  31461. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31462. */
  31463. layerMask: number;
  31464. /**
  31465. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31466. */
  31467. fovMode: number;
  31468. /**
  31469. * Rig mode of the camera.
  31470. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31471. * This is normally controlled byt the camera themselves as internal use.
  31472. */
  31473. cameraRigMode: number;
  31474. /**
  31475. * Defines the distance between both "eyes" in case of a RIG
  31476. */
  31477. interaxialDistance: number;
  31478. /**
  31479. * Defines if stereoscopic rendering is done side by side or over under.
  31480. */
  31481. isStereoscopicSideBySide: boolean;
  31482. /**
  31483. * 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
  31484. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31485. * else in the scene.
  31486. */
  31487. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31488. /**
  31489. * When set, the camera will render to this render target instead of the default canvas
  31490. */
  31491. outputRenderTarget: Nullable<RenderTargetTexture>;
  31492. /**
  31493. * Observable triggered when the camera view matrix has changed.
  31494. */
  31495. onViewMatrixChangedObservable: Observable<Camera>;
  31496. /**
  31497. * Observable triggered when the camera Projection matrix has changed.
  31498. */
  31499. onProjectionMatrixChangedObservable: Observable<Camera>;
  31500. /**
  31501. * Observable triggered when the inputs have been processed.
  31502. */
  31503. onAfterCheckInputsObservable: Observable<Camera>;
  31504. /**
  31505. * Observable triggered when reset has been called and applied to the camera.
  31506. */
  31507. onRestoreStateObservable: Observable<Camera>;
  31508. /** @hidden */
  31509. _cameraRigParams: any;
  31510. /** @hidden */
  31511. _rigCameras: Camera[];
  31512. /** @hidden */
  31513. _rigPostProcess: Nullable<PostProcess>;
  31514. protected _webvrViewMatrix: Matrix;
  31515. /** @hidden */
  31516. _skipRendering: boolean;
  31517. /** @hidden */
  31518. _projectionMatrix: Matrix;
  31519. /** @hidden */
  31520. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31521. /** @hidden */
  31522. _activeMeshes: SmartArray<AbstractMesh>;
  31523. protected _globalPosition: Vector3;
  31524. /** @hidden */
  31525. _computedViewMatrix: Matrix;
  31526. private _doNotComputeProjectionMatrix;
  31527. private _transformMatrix;
  31528. private _frustumPlanes;
  31529. private _refreshFrustumPlanes;
  31530. private _storedFov;
  31531. private _stateStored;
  31532. /**
  31533. * Instantiates a new camera object.
  31534. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31535. * @see http://doc.babylonjs.com/features/cameras
  31536. * @param name Defines the name of the camera in the scene
  31537. * @param position Defines the position of the camera
  31538. * @param scene Defines the scene the camera belongs too
  31539. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31540. */
  31541. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31542. /**
  31543. * Store current camera state (fov, position, etc..)
  31544. * @returns the camera
  31545. */
  31546. storeState(): Camera;
  31547. /**
  31548. * Restores the camera state values if it has been stored. You must call storeState() first
  31549. */
  31550. protected _restoreStateValues(): boolean;
  31551. /**
  31552. * Restored camera state. You must call storeState() first.
  31553. * @returns true if restored and false otherwise
  31554. */
  31555. restoreState(): boolean;
  31556. /**
  31557. * Gets the class name of the camera.
  31558. * @returns the class name
  31559. */
  31560. getClassName(): string;
  31561. /** @hidden */
  31562. readonly _isCamera: boolean;
  31563. /**
  31564. * Gets a string representation of the camera useful for debug purpose.
  31565. * @param fullDetails Defines that a more verboe level of logging is required
  31566. * @returns the string representation
  31567. */
  31568. toString(fullDetails?: boolean): string;
  31569. /**
  31570. * Gets the current world space position of the camera.
  31571. */
  31572. readonly globalPosition: Vector3;
  31573. /**
  31574. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31575. * @returns the active meshe list
  31576. */
  31577. getActiveMeshes(): SmartArray<AbstractMesh>;
  31578. /**
  31579. * Check wether a mesh is part of the current active mesh list of the camera
  31580. * @param mesh Defines the mesh to check
  31581. * @returns true if active, false otherwise
  31582. */
  31583. isActiveMesh(mesh: Mesh): boolean;
  31584. /**
  31585. * Is this camera ready to be used/rendered
  31586. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31587. * @return true if the camera is ready
  31588. */
  31589. isReady(completeCheck?: boolean): boolean;
  31590. /** @hidden */
  31591. _initCache(): void;
  31592. /** @hidden */
  31593. _updateCache(ignoreParentClass?: boolean): void;
  31594. /** @hidden */
  31595. _isSynchronized(): boolean;
  31596. /** @hidden */
  31597. _isSynchronizedViewMatrix(): boolean;
  31598. /** @hidden */
  31599. _isSynchronizedProjectionMatrix(): boolean;
  31600. /**
  31601. * Attach the input controls to a specific dom element to get the input from.
  31602. * @param element Defines the element the controls should be listened from
  31603. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31604. */
  31605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31606. /**
  31607. * Detach the current controls from the specified dom element.
  31608. * @param element Defines the element to stop listening the inputs from
  31609. */
  31610. detachControl(element: HTMLElement): void;
  31611. /**
  31612. * Update the camera state according to the different inputs gathered during the frame.
  31613. */
  31614. update(): void;
  31615. /** @hidden */
  31616. _checkInputs(): void;
  31617. /** @hidden */
  31618. readonly rigCameras: Camera[];
  31619. /**
  31620. * Gets the post process used by the rig cameras
  31621. */
  31622. readonly rigPostProcess: Nullable<PostProcess>;
  31623. /**
  31624. * Internal, gets the first post proces.
  31625. * @returns the first post process to be run on this camera.
  31626. */
  31627. _getFirstPostProcess(): Nullable<PostProcess>;
  31628. private _cascadePostProcessesToRigCams;
  31629. /**
  31630. * Attach a post process to the camera.
  31631. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31632. * @param postProcess The post process to attach to the camera
  31633. * @param insertAt The position of the post process in case several of them are in use in the scene
  31634. * @returns the position the post process has been inserted at
  31635. */
  31636. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31637. /**
  31638. * Detach a post process to the camera.
  31639. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31640. * @param postProcess The post process to detach from the camera
  31641. */
  31642. detachPostProcess(postProcess: PostProcess): void;
  31643. /**
  31644. * Gets the current world matrix of the camera
  31645. */
  31646. getWorldMatrix(): Matrix;
  31647. /** @hidden */
  31648. _getViewMatrix(): Matrix;
  31649. /**
  31650. * Gets the current view matrix of the camera.
  31651. * @param force forces the camera to recompute the matrix without looking at the cached state
  31652. * @returns the view matrix
  31653. */
  31654. getViewMatrix(force?: boolean): Matrix;
  31655. /**
  31656. * Freeze the projection matrix.
  31657. * It will prevent the cache check of the camera projection compute and can speed up perf
  31658. * if no parameter of the camera are meant to change
  31659. * @param projection Defines manually a projection if necessary
  31660. */
  31661. freezeProjectionMatrix(projection?: Matrix): void;
  31662. /**
  31663. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31664. */
  31665. unfreezeProjectionMatrix(): void;
  31666. /**
  31667. * Gets the current projection matrix of the camera.
  31668. * @param force forces the camera to recompute the matrix without looking at the cached state
  31669. * @returns the projection matrix
  31670. */
  31671. getProjectionMatrix(force?: boolean): Matrix;
  31672. /**
  31673. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31674. * @returns a Matrix
  31675. */
  31676. getTransformationMatrix(): Matrix;
  31677. private _updateFrustumPlanes;
  31678. /**
  31679. * Checks if a cullable object (mesh...) is in the camera frustum
  31680. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31681. * @param target The object to check
  31682. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31683. * @returns true if the object is in frustum otherwise false
  31684. */
  31685. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31686. /**
  31687. * Checks if a cullable object (mesh...) is in the camera frustum
  31688. * Unlike isInFrustum this cheks the full bounding box
  31689. * @param target The object to check
  31690. * @returns true if the object is in frustum otherwise false
  31691. */
  31692. isCompletelyInFrustum(target: ICullable): boolean;
  31693. /**
  31694. * Gets a ray in the forward direction from the camera.
  31695. * @param length Defines the length of the ray to create
  31696. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31697. * @param origin Defines the start point of the ray which defaults to the camera position
  31698. * @returns the forward ray
  31699. */
  31700. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31701. /**
  31702. * Releases resources associated with this node.
  31703. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31704. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31705. */
  31706. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31707. /** @hidden */
  31708. _isLeftCamera: boolean;
  31709. /**
  31710. * Gets the left camera of a rig setup in case of Rigged Camera
  31711. */
  31712. readonly isLeftCamera: boolean;
  31713. /** @hidden */
  31714. _isRightCamera: boolean;
  31715. /**
  31716. * Gets the right camera of a rig setup in case of Rigged Camera
  31717. */
  31718. readonly isRightCamera: boolean;
  31719. /**
  31720. * Gets the left camera of a rig setup in case of Rigged Camera
  31721. */
  31722. readonly leftCamera: Nullable<FreeCamera>;
  31723. /**
  31724. * Gets the right camera of a rig setup in case of Rigged Camera
  31725. */
  31726. readonly rightCamera: Nullable<FreeCamera>;
  31727. /**
  31728. * Gets the left camera target of a rig setup in case of Rigged Camera
  31729. * @returns the target position
  31730. */
  31731. getLeftTarget(): Nullable<Vector3>;
  31732. /**
  31733. * Gets the right camera target of a rig setup in case of Rigged Camera
  31734. * @returns the target position
  31735. */
  31736. getRightTarget(): Nullable<Vector3>;
  31737. /**
  31738. * @hidden
  31739. */
  31740. setCameraRigMode(mode: number, rigParams: any): void;
  31741. /** @hidden */
  31742. static _setStereoscopicRigMode(camera: Camera): void;
  31743. /** @hidden */
  31744. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31745. /** @hidden */
  31746. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31747. /** @hidden */
  31748. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31749. /** @hidden */
  31750. _getVRProjectionMatrix(): Matrix;
  31751. protected _updateCameraRotationMatrix(): void;
  31752. protected _updateWebVRCameraRotationMatrix(): void;
  31753. /**
  31754. * This function MUST be overwritten by the different WebVR cameras available.
  31755. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31756. * @hidden
  31757. */
  31758. _getWebVRProjectionMatrix(): Matrix;
  31759. /**
  31760. * This function MUST be overwritten by the different WebVR cameras available.
  31761. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31762. * @hidden
  31763. */
  31764. _getWebVRViewMatrix(): Matrix;
  31765. /** @hidden */
  31766. setCameraRigParameter(name: string, value: any): void;
  31767. /**
  31768. * needs to be overridden by children so sub has required properties to be copied
  31769. * @hidden
  31770. */
  31771. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31772. /**
  31773. * May need to be overridden by children
  31774. * @hidden
  31775. */
  31776. _updateRigCameras(): void;
  31777. /** @hidden */
  31778. _setupInputs(): void;
  31779. /**
  31780. * Serialiaze the camera setup to a json represention
  31781. * @returns the JSON representation
  31782. */
  31783. serialize(): any;
  31784. /**
  31785. * Clones the current camera.
  31786. * @param name The cloned camera name
  31787. * @returns the cloned camera
  31788. */
  31789. clone(name: string): Camera;
  31790. /**
  31791. * Gets the direction of the camera relative to a given local axis.
  31792. * @param localAxis Defines the reference axis to provide a relative direction.
  31793. * @return the direction
  31794. */
  31795. getDirection(localAxis: Vector3): Vector3;
  31796. /**
  31797. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31798. * @param localAxis Defines the reference axis to provide a relative direction.
  31799. * @param result Defines the vector to store the result in
  31800. */
  31801. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31802. /**
  31803. * Gets a camera constructor for a given camera type
  31804. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31805. * @param name The name of the camera the result will be able to instantiate
  31806. * @param scene The scene the result will construct the camera in
  31807. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31808. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31809. * @returns a factory method to construc the camera
  31810. */
  31811. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31812. /**
  31813. * Compute the world matrix of the camera.
  31814. * @returns the camera workd matrix
  31815. */
  31816. computeWorldMatrix(): Matrix;
  31817. /**
  31818. * Parse a JSON and creates the camera from the parsed information
  31819. * @param parsedCamera The JSON to parse
  31820. * @param scene The scene to instantiate the camera in
  31821. * @returns the newly constructed camera
  31822. */
  31823. static Parse(parsedCamera: any, scene: Scene): Camera;
  31824. }
  31825. }
  31826. declare module "babylonjs/Misc/tools" {
  31827. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31828. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31829. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31830. import { Observable } from "babylonjs/Misc/observable";
  31831. import { DomManagement } from "babylonjs/Misc/domManagement";
  31832. import { WebRequest } from "babylonjs/Misc/webRequest";
  31833. import { Camera } from "babylonjs/Cameras/camera";
  31834. import { Engine } from "babylonjs/Engines/engine";
  31835. import { Animation } from "babylonjs/Animations/animation";
  31836. /**
  31837. * Interface for any object that can request an animation frame
  31838. */
  31839. export interface ICustomAnimationFrameRequester {
  31840. /**
  31841. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31842. */
  31843. renderFunction?: Function;
  31844. /**
  31845. * Called to request the next frame to render to
  31846. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31847. */
  31848. requestAnimationFrame: Function;
  31849. /**
  31850. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31851. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31852. */
  31853. requestID?: number;
  31854. }
  31855. /**
  31856. * Interface containing an array of animations
  31857. */
  31858. export interface IAnimatable {
  31859. /**
  31860. * Array of animations
  31861. */
  31862. animations: Nullable<Array<Animation>>;
  31863. }
  31864. /** Interface used by value gradients (color, factor, ...) */
  31865. export interface IValueGradient {
  31866. /**
  31867. * Gets or sets the gradient value (between 0 and 1)
  31868. */
  31869. gradient: number;
  31870. }
  31871. /** Class used to store color4 gradient */
  31872. export class ColorGradient implements IValueGradient {
  31873. /**
  31874. * Gets or sets the gradient value (between 0 and 1)
  31875. */
  31876. gradient: number;
  31877. /**
  31878. * Gets or sets first associated color
  31879. */
  31880. color1: Color4;
  31881. /**
  31882. * Gets or sets second associated color
  31883. */
  31884. color2?: Color4;
  31885. /**
  31886. * Will get a color picked randomly between color1 and color2.
  31887. * If color2 is undefined then color1 will be used
  31888. * @param result defines the target Color4 to store the result in
  31889. */
  31890. getColorToRef(result: Color4): void;
  31891. }
  31892. /** Class used to store color 3 gradient */
  31893. export class Color3Gradient implements IValueGradient {
  31894. /**
  31895. * Gets or sets the gradient value (between 0 and 1)
  31896. */
  31897. gradient: number;
  31898. /**
  31899. * Gets or sets the associated color
  31900. */
  31901. color: Color3;
  31902. }
  31903. /** Class used to store factor gradient */
  31904. export class FactorGradient implements IValueGradient {
  31905. /**
  31906. * Gets or sets the gradient value (between 0 and 1)
  31907. */
  31908. gradient: number;
  31909. /**
  31910. * Gets or sets first associated factor
  31911. */
  31912. factor1: number;
  31913. /**
  31914. * Gets or sets second associated factor
  31915. */
  31916. factor2?: number;
  31917. /**
  31918. * Will get a number picked randomly between factor1 and factor2.
  31919. * If factor2 is undefined then factor1 will be used
  31920. * @returns the picked number
  31921. */
  31922. getFactor(): number;
  31923. }
  31924. /**
  31925. * @ignore
  31926. * Application error to support additional information when loading a file
  31927. */
  31928. export class LoadFileError extends Error {
  31929. /** defines the optional web request */
  31930. request?: WebRequest | undefined;
  31931. private static _setPrototypeOf;
  31932. /**
  31933. * Creates a new LoadFileError
  31934. * @param message defines the message of the error
  31935. * @param request defines the optional web request
  31936. */
  31937. constructor(message: string,
  31938. /** defines the optional web request */
  31939. request?: WebRequest | undefined);
  31940. }
  31941. /**
  31942. * Class used to define a retry strategy when error happens while loading assets
  31943. */
  31944. export class RetryStrategy {
  31945. /**
  31946. * Function used to defines an exponential back off strategy
  31947. * @param maxRetries defines the maximum number of retries (3 by default)
  31948. * @param baseInterval defines the interval between retries
  31949. * @returns the strategy function to use
  31950. */
  31951. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31952. }
  31953. /**
  31954. * File request interface
  31955. */
  31956. export interface IFileRequest {
  31957. /**
  31958. * Raised when the request is complete (success or error).
  31959. */
  31960. onCompleteObservable: Observable<IFileRequest>;
  31961. /**
  31962. * Aborts the request for a file.
  31963. */
  31964. abort: () => void;
  31965. }
  31966. /**
  31967. * Class containing a set of static utilities functions
  31968. */
  31969. export class Tools {
  31970. /**
  31971. * Gets or sets the base URL to use to load assets
  31972. */
  31973. static BaseUrl: string;
  31974. /**
  31975. * Enable/Disable Custom HTTP Request Headers globally.
  31976. * default = false
  31977. * @see CustomRequestHeaders
  31978. */
  31979. static UseCustomRequestHeaders: boolean;
  31980. /**
  31981. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31982. * i.e. when loading files, where the server/service expects an Authorization header
  31983. */
  31984. static CustomRequestHeaders: {
  31985. [key: string]: string;
  31986. };
  31987. /**
  31988. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31989. */
  31990. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31991. /**
  31992. * Default behaviour for cors in the application.
  31993. * It can be a string if the expected behavior is identical in the entire app.
  31994. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31995. */
  31996. static CorsBehavior: string | ((url: string | string[]) => string);
  31997. /**
  31998. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31999. * @ignorenaming
  32000. */
  32001. static UseFallbackTexture: boolean;
  32002. /**
  32003. * Use this object to register external classes like custom textures or material
  32004. * to allow the laoders to instantiate them
  32005. */
  32006. static RegisteredExternalClasses: {
  32007. [key: string]: Object;
  32008. };
  32009. /**
  32010. * Texture content used if a texture cannot loaded
  32011. * @ignorenaming
  32012. */
  32013. static fallbackTexture: string;
  32014. /**
  32015. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32016. * @param u defines the coordinate on X axis
  32017. * @param v defines the coordinate on Y axis
  32018. * @param width defines the width of the source data
  32019. * @param height defines the height of the source data
  32020. * @param pixels defines the source byte array
  32021. * @param color defines the output color
  32022. */
  32023. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  32024. /**
  32025. * Interpolates between a and b via alpha
  32026. * @param a The lower value (returned when alpha = 0)
  32027. * @param b The upper value (returned when alpha = 1)
  32028. * @param alpha The interpolation-factor
  32029. * @return The mixed value
  32030. */
  32031. static Mix(a: number, b: number, alpha: number): number;
  32032. /**
  32033. * Tries to instantiate a new object from a given class name
  32034. * @param className defines the class name to instantiate
  32035. * @returns the new object or null if the system was not able to do the instantiation
  32036. */
  32037. static Instantiate(className: string): any;
  32038. /**
  32039. * Provides a slice function that will work even on IE
  32040. * @param data defines the array to slice
  32041. * @param start defines the start of the data (optional)
  32042. * @param end defines the end of the data (optional)
  32043. * @returns the new sliced array
  32044. */
  32045. static Slice<T>(data: T, start?: number, end?: number): T;
  32046. /**
  32047. * Polyfill for setImmediate
  32048. * @param action defines the action to execute after the current execution block
  32049. */
  32050. static SetImmediate(action: () => void): void;
  32051. /**
  32052. * Function indicating if a number is an exponent of 2
  32053. * @param value defines the value to test
  32054. * @returns true if the value is an exponent of 2
  32055. */
  32056. static IsExponentOfTwo(value: number): boolean;
  32057. private static _tmpFloatArray;
  32058. /**
  32059. * Returns the nearest 32-bit single precision float representation of a Number
  32060. * @param value A Number. If the parameter is of a different type, it will get converted
  32061. * to a number or to NaN if it cannot be converted
  32062. * @returns number
  32063. */
  32064. static FloatRound(value: number): number;
  32065. /**
  32066. * Find the next highest power of two.
  32067. * @param x Number to start search from.
  32068. * @return Next highest power of two.
  32069. */
  32070. static CeilingPOT(x: number): number;
  32071. /**
  32072. * Find the next lowest power of two.
  32073. * @param x Number to start search from.
  32074. * @return Next lowest power of two.
  32075. */
  32076. static FloorPOT(x: number): number;
  32077. /**
  32078. * Find the nearest power of two.
  32079. * @param x Number to start search from.
  32080. * @return Next nearest power of two.
  32081. */
  32082. static NearestPOT(x: number): number;
  32083. /**
  32084. * Get the closest exponent of two
  32085. * @param value defines the value to approximate
  32086. * @param max defines the maximum value to return
  32087. * @param mode defines how to define the closest value
  32088. * @returns closest exponent of two of the given value
  32089. */
  32090. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32091. /**
  32092. * Extracts the filename from a path
  32093. * @param path defines the path to use
  32094. * @returns the filename
  32095. */
  32096. static GetFilename(path: string): string;
  32097. /**
  32098. * Extracts the "folder" part of a path (everything before the filename).
  32099. * @param uri The URI to extract the info from
  32100. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32101. * @returns The "folder" part of the path
  32102. */
  32103. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32104. /**
  32105. * Extracts text content from a DOM element hierarchy
  32106. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32107. */
  32108. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32109. /**
  32110. * Convert an angle in radians to degrees
  32111. * @param angle defines the angle to convert
  32112. * @returns the angle in degrees
  32113. */
  32114. static ToDegrees(angle: number): number;
  32115. /**
  32116. * Convert an angle in degrees to radians
  32117. * @param angle defines the angle to convert
  32118. * @returns the angle in radians
  32119. */
  32120. static ToRadians(angle: number): number;
  32121. /**
  32122. * Encode a buffer to a base64 string
  32123. * @param buffer defines the buffer to encode
  32124. * @returns the encoded string
  32125. */
  32126. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32127. /**
  32128. * Extracts minimum and maximum values from a list of indexed positions
  32129. * @param positions defines the positions to use
  32130. * @param indices defines the indices to the positions
  32131. * @param indexStart defines the start index
  32132. * @param indexCount defines the end index
  32133. * @param bias defines bias value to add to the result
  32134. * @return minimum and maximum values
  32135. */
  32136. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32137. minimum: Vector3;
  32138. maximum: Vector3;
  32139. };
  32140. /**
  32141. * Extracts minimum and maximum values from a list of positions
  32142. * @param positions defines the positions to use
  32143. * @param start defines the start index in the positions array
  32144. * @param count defines the number of positions to handle
  32145. * @param bias defines bias value to add to the result
  32146. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32147. * @return minimum and maximum values
  32148. */
  32149. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32150. minimum: Vector3;
  32151. maximum: Vector3;
  32152. };
  32153. /**
  32154. * Returns an array if obj is not an array
  32155. * @param obj defines the object to evaluate as an array
  32156. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32157. * @returns either obj directly if obj is an array or a new array containing obj
  32158. */
  32159. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32160. /**
  32161. * Gets the pointer prefix to use
  32162. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32163. */
  32164. static GetPointerPrefix(): string;
  32165. /**
  32166. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32167. * @param func - the function to be called
  32168. * @param requester - the object that will request the next frame. Falls back to window.
  32169. * @returns frame number
  32170. */
  32171. static QueueNewFrame(func: () => void, requester?: any): number;
  32172. /**
  32173. * Ask the browser to promote the current element to fullscreen rendering mode
  32174. * @param element defines the DOM element to promote
  32175. */
  32176. static RequestFullscreen(element: HTMLElement): void;
  32177. /**
  32178. * Asks the browser to exit fullscreen mode
  32179. */
  32180. static ExitFullscreen(): void;
  32181. /**
  32182. * Ask the browser to promote the current element to pointerlock mode
  32183. * @param element defines the DOM element to promote
  32184. */
  32185. static RequestPointerlock(element: HTMLElement): void;
  32186. /**
  32187. * Asks the browser to exit pointerlock mode
  32188. */
  32189. static ExitPointerlock(): void;
  32190. /**
  32191. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32192. * @param url define the url we are trying
  32193. * @param element define the dom element where to configure the cors policy
  32194. */
  32195. static SetCorsBehavior(url: string | string[], element: {
  32196. crossOrigin: string | null;
  32197. }): void;
  32198. /**
  32199. * Removes unwanted characters from an url
  32200. * @param url defines the url to clean
  32201. * @returns the cleaned url
  32202. */
  32203. static CleanUrl(url: string): string;
  32204. /**
  32205. * Gets or sets a function used to pre-process url before using them to load assets
  32206. */
  32207. static PreprocessUrl: (url: string) => string;
  32208. /**
  32209. * Loads an image as an HTMLImageElement.
  32210. * @param input url string, ArrayBuffer, or Blob to load
  32211. * @param onLoad callback called when the image successfully loads
  32212. * @param onError callback called when the image fails to load
  32213. * @param offlineProvider offline provider for caching
  32214. * @returns the HTMLImageElement of the loaded image
  32215. */
  32216. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32217. /**
  32218. * Loads a file
  32219. * @param url url string, ArrayBuffer, or Blob to load
  32220. * @param onSuccess callback called when the file successfully loads
  32221. * @param onProgress callback called while file is loading (if the server supports this mode)
  32222. * @param offlineProvider defines the offline provider for caching
  32223. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32224. * @param onError callback called when the file fails to load
  32225. * @returns a file request object
  32226. */
  32227. 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;
  32228. /**
  32229. * Loads a file from a url
  32230. * @param url the file url to load
  32231. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32232. */
  32233. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32234. /**
  32235. * Load a script (identified by an url). When the url returns, the
  32236. * content of this file is added into a new script element, attached to the DOM (body element)
  32237. * @param scriptUrl defines the url of the script to laod
  32238. * @param onSuccess defines the callback called when the script is loaded
  32239. * @param onError defines the callback to call if an error occurs
  32240. * @param scriptId defines the id of the script element
  32241. */
  32242. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32243. /**
  32244. * Load an asynchronous script (identified by an url). When the url returns, the
  32245. * content of this file is added into a new script element, attached to the DOM (body element)
  32246. * @param scriptUrl defines the url of the script to laod
  32247. * @param scriptId defines the id of the script element
  32248. * @returns a promise request object
  32249. */
  32250. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32251. /**
  32252. * Loads a file from a blob
  32253. * @param fileToLoad defines the blob to use
  32254. * @param callback defines the callback to call when data is loaded
  32255. * @param progressCallback defines the callback to call during loading process
  32256. * @returns a file request object
  32257. */
  32258. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32259. /**
  32260. * Loads a file
  32261. * @param fileToLoad defines the file to load
  32262. * @param callback defines the callback to call when data is loaded
  32263. * @param progressCallBack defines the callback to call during loading process
  32264. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32265. * @returns a file request object
  32266. */
  32267. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32268. /**
  32269. * Creates a data url from a given string content
  32270. * @param content defines the content to convert
  32271. * @returns the new data url link
  32272. */
  32273. static FileAsURL(content: string): string;
  32274. /**
  32275. * Format the given number to a specific decimal format
  32276. * @param value defines the number to format
  32277. * @param decimals defines the number of decimals to use
  32278. * @returns the formatted string
  32279. */
  32280. static Format(value: number, decimals?: number): string;
  32281. /**
  32282. * Checks if a given vector is inside a specific range
  32283. * @param v defines the vector to test
  32284. * @param min defines the minimum range
  32285. * @param max defines the maximum range
  32286. */
  32287. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32288. /**
  32289. * Tries to copy an object by duplicating every property
  32290. * @param source defines the source object
  32291. * @param destination defines the target object
  32292. * @param doNotCopyList defines a list of properties to avoid
  32293. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32294. */
  32295. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32296. /**
  32297. * Gets a boolean indicating if the given object has no own property
  32298. * @param obj defines the object to test
  32299. * @returns true if object has no own property
  32300. */
  32301. static IsEmpty(obj: any): boolean;
  32302. /**
  32303. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32304. * @param str Source string
  32305. * @param suffix Suffix to search for in the source string
  32306. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32307. */
  32308. static EndsWith(str: string, suffix: string): boolean;
  32309. /**
  32310. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  32311. * @param str Source string
  32312. * @param suffix Suffix to search for in the source string
  32313. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32314. */
  32315. static StartsWith(str: string, suffix: string): boolean;
  32316. /**
  32317. * Function used to register events at window level
  32318. * @param events defines the events to register
  32319. */
  32320. static RegisterTopRootEvents(events: {
  32321. name: string;
  32322. handler: Nullable<(e: FocusEvent) => any>;
  32323. }[]): void;
  32324. /**
  32325. * Function used to unregister events from window level
  32326. * @param events defines the events to unregister
  32327. */
  32328. static UnregisterTopRootEvents(events: {
  32329. name: string;
  32330. handler: Nullable<(e: FocusEvent) => any>;
  32331. }[]): void;
  32332. /**
  32333. * @ignore
  32334. */
  32335. static _ScreenshotCanvas: HTMLCanvasElement;
  32336. /**
  32337. * Dumps the current bound framebuffer
  32338. * @param width defines the rendering width
  32339. * @param height defines the rendering height
  32340. * @param engine defines the hosting engine
  32341. * @param successCallback defines the callback triggered once the data are available
  32342. * @param mimeType defines the mime type of the result
  32343. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32344. */
  32345. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32346. /**
  32347. * Converts the canvas data to blob.
  32348. * This acts as a polyfill for browsers not supporting the to blob function.
  32349. * @param canvas Defines the canvas to extract the data from
  32350. * @param successCallback Defines the callback triggered once the data are available
  32351. * @param mimeType Defines the mime type of the result
  32352. */
  32353. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32354. /**
  32355. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32356. * @param successCallback defines the callback triggered once the data are available
  32357. * @param mimeType defines the mime type of the result
  32358. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32359. */
  32360. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32361. /**
  32362. * Downloads a blob in the browser
  32363. * @param blob defines the blob to download
  32364. * @param fileName defines the name of the downloaded file
  32365. */
  32366. static Download(blob: Blob, fileName: string): void;
  32367. /**
  32368. * Captures a screenshot of the current rendering
  32369. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32370. * @param engine defines the rendering engine
  32371. * @param camera defines the source camera
  32372. * @param size This parameter can be set to a single number or to an object with the
  32373. * following (optional) properties: precision, width, height. If a single number is passed,
  32374. * it will be used for both width and height. If an object is passed, the screenshot size
  32375. * will be derived from the parameters. The precision property is a multiplier allowing
  32376. * rendering at a higher or lower resolution
  32377. * @param successCallback defines the callback receives a single parameter which contains the
  32378. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32379. * src parameter of an <img> to display it
  32380. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32381. * Check your browser for supported MIME types
  32382. */
  32383. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32384. /**
  32385. * Generates an image screenshot from the specified camera.
  32386. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32387. * @param engine The engine to use for rendering
  32388. * @param camera The camera to use for rendering
  32389. * @param size This parameter can be set to a single number or to an object with the
  32390. * following (optional) properties: precision, width, height. If a single number is passed,
  32391. * it will be used for both width and height. If an object is passed, the screenshot size
  32392. * will be derived from the parameters. The precision property is a multiplier allowing
  32393. * rendering at a higher or lower resolution
  32394. * @param successCallback The callback receives a single parameter which contains the
  32395. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32396. * src parameter of an <img> to display it
  32397. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32398. * Check your browser for supported MIME types
  32399. * @param samples Texture samples (default: 1)
  32400. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32401. * @param fileName A name for for the downloaded file.
  32402. */
  32403. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32404. /**
  32405. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32406. * Be aware Math.random() could cause collisions, but:
  32407. * "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"
  32408. * @returns a pseudo random id
  32409. */
  32410. static RandomId(): string;
  32411. /**
  32412. * Test if the given uri is a base64 string
  32413. * @param uri The uri to test
  32414. * @return True if the uri is a base64 string or false otherwise
  32415. */
  32416. static IsBase64(uri: string): boolean;
  32417. /**
  32418. * Decode the given base64 uri.
  32419. * @param uri The uri to decode
  32420. * @return The decoded base64 data.
  32421. */
  32422. static DecodeBase64(uri: string): ArrayBuffer;
  32423. /**
  32424. * Gets the absolute url.
  32425. * @param url the input url
  32426. * @return the absolute url
  32427. */
  32428. static GetAbsoluteUrl(url: string): string;
  32429. /**
  32430. * No log
  32431. */
  32432. static readonly NoneLogLevel: number;
  32433. /**
  32434. * Only message logs
  32435. */
  32436. static readonly MessageLogLevel: number;
  32437. /**
  32438. * Only warning logs
  32439. */
  32440. static readonly WarningLogLevel: number;
  32441. /**
  32442. * Only error logs
  32443. */
  32444. static readonly ErrorLogLevel: number;
  32445. /**
  32446. * All logs
  32447. */
  32448. static readonly AllLogLevel: number;
  32449. /**
  32450. * Gets a value indicating the number of loading errors
  32451. * @ignorenaming
  32452. */
  32453. static readonly errorsCount: number;
  32454. /**
  32455. * Callback called when a new log is added
  32456. */
  32457. static OnNewCacheEntry: (entry: string) => void;
  32458. /**
  32459. * Log a message to the console
  32460. * @param message defines the message to log
  32461. */
  32462. static Log(message: string): void;
  32463. /**
  32464. * Write a warning message to the console
  32465. * @param message defines the message to log
  32466. */
  32467. static Warn(message: string): void;
  32468. /**
  32469. * Write an error message to the console
  32470. * @param message defines the message to log
  32471. */
  32472. static Error(message: string): void;
  32473. /**
  32474. * Gets current log cache (list of logs)
  32475. */
  32476. static readonly LogCache: string;
  32477. /**
  32478. * Clears the log cache
  32479. */
  32480. static ClearLogCache(): void;
  32481. /**
  32482. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32483. */
  32484. static LogLevels: number;
  32485. /**
  32486. * Checks if the loaded document was accessed via `file:`-Protocol.
  32487. * @returns boolean
  32488. */
  32489. static IsFileURL(): boolean;
  32490. /**
  32491. * Checks if the window object exists
  32492. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32493. */
  32494. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32495. /**
  32496. * No performance log
  32497. */
  32498. static readonly PerformanceNoneLogLevel: number;
  32499. /**
  32500. * Use user marks to log performance
  32501. */
  32502. static readonly PerformanceUserMarkLogLevel: number;
  32503. /**
  32504. * Log performance to the console
  32505. */
  32506. static readonly PerformanceConsoleLogLevel: number;
  32507. private static _performance;
  32508. /**
  32509. * Sets the current performance log level
  32510. */
  32511. static PerformanceLogLevel: number;
  32512. private static _StartPerformanceCounterDisabled;
  32513. private static _EndPerformanceCounterDisabled;
  32514. private static _StartUserMark;
  32515. private static _EndUserMark;
  32516. private static _StartPerformanceConsole;
  32517. private static _EndPerformanceConsole;
  32518. /**
  32519. * Starts a performance counter
  32520. */
  32521. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32522. /**
  32523. * Ends a specific performance coutner
  32524. */
  32525. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32526. /**
  32527. * Gets either window.performance.now() if supported or Date.now() else
  32528. */
  32529. static readonly Now: number;
  32530. /**
  32531. * This method will return the name of the class used to create the instance of the given object.
  32532. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32533. * @param object the object to get the class name from
  32534. * @param isType defines if the object is actually a type
  32535. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32536. */
  32537. static GetClassName(object: any, isType?: boolean): string;
  32538. /**
  32539. * Gets the first element of an array satisfying a given predicate
  32540. * @param array defines the array to browse
  32541. * @param predicate defines the predicate to use
  32542. * @returns null if not found or the element
  32543. */
  32544. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32545. /**
  32546. * This method will return the name of the full name of the class, including its owning module (if any).
  32547. * 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).
  32548. * @param object the object to get the class name from
  32549. * @param isType defines if the object is actually a type
  32550. * @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.
  32551. * @ignorenaming
  32552. */
  32553. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32554. /**
  32555. * Returns a promise that resolves after the given amount of time.
  32556. * @param delay Number of milliseconds to delay
  32557. * @returns Promise that resolves after the given amount of time
  32558. */
  32559. static DelayAsync(delay: number): Promise<void>;
  32560. /**
  32561. * Gets the current gradient from an array of IValueGradient
  32562. * @param ratio defines the current ratio to get
  32563. * @param gradients defines the array of IValueGradient
  32564. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32565. */
  32566. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32567. }
  32568. /**
  32569. * This class is used to track a performance counter which is number based.
  32570. * The user has access to many properties which give statistics of different nature.
  32571. *
  32572. * The implementer can track two kinds of Performance Counter: time and count.
  32573. * 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.
  32574. * 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.
  32575. */
  32576. export class PerfCounter {
  32577. /**
  32578. * Gets or sets a global boolean to turn on and off all the counters
  32579. */
  32580. static Enabled: boolean;
  32581. /**
  32582. * Returns the smallest value ever
  32583. */
  32584. readonly min: number;
  32585. /**
  32586. * Returns the biggest value ever
  32587. */
  32588. readonly max: number;
  32589. /**
  32590. * Returns the average value since the performance counter is running
  32591. */
  32592. readonly average: number;
  32593. /**
  32594. * Returns the average value of the last second the counter was monitored
  32595. */
  32596. readonly lastSecAverage: number;
  32597. /**
  32598. * Returns the current value
  32599. */
  32600. readonly current: number;
  32601. /**
  32602. * Gets the accumulated total
  32603. */
  32604. readonly total: number;
  32605. /**
  32606. * Gets the total value count
  32607. */
  32608. readonly count: number;
  32609. /**
  32610. * Creates a new counter
  32611. */
  32612. constructor();
  32613. /**
  32614. * Call this method to start monitoring a new frame.
  32615. * 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.
  32616. */
  32617. fetchNewFrame(): void;
  32618. /**
  32619. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32620. * @param newCount the count value to add to the monitored count
  32621. * @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.
  32622. */
  32623. addCount(newCount: number, fetchResult: boolean): void;
  32624. /**
  32625. * Start monitoring this performance counter
  32626. */
  32627. beginMonitoring(): void;
  32628. /**
  32629. * Compute the time lapsed since the previous beginMonitoring() call.
  32630. * @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
  32631. */
  32632. endMonitoring(newFrame?: boolean): void;
  32633. private _fetchResult;
  32634. private _startMonitoringTime;
  32635. private _min;
  32636. private _max;
  32637. private _average;
  32638. private _current;
  32639. private _totalValueCount;
  32640. private _totalAccumulated;
  32641. private _lastSecAverage;
  32642. private _lastSecAccumulated;
  32643. private _lastSecTime;
  32644. private _lastSecValueCount;
  32645. }
  32646. /**
  32647. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32648. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32649. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32650. * @param name The name of the class, case should be preserved
  32651. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32652. */
  32653. export function className(name: string, module?: string): (target: Object) => void;
  32654. /**
  32655. * An implementation of a loop for asynchronous functions.
  32656. */
  32657. export class AsyncLoop {
  32658. /**
  32659. * Defines the number of iterations for the loop
  32660. */
  32661. iterations: number;
  32662. /**
  32663. * Defines the current index of the loop.
  32664. */
  32665. index: number;
  32666. private _done;
  32667. private _fn;
  32668. private _successCallback;
  32669. /**
  32670. * Constructor.
  32671. * @param iterations the number of iterations.
  32672. * @param func the function to run each iteration
  32673. * @param successCallback the callback that will be called upon succesful execution
  32674. * @param offset starting offset.
  32675. */
  32676. constructor(
  32677. /**
  32678. * Defines the number of iterations for the loop
  32679. */
  32680. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32681. /**
  32682. * Execute the next iteration. Must be called after the last iteration was finished.
  32683. */
  32684. executeNext(): void;
  32685. /**
  32686. * Break the loop and run the success callback.
  32687. */
  32688. breakLoop(): void;
  32689. /**
  32690. * Create and run an async loop.
  32691. * @param iterations the number of iterations.
  32692. * @param fn the function to run each iteration
  32693. * @param successCallback the callback that will be called upon succesful execution
  32694. * @param offset starting offset.
  32695. * @returns the created async loop object
  32696. */
  32697. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32698. /**
  32699. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32700. * @param iterations total number of iterations
  32701. * @param syncedIterations number of synchronous iterations in each async iteration.
  32702. * @param fn the function to call each iteration.
  32703. * @param callback a success call back that will be called when iterating stops.
  32704. * @param breakFunction a break condition (optional)
  32705. * @param timeout timeout settings for the setTimeout function. default - 0.
  32706. * @returns the created async loop object
  32707. */
  32708. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32709. }
  32710. }
  32711. declare module "babylonjs/Collisions/collisionCoordinator" {
  32712. import { Nullable } from "babylonjs/types";
  32713. import { Scene } from "babylonjs/scene";
  32714. import { Vector3 } from "babylonjs/Maths/math";
  32715. import { Collider } from "babylonjs/Collisions/collider";
  32716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32717. /** @hidden */
  32718. export interface ICollisionCoordinator {
  32719. createCollider(): Collider;
  32720. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32721. init(scene: Scene): void;
  32722. }
  32723. /** @hidden */
  32724. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32725. private _scene;
  32726. private _scaledPosition;
  32727. private _scaledVelocity;
  32728. private _finalPosition;
  32729. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32730. createCollider(): Collider;
  32731. init(scene: Scene): void;
  32732. private _collideWithWorld;
  32733. }
  32734. }
  32735. declare module "babylonjs/Inputs/scene.inputManager" {
  32736. import { Nullable } from "babylonjs/types";
  32737. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32738. import { Vector2 } from "babylonjs/Maths/math";
  32739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32740. import { Scene } from "babylonjs/scene";
  32741. /**
  32742. * Class used to manage all inputs for the scene.
  32743. */
  32744. export class InputManager {
  32745. /** The distance in pixel that you have to move to prevent some events */
  32746. static DragMovementThreshold: number;
  32747. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32748. static LongPressDelay: number;
  32749. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32750. static DoubleClickDelay: number;
  32751. /** If you need to check double click without raising a single click at first click, enable this flag */
  32752. static ExclusiveDoubleClickMode: boolean;
  32753. private _wheelEventName;
  32754. private _onPointerMove;
  32755. private _onPointerDown;
  32756. private _onPointerUp;
  32757. private _initClickEvent;
  32758. private _initActionManager;
  32759. private _delayedSimpleClick;
  32760. private _delayedSimpleClickTimeout;
  32761. private _previousDelayedSimpleClickTimeout;
  32762. private _meshPickProceed;
  32763. private _previousButtonPressed;
  32764. private _currentPickResult;
  32765. private _previousPickResult;
  32766. private _totalPointersPressed;
  32767. private _doubleClickOccured;
  32768. private _pointerOverMesh;
  32769. private _pickedDownMesh;
  32770. private _pickedUpMesh;
  32771. private _pointerX;
  32772. private _pointerY;
  32773. private _unTranslatedPointerX;
  32774. private _unTranslatedPointerY;
  32775. private _startingPointerPosition;
  32776. private _previousStartingPointerPosition;
  32777. private _startingPointerTime;
  32778. private _previousStartingPointerTime;
  32779. private _pointerCaptures;
  32780. private _onKeyDown;
  32781. private _onKeyUp;
  32782. private _onCanvasFocusObserver;
  32783. private _onCanvasBlurObserver;
  32784. private _scene;
  32785. /**
  32786. * Creates a new InputManager
  32787. * @param scene defines the hosting scene
  32788. */
  32789. constructor(scene: Scene);
  32790. /**
  32791. * Gets the mesh that is currently under the pointer
  32792. */
  32793. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32794. /**
  32795. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32796. */
  32797. readonly unTranslatedPointer: Vector2;
  32798. /**
  32799. * Gets or sets the current on-screen X position of the pointer
  32800. */
  32801. pointerX: number;
  32802. /**
  32803. * Gets or sets the current on-screen Y position of the pointer
  32804. */
  32805. pointerY: number;
  32806. private _updatePointerPosition;
  32807. private _processPointerMove;
  32808. private _setRayOnPointerInfo;
  32809. private _checkPrePointerObservable;
  32810. /**
  32811. * Use this method to simulate a pointer move on a mesh
  32812. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32813. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32814. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32815. */
  32816. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32817. /**
  32818. * Use this method to simulate a pointer down on a mesh
  32819. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32820. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32821. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32822. */
  32823. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32824. private _processPointerDown;
  32825. /** @hidden */
  32826. _isPointerSwiping(): boolean;
  32827. /**
  32828. * Use this method to simulate a pointer up on a mesh
  32829. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32830. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32831. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32832. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32833. */
  32834. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32835. private _processPointerUp;
  32836. /**
  32837. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32838. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32839. * @returns true if the pointer was captured
  32840. */
  32841. isPointerCaptured(pointerId?: number): boolean;
  32842. /**
  32843. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32844. * @param attachUp defines if you want to attach events to pointerup
  32845. * @param attachDown defines if you want to attach events to pointerdown
  32846. * @param attachMove defines if you want to attach events to pointermove
  32847. */
  32848. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32849. /**
  32850. * Detaches all event handlers
  32851. */
  32852. detachControl(): void;
  32853. /**
  32854. * Force the value of meshUnderPointer
  32855. * @param mesh defines the mesh to use
  32856. */
  32857. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32858. /**
  32859. * Gets the mesh under the pointer
  32860. * @returns a Mesh or null if no mesh is under the pointer
  32861. */
  32862. getPointerOverMesh(): Nullable<AbstractMesh>;
  32863. }
  32864. }
  32865. declare module "babylonjs/Animations/animationGroup" {
  32866. import { Animatable } from "babylonjs/Animations/animatable";
  32867. import { Animation } from "babylonjs/Animations/animation";
  32868. import { Scene, IDisposable } from "babylonjs/scene";
  32869. import { Observable } from "babylonjs/Misc/observable";
  32870. import { Nullable } from "babylonjs/types";
  32871. import "babylonjs/Animations/animatable";
  32872. /**
  32873. * This class defines the direct association between an animation and a target
  32874. */
  32875. export class TargetedAnimation {
  32876. /**
  32877. * Animation to perform
  32878. */
  32879. animation: Animation;
  32880. /**
  32881. * Target to animate
  32882. */
  32883. target: any;
  32884. /**
  32885. * Serialize the object
  32886. * @returns the JSON object representing the current entity
  32887. */
  32888. serialize(): any;
  32889. }
  32890. /**
  32891. * Use this class to create coordinated animations on multiple targets
  32892. */
  32893. export class AnimationGroup implements IDisposable {
  32894. /** The name of the animation group */
  32895. name: string;
  32896. private _scene;
  32897. private _targetedAnimations;
  32898. private _animatables;
  32899. private _from;
  32900. private _to;
  32901. private _isStarted;
  32902. private _isPaused;
  32903. private _speedRatio;
  32904. private _loopAnimation;
  32905. /**
  32906. * Gets or sets the unique id of the node
  32907. */
  32908. uniqueId: number;
  32909. /**
  32910. * This observable will notify when one animation have ended
  32911. */
  32912. onAnimationEndObservable: Observable<TargetedAnimation>;
  32913. /**
  32914. * Observer raised when one animation loops
  32915. */
  32916. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32917. /**
  32918. * This observable will notify when all animations have ended.
  32919. */
  32920. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32921. /**
  32922. * This observable will notify when all animations have paused.
  32923. */
  32924. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32925. /**
  32926. * This observable will notify when all animations are playing.
  32927. */
  32928. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32929. /**
  32930. * Gets the first frame
  32931. */
  32932. readonly from: number;
  32933. /**
  32934. * Gets the last frame
  32935. */
  32936. readonly to: number;
  32937. /**
  32938. * Define if the animations are started
  32939. */
  32940. readonly isStarted: boolean;
  32941. /**
  32942. * Gets a value indicating that the current group is playing
  32943. */
  32944. readonly isPlaying: boolean;
  32945. /**
  32946. * Gets or sets the speed ratio to use for all animations
  32947. */
  32948. /**
  32949. * Gets or sets the speed ratio to use for all animations
  32950. */
  32951. speedRatio: number;
  32952. /**
  32953. * Gets or sets if all animations should loop or not
  32954. */
  32955. loopAnimation: boolean;
  32956. /**
  32957. * Gets the targeted animations for this animation group
  32958. */
  32959. readonly targetedAnimations: Array<TargetedAnimation>;
  32960. /**
  32961. * returning the list of animatables controlled by this animation group.
  32962. */
  32963. readonly animatables: Array<Animatable>;
  32964. /**
  32965. * Instantiates a new Animation Group.
  32966. * This helps managing several animations at once.
  32967. * @see http://doc.babylonjs.com/how_to/group
  32968. * @param name Defines the name of the group
  32969. * @param scene Defines the scene the group belongs to
  32970. */
  32971. constructor(
  32972. /** The name of the animation group */
  32973. name: string, scene?: Nullable<Scene>);
  32974. /**
  32975. * Add an animation (with its target) in the group
  32976. * @param animation defines the animation we want to add
  32977. * @param target defines the target of the animation
  32978. * @returns the TargetedAnimation object
  32979. */
  32980. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32981. /**
  32982. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32983. * It can add constant keys at begin or end
  32984. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32985. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32986. * @returns the animation group
  32987. */
  32988. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32989. /**
  32990. * Start all animations on given targets
  32991. * @param loop defines if animations must loop
  32992. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32993. * @param from defines the from key (optional)
  32994. * @param to defines the to key (optional)
  32995. * @returns the current animation group
  32996. */
  32997. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32998. /**
  32999. * Pause all animations
  33000. * @returns the animation group
  33001. */
  33002. pause(): AnimationGroup;
  33003. /**
  33004. * Play all animations to initial state
  33005. * This function will start() the animations if they were not started or will restart() them if they were paused
  33006. * @param loop defines if animations must loop
  33007. * @returns the animation group
  33008. */
  33009. play(loop?: boolean): AnimationGroup;
  33010. /**
  33011. * Reset all animations to initial state
  33012. * @returns the animation group
  33013. */
  33014. reset(): AnimationGroup;
  33015. /**
  33016. * Restart animations from key 0
  33017. * @returns the animation group
  33018. */
  33019. restart(): AnimationGroup;
  33020. /**
  33021. * Stop all animations
  33022. * @returns the animation group
  33023. */
  33024. stop(): AnimationGroup;
  33025. /**
  33026. * Set animation weight for all animatables
  33027. * @param weight defines the weight to use
  33028. * @return the animationGroup
  33029. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33030. */
  33031. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33032. /**
  33033. * Synchronize and normalize all animatables with a source animatable
  33034. * @param root defines the root animatable to synchronize with
  33035. * @return the animationGroup
  33036. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33037. */
  33038. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33039. /**
  33040. * Goes to a specific frame in this animation group
  33041. * @param frame the frame number to go to
  33042. * @return the animationGroup
  33043. */
  33044. goToFrame(frame: number): AnimationGroup;
  33045. /**
  33046. * Dispose all associated resources
  33047. */
  33048. dispose(): void;
  33049. private _checkAnimationGroupEnded;
  33050. /**
  33051. * Clone the current animation group and returns a copy
  33052. * @param newName defines the name of the new group
  33053. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33054. * @returns the new aniamtion group
  33055. */
  33056. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33057. /**
  33058. * Serializes the animationGroup to an object
  33059. * @returns Serialized object
  33060. */
  33061. serialize(): any;
  33062. /**
  33063. * Returns a new AnimationGroup object parsed from the source provided.
  33064. * @param parsedAnimationGroup defines the source
  33065. * @param scene defines the scene that will receive the animationGroup
  33066. * @returns a new AnimationGroup
  33067. */
  33068. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33069. /**
  33070. * Returns the string "AnimationGroup"
  33071. * @returns "AnimationGroup"
  33072. */
  33073. getClassName(): string;
  33074. /**
  33075. * Creates a detailled string about the object
  33076. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33077. * @returns a string representing the object
  33078. */
  33079. toString(fullDetails?: boolean): string;
  33080. }
  33081. }
  33082. declare module "babylonjs/scene" {
  33083. import { Nullable } from "babylonjs/types";
  33084. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  33085. import { Observable } from "babylonjs/Misc/observable";
  33086. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33087. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  33088. import { Geometry } from "babylonjs/Meshes/geometry";
  33089. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33090. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33092. import { Mesh } from "babylonjs/Meshes/mesh";
  33093. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33094. import { Bone } from "babylonjs/Bones/bone";
  33095. import { Skeleton } from "babylonjs/Bones/skeleton";
  33096. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33097. import { Camera } from "babylonjs/Cameras/camera";
  33098. import { AbstractScene } from "babylonjs/abstractScene";
  33099. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33100. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33101. import { Material } from "babylonjs/Materials/material";
  33102. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33103. import { Effect } from "babylonjs/Materials/effect";
  33104. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33105. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33106. import { Light } from "babylonjs/Lights/light";
  33107. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33108. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33109. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33110. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33111. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33112. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33113. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33114. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33115. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33116. import { Engine } from "babylonjs/Engines/engine";
  33117. import { Node } from "babylonjs/node";
  33118. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33119. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33120. import { WebRequest } from "babylonjs/Misc/webRequest";
  33121. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33122. import { Ray } from "babylonjs/Culling/ray";
  33123. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33124. import { Animation } from "babylonjs/Animations/animation";
  33125. import { Animatable } from "babylonjs/Animations/animatable";
  33126. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33127. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33128. import { Collider } from "babylonjs/Collisions/collider";
  33129. /**
  33130. * Define an interface for all classes that will hold resources
  33131. */
  33132. export interface IDisposable {
  33133. /**
  33134. * Releases all held resources
  33135. */
  33136. dispose(): void;
  33137. }
  33138. /** Interface defining initialization parameters for Scene class */
  33139. export interface SceneOptions {
  33140. /**
  33141. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33142. * It will improve performance when the number of geometries becomes important.
  33143. */
  33144. useGeometryUniqueIdsMap?: boolean;
  33145. /**
  33146. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33147. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33148. */
  33149. useMaterialMeshMap?: boolean;
  33150. /**
  33151. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33152. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33153. */
  33154. useClonedMeshhMap?: boolean;
  33155. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33156. virtual?: boolean;
  33157. }
  33158. /**
  33159. * Represents a scene to be rendered by the engine.
  33160. * @see http://doc.babylonjs.com/features/scene
  33161. */
  33162. export class Scene extends AbstractScene implements IAnimatable {
  33163. private static _uniqueIdCounter;
  33164. /** The fog is deactivated */
  33165. static readonly FOGMODE_NONE: number;
  33166. /** The fog density is following an exponential function */
  33167. static readonly FOGMODE_EXP: number;
  33168. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33169. static readonly FOGMODE_EXP2: number;
  33170. /** The fog density is following a linear function. */
  33171. static readonly FOGMODE_LINEAR: number;
  33172. /**
  33173. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33174. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33175. */
  33176. static MinDeltaTime: number;
  33177. /**
  33178. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33179. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33180. */
  33181. static MaxDeltaTime: number;
  33182. /**
  33183. * Factory used to create the default material.
  33184. * @param name The name of the material to create
  33185. * @param scene The scene to create the material for
  33186. * @returns The default material
  33187. */
  33188. static DefaultMaterialFactory(scene: Scene): Material;
  33189. /**
  33190. * Factory used to create the a collision coordinator.
  33191. * @returns The collision coordinator
  33192. */
  33193. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33194. /** @hidden */
  33195. _inputManager: InputManager;
  33196. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33197. cameraToUseForPointers: Nullable<Camera>;
  33198. /** @hidden */
  33199. readonly _isScene: boolean;
  33200. /**
  33201. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33202. */
  33203. autoClear: boolean;
  33204. /**
  33205. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33206. */
  33207. autoClearDepthAndStencil: boolean;
  33208. /**
  33209. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33210. */
  33211. clearColor: Color4;
  33212. /**
  33213. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33214. */
  33215. ambientColor: Color3;
  33216. /**
  33217. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33218. * It should only be one of the following (if not the default embedded one):
  33219. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33220. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33221. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33222. * The material properties need to be setup according to the type of texture in use.
  33223. */
  33224. environmentBRDFTexture: BaseTexture;
  33225. /** @hidden */
  33226. protected _environmentTexture: Nullable<BaseTexture>;
  33227. /**
  33228. * Texture used in all pbr material as the reflection texture.
  33229. * As in the majority of the scene they are the same (exception for multi room and so on),
  33230. * this is easier to reference from here than from all the materials.
  33231. */
  33232. /**
  33233. * Texture used in all pbr material as the reflection texture.
  33234. * As in the majority of the scene they are the same (exception for multi room and so on),
  33235. * this is easier to set here than in all the materials.
  33236. */
  33237. environmentTexture: Nullable<BaseTexture>;
  33238. /** @hidden */
  33239. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33240. /**
  33241. * Default image processing configuration used either in the rendering
  33242. * Forward main pass or through the imageProcessingPostProcess if present.
  33243. * As in the majority of the scene they are the same (exception for multi camera),
  33244. * this is easier to reference from here than from all the materials and post process.
  33245. *
  33246. * No setter as we it is a shared configuration, you can set the values instead.
  33247. */
  33248. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33249. private _forceWireframe;
  33250. /**
  33251. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33252. */
  33253. forceWireframe: boolean;
  33254. private _forcePointsCloud;
  33255. /**
  33256. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33257. */
  33258. forcePointsCloud: boolean;
  33259. /**
  33260. * Gets or sets the active clipplane 1
  33261. */
  33262. clipPlane: Nullable<Plane>;
  33263. /**
  33264. * Gets or sets the active clipplane 2
  33265. */
  33266. clipPlane2: Nullable<Plane>;
  33267. /**
  33268. * Gets or sets the active clipplane 3
  33269. */
  33270. clipPlane3: Nullable<Plane>;
  33271. /**
  33272. * Gets or sets the active clipplane 4
  33273. */
  33274. clipPlane4: Nullable<Plane>;
  33275. /**
  33276. * Gets or sets a boolean indicating if animations are enabled
  33277. */
  33278. animationsEnabled: boolean;
  33279. private _animationPropertiesOverride;
  33280. /**
  33281. * Gets or sets the animation properties override
  33282. */
  33283. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33284. /**
  33285. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33286. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33287. */
  33288. useConstantAnimationDeltaTime: boolean;
  33289. /**
  33290. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33291. * Please note that it requires to run a ray cast through the scene on every frame
  33292. */
  33293. constantlyUpdateMeshUnderPointer: boolean;
  33294. /**
  33295. * Defines the HTML cursor to use when hovering over interactive elements
  33296. */
  33297. hoverCursor: string;
  33298. /**
  33299. * Defines the HTML default cursor to use (empty by default)
  33300. */
  33301. defaultCursor: string;
  33302. /**
  33303. * This is used to call preventDefault() on pointer down
  33304. * in order to block unwanted artifacts like system double clicks
  33305. */
  33306. preventDefaultOnPointerDown: boolean;
  33307. /**
  33308. * This is used to call preventDefault() on pointer up
  33309. * in order to block unwanted artifacts like system double clicks
  33310. */
  33311. preventDefaultOnPointerUp: boolean;
  33312. /**
  33313. * Gets or sets user defined metadata
  33314. */
  33315. metadata: any;
  33316. /**
  33317. * For internal use only. Please do not use.
  33318. */
  33319. reservedDataStore: any;
  33320. /**
  33321. * Gets the name of the plugin used to load this scene (null by default)
  33322. */
  33323. loadingPluginName: string;
  33324. /**
  33325. * Use this array to add regular expressions used to disable offline support for specific urls
  33326. */
  33327. disableOfflineSupportExceptionRules: RegExp[];
  33328. /**
  33329. * An event triggered when the scene is disposed.
  33330. */
  33331. onDisposeObservable: Observable<Scene>;
  33332. private _onDisposeObserver;
  33333. /** Sets a function to be executed when this scene is disposed. */
  33334. onDispose: () => void;
  33335. /**
  33336. * An event triggered before rendering the scene (right after animations and physics)
  33337. */
  33338. onBeforeRenderObservable: Observable<Scene>;
  33339. private _onBeforeRenderObserver;
  33340. /** Sets a function to be executed before rendering this scene */
  33341. beforeRender: Nullable<() => void>;
  33342. /**
  33343. * An event triggered after rendering the scene
  33344. */
  33345. onAfterRenderObservable: Observable<Scene>;
  33346. /**
  33347. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33348. */
  33349. onAfterRenderCameraObservable: Observable<Camera>;
  33350. private _onAfterRenderObserver;
  33351. /** Sets a function to be executed after rendering this scene */
  33352. afterRender: Nullable<() => void>;
  33353. /**
  33354. * An event triggered before animating the scene
  33355. */
  33356. onBeforeAnimationsObservable: Observable<Scene>;
  33357. /**
  33358. * An event triggered after animations processing
  33359. */
  33360. onAfterAnimationsObservable: Observable<Scene>;
  33361. /**
  33362. * An event triggered before draw calls are ready to be sent
  33363. */
  33364. onBeforeDrawPhaseObservable: Observable<Scene>;
  33365. /**
  33366. * An event triggered after draw calls have been sent
  33367. */
  33368. onAfterDrawPhaseObservable: Observable<Scene>;
  33369. /**
  33370. * An event triggered when the scene is ready
  33371. */
  33372. onReadyObservable: Observable<Scene>;
  33373. /**
  33374. * An event triggered before rendering a camera
  33375. */
  33376. onBeforeCameraRenderObservable: Observable<Camera>;
  33377. private _onBeforeCameraRenderObserver;
  33378. /** Sets a function to be executed before rendering a camera*/
  33379. beforeCameraRender: () => void;
  33380. /**
  33381. * An event triggered after rendering a camera
  33382. */
  33383. onAfterCameraRenderObservable: Observable<Camera>;
  33384. private _onAfterCameraRenderObserver;
  33385. /** Sets a function to be executed after rendering a camera*/
  33386. afterCameraRender: () => void;
  33387. /**
  33388. * An event triggered when active meshes evaluation is about to start
  33389. */
  33390. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33391. /**
  33392. * An event triggered when active meshes evaluation is done
  33393. */
  33394. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33395. /**
  33396. * An event triggered when particles rendering is about to start
  33397. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33398. */
  33399. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33400. /**
  33401. * An event triggered when particles rendering is done
  33402. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33403. */
  33404. onAfterParticlesRenderingObservable: Observable<Scene>;
  33405. /**
  33406. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33407. */
  33408. onDataLoadedObservable: Observable<Scene>;
  33409. /**
  33410. * An event triggered when a camera is created
  33411. */
  33412. onNewCameraAddedObservable: Observable<Camera>;
  33413. /**
  33414. * An event triggered when a camera is removed
  33415. */
  33416. onCameraRemovedObservable: Observable<Camera>;
  33417. /**
  33418. * An event triggered when a light is created
  33419. */
  33420. onNewLightAddedObservable: Observable<Light>;
  33421. /**
  33422. * An event triggered when a light is removed
  33423. */
  33424. onLightRemovedObservable: Observable<Light>;
  33425. /**
  33426. * An event triggered when a geometry is created
  33427. */
  33428. onNewGeometryAddedObservable: Observable<Geometry>;
  33429. /**
  33430. * An event triggered when a geometry is removed
  33431. */
  33432. onGeometryRemovedObservable: Observable<Geometry>;
  33433. /**
  33434. * An event triggered when a transform node is created
  33435. */
  33436. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33437. /**
  33438. * An event triggered when a transform node is removed
  33439. */
  33440. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33441. /**
  33442. * An event triggered when a mesh is created
  33443. */
  33444. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33445. /**
  33446. * An event triggered when a mesh is removed
  33447. */
  33448. onMeshRemovedObservable: Observable<AbstractMesh>;
  33449. /**
  33450. * An event triggered when a skeleton is created
  33451. */
  33452. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33453. /**
  33454. * An event triggered when a skeleton is removed
  33455. */
  33456. onSkeletonRemovedObservable: Observable<Skeleton>;
  33457. /**
  33458. * An event triggered when a material is created
  33459. */
  33460. onNewMaterialAddedObservable: Observable<Material>;
  33461. /**
  33462. * An event triggered when a material is removed
  33463. */
  33464. onMaterialRemovedObservable: Observable<Material>;
  33465. /**
  33466. * An event triggered when a texture is created
  33467. */
  33468. onNewTextureAddedObservable: Observable<BaseTexture>;
  33469. /**
  33470. * An event triggered when a texture is removed
  33471. */
  33472. onTextureRemovedObservable: Observable<BaseTexture>;
  33473. /**
  33474. * An event triggered when render targets are about to be rendered
  33475. * Can happen multiple times per frame.
  33476. */
  33477. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33478. /**
  33479. * An event triggered when render targets were rendered.
  33480. * Can happen multiple times per frame.
  33481. */
  33482. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33483. /**
  33484. * An event triggered before calculating deterministic simulation step
  33485. */
  33486. onBeforeStepObservable: Observable<Scene>;
  33487. /**
  33488. * An event triggered after calculating deterministic simulation step
  33489. */
  33490. onAfterStepObservable: Observable<Scene>;
  33491. /**
  33492. * An event triggered when the activeCamera property is updated
  33493. */
  33494. onActiveCameraChanged: Observable<Scene>;
  33495. /**
  33496. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33497. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33498. * 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)
  33499. */
  33500. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33501. /**
  33502. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33503. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33504. * 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)
  33505. */
  33506. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33507. /**
  33508. * This Observable will when a mesh has been imported into the scene.
  33509. */
  33510. onMeshImportedObservable: Observable<AbstractMesh>;
  33511. /**
  33512. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33513. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33514. */
  33515. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33516. /** @hidden */
  33517. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33518. /**
  33519. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33520. */
  33521. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33522. /**
  33523. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33524. */
  33525. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33526. /**
  33527. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33528. */
  33529. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33530. /** Callback called when a pointer move is detected */
  33531. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33532. /** Callback called when a pointer down is detected */
  33533. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33534. /** Callback called when a pointer up is detected */
  33535. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33536. /** Callback called when a pointer pick is detected */
  33537. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33538. /**
  33539. * 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).
  33540. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33541. */
  33542. onPrePointerObservable: Observable<PointerInfoPre>;
  33543. /**
  33544. * Observable event triggered each time an input event is received from the rendering canvas
  33545. */
  33546. onPointerObservable: Observable<PointerInfo>;
  33547. /**
  33548. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33549. */
  33550. readonly unTranslatedPointer: Vector2;
  33551. /**
  33552. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33553. */
  33554. static DragMovementThreshold: number;
  33555. /**
  33556. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33557. */
  33558. static LongPressDelay: number;
  33559. /**
  33560. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33561. */
  33562. static DoubleClickDelay: number;
  33563. /** If you need to check double click without raising a single click at first click, enable this flag */
  33564. static ExclusiveDoubleClickMode: boolean;
  33565. /** @hidden */
  33566. _mirroredCameraPosition: Nullable<Vector3>;
  33567. /**
  33568. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33569. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33570. */
  33571. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33572. /**
  33573. * Observable event triggered each time an keyboard event is received from the hosting window
  33574. */
  33575. onKeyboardObservable: Observable<KeyboardInfo>;
  33576. private _useRightHandedSystem;
  33577. /**
  33578. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33579. */
  33580. useRightHandedSystem: boolean;
  33581. private _timeAccumulator;
  33582. private _currentStepId;
  33583. private _currentInternalStep;
  33584. /**
  33585. * Sets the step Id used by deterministic lock step
  33586. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33587. * @param newStepId defines the step Id
  33588. */
  33589. setStepId(newStepId: number): void;
  33590. /**
  33591. * Gets the step Id used by deterministic lock step
  33592. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33593. * @returns the step Id
  33594. */
  33595. getStepId(): number;
  33596. /**
  33597. * Gets the internal step used by deterministic lock step
  33598. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33599. * @returns the internal step
  33600. */
  33601. getInternalStep(): number;
  33602. private _fogEnabled;
  33603. /**
  33604. * Gets or sets a boolean indicating if fog is enabled on this scene
  33605. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33606. * (Default is true)
  33607. */
  33608. fogEnabled: boolean;
  33609. private _fogMode;
  33610. /**
  33611. * Gets or sets the fog mode to use
  33612. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33613. * | mode | value |
  33614. * | --- | --- |
  33615. * | FOGMODE_NONE | 0 |
  33616. * | FOGMODE_EXP | 1 |
  33617. * | FOGMODE_EXP2 | 2 |
  33618. * | FOGMODE_LINEAR | 3 |
  33619. */
  33620. fogMode: number;
  33621. /**
  33622. * Gets or sets the fog color to use
  33623. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33624. * (Default is Color3(0.2, 0.2, 0.3))
  33625. */
  33626. fogColor: Color3;
  33627. /**
  33628. * Gets or sets the fog density to use
  33629. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33630. * (Default is 0.1)
  33631. */
  33632. fogDensity: number;
  33633. /**
  33634. * Gets or sets the fog start distance to use
  33635. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33636. * (Default is 0)
  33637. */
  33638. fogStart: number;
  33639. /**
  33640. * Gets or sets the fog end distance to use
  33641. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33642. * (Default is 1000)
  33643. */
  33644. fogEnd: number;
  33645. private _shadowsEnabled;
  33646. /**
  33647. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33648. */
  33649. shadowsEnabled: boolean;
  33650. private _lightsEnabled;
  33651. /**
  33652. * Gets or sets a boolean indicating if lights are enabled on this scene
  33653. */
  33654. lightsEnabled: boolean;
  33655. /** All of the active cameras added to this scene. */
  33656. activeCameras: Camera[];
  33657. /** @hidden */
  33658. _activeCamera: Nullable<Camera>;
  33659. /** Gets or sets the current active camera */
  33660. activeCamera: Nullable<Camera>;
  33661. private _defaultMaterial;
  33662. /** The default material used on meshes when no material is affected */
  33663. /** The default material used on meshes when no material is affected */
  33664. defaultMaterial: Material;
  33665. private _texturesEnabled;
  33666. /**
  33667. * Gets or sets a boolean indicating if textures are enabled on this scene
  33668. */
  33669. texturesEnabled: boolean;
  33670. /**
  33671. * Gets or sets a boolean indicating if particles are enabled on this scene
  33672. */
  33673. particlesEnabled: boolean;
  33674. /**
  33675. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33676. */
  33677. spritesEnabled: boolean;
  33678. private _skeletonsEnabled;
  33679. /**
  33680. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33681. */
  33682. skeletonsEnabled: boolean;
  33683. /**
  33684. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33685. */
  33686. lensFlaresEnabled: boolean;
  33687. /**
  33688. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33689. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33690. */
  33691. collisionsEnabled: boolean;
  33692. private _collisionCoordinator;
  33693. /** @hidden */
  33694. readonly collisionCoordinator: ICollisionCoordinator;
  33695. /**
  33696. * Defines the gravity applied to this scene (used only for collisions)
  33697. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33698. */
  33699. gravity: Vector3;
  33700. /**
  33701. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33702. */
  33703. postProcessesEnabled: boolean;
  33704. /**
  33705. * The list of postprocesses added to the scene
  33706. */
  33707. postProcesses: PostProcess[];
  33708. /**
  33709. * Gets the current postprocess manager
  33710. */
  33711. postProcessManager: PostProcessManager;
  33712. /**
  33713. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33714. */
  33715. renderTargetsEnabled: boolean;
  33716. /**
  33717. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33718. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33719. */
  33720. dumpNextRenderTargets: boolean;
  33721. /**
  33722. * The list of user defined render targets added to the scene
  33723. */
  33724. customRenderTargets: RenderTargetTexture[];
  33725. /**
  33726. * Defines if texture loading must be delayed
  33727. * If true, textures will only be loaded when they need to be rendered
  33728. */
  33729. useDelayedTextureLoading: boolean;
  33730. /**
  33731. * Gets the list of meshes imported to the scene through SceneLoader
  33732. */
  33733. importedMeshesFiles: String[];
  33734. /**
  33735. * Gets or sets a boolean indicating if probes are enabled on this scene
  33736. */
  33737. probesEnabled: boolean;
  33738. /**
  33739. * Gets or sets the current offline provider to use to store scene data
  33740. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33741. */
  33742. offlineProvider: IOfflineProvider;
  33743. /**
  33744. * Gets or sets the action manager associated with the scene
  33745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33746. */
  33747. actionManager: AbstractActionManager;
  33748. private _meshesForIntersections;
  33749. /**
  33750. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33751. */
  33752. proceduralTexturesEnabled: boolean;
  33753. private _engine;
  33754. private _totalVertices;
  33755. /** @hidden */
  33756. _activeIndices: PerfCounter;
  33757. /** @hidden */
  33758. _activeParticles: PerfCounter;
  33759. /** @hidden */
  33760. _activeBones: PerfCounter;
  33761. private _animationRatio;
  33762. /** @hidden */
  33763. _animationTimeLast: number;
  33764. /** @hidden */
  33765. _animationTime: number;
  33766. /**
  33767. * Gets or sets a general scale for animation speed
  33768. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33769. */
  33770. animationTimeScale: number;
  33771. /** @hidden */
  33772. _cachedMaterial: Nullable<Material>;
  33773. /** @hidden */
  33774. _cachedEffect: Nullable<Effect>;
  33775. /** @hidden */
  33776. _cachedVisibility: Nullable<number>;
  33777. private _renderId;
  33778. private _frameId;
  33779. private _executeWhenReadyTimeoutId;
  33780. private _intermediateRendering;
  33781. private _viewUpdateFlag;
  33782. private _projectionUpdateFlag;
  33783. /** @hidden */
  33784. _toBeDisposed: Nullable<IDisposable>[];
  33785. private _activeRequests;
  33786. /** @hidden */
  33787. _pendingData: any[];
  33788. private _isDisposed;
  33789. /**
  33790. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33791. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33792. */
  33793. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33794. private _activeMeshes;
  33795. private _processedMaterials;
  33796. private _renderTargets;
  33797. /** @hidden */
  33798. _activeParticleSystems: SmartArray<IParticleSystem>;
  33799. private _activeSkeletons;
  33800. private _softwareSkinnedMeshes;
  33801. private _renderingManager;
  33802. /** @hidden */
  33803. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33804. private _transformMatrix;
  33805. private _sceneUbo;
  33806. /** @hidden */
  33807. _viewMatrix: Matrix;
  33808. private _projectionMatrix;
  33809. /** @hidden */
  33810. _forcedViewPosition: Nullable<Vector3>;
  33811. /** @hidden */
  33812. _frustumPlanes: Plane[];
  33813. /**
  33814. * Gets the list of frustum planes (built from the active camera)
  33815. */
  33816. readonly frustumPlanes: Plane[];
  33817. /**
  33818. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33819. * This is useful if there are more lights that the maximum simulteanous authorized
  33820. */
  33821. requireLightSorting: boolean;
  33822. /** @hidden */
  33823. readonly useMaterialMeshMap: boolean;
  33824. /** @hidden */
  33825. readonly useClonedMeshhMap: boolean;
  33826. private _externalData;
  33827. private _uid;
  33828. /**
  33829. * @hidden
  33830. * Backing store of defined scene components.
  33831. */
  33832. _components: ISceneComponent[];
  33833. /**
  33834. * @hidden
  33835. * Backing store of defined scene components.
  33836. */
  33837. _serializableComponents: ISceneSerializableComponent[];
  33838. /**
  33839. * List of components to register on the next registration step.
  33840. */
  33841. private _transientComponents;
  33842. /**
  33843. * Registers the transient components if needed.
  33844. */
  33845. private _registerTransientComponents;
  33846. /**
  33847. * @hidden
  33848. * Add a component to the scene.
  33849. * Note that the ccomponent could be registered on th next frame if this is called after
  33850. * the register component stage.
  33851. * @param component Defines the component to add to the scene
  33852. */
  33853. _addComponent(component: ISceneComponent): void;
  33854. /**
  33855. * @hidden
  33856. * Gets a component from the scene.
  33857. * @param name defines the name of the component to retrieve
  33858. * @returns the component or null if not present
  33859. */
  33860. _getComponent(name: string): Nullable<ISceneComponent>;
  33861. /**
  33862. * @hidden
  33863. * Defines the actions happening before camera updates.
  33864. */
  33865. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33866. /**
  33867. * @hidden
  33868. * Defines the actions happening before clear the canvas.
  33869. */
  33870. _beforeClearStage: Stage<SimpleStageAction>;
  33871. /**
  33872. * @hidden
  33873. * Defines the actions when collecting render targets for the frame.
  33874. */
  33875. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33876. /**
  33877. * @hidden
  33878. * Defines the actions happening for one camera in the frame.
  33879. */
  33880. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33881. /**
  33882. * @hidden
  33883. * Defines the actions happening during the per mesh ready checks.
  33884. */
  33885. _isReadyForMeshStage: Stage<MeshStageAction>;
  33886. /**
  33887. * @hidden
  33888. * Defines the actions happening before evaluate active mesh checks.
  33889. */
  33890. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33891. /**
  33892. * @hidden
  33893. * Defines the actions happening during the evaluate sub mesh checks.
  33894. */
  33895. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33896. /**
  33897. * @hidden
  33898. * Defines the actions happening during the active mesh stage.
  33899. */
  33900. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33901. /**
  33902. * @hidden
  33903. * Defines the actions happening during the per camera render target step.
  33904. */
  33905. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33906. /**
  33907. * @hidden
  33908. * Defines the actions happening just before the active camera is drawing.
  33909. */
  33910. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33911. /**
  33912. * @hidden
  33913. * Defines the actions happening just before a render target is drawing.
  33914. */
  33915. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33916. /**
  33917. * @hidden
  33918. * Defines the actions happening just before a rendering group is drawing.
  33919. */
  33920. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33921. /**
  33922. * @hidden
  33923. * Defines the actions happening just before a mesh is drawing.
  33924. */
  33925. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33926. /**
  33927. * @hidden
  33928. * Defines the actions happening just after a mesh has been drawn.
  33929. */
  33930. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33931. /**
  33932. * @hidden
  33933. * Defines the actions happening just after a rendering group has been drawn.
  33934. */
  33935. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33936. /**
  33937. * @hidden
  33938. * Defines the actions happening just after the active camera has been drawn.
  33939. */
  33940. _afterCameraDrawStage: Stage<CameraStageAction>;
  33941. /**
  33942. * @hidden
  33943. * Defines the actions happening just after a render target has been drawn.
  33944. */
  33945. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33946. /**
  33947. * @hidden
  33948. * Defines the actions happening just after rendering all cameras and computing intersections.
  33949. */
  33950. _afterRenderStage: Stage<SimpleStageAction>;
  33951. /**
  33952. * @hidden
  33953. * Defines the actions happening when a pointer move event happens.
  33954. */
  33955. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33956. /**
  33957. * @hidden
  33958. * Defines the actions happening when a pointer down event happens.
  33959. */
  33960. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33961. /**
  33962. * @hidden
  33963. * Defines the actions happening when a pointer up event happens.
  33964. */
  33965. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33966. /**
  33967. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33968. */
  33969. private geometriesByUniqueId;
  33970. /**
  33971. * Creates a new Scene
  33972. * @param engine defines the engine to use to render this scene
  33973. * @param options defines the scene options
  33974. */
  33975. constructor(engine: Engine, options?: SceneOptions);
  33976. /**
  33977. * Gets a string idenfifying the name of the class
  33978. * @returns "Scene" string
  33979. */
  33980. getClassName(): string;
  33981. private _defaultMeshCandidates;
  33982. /**
  33983. * @hidden
  33984. */
  33985. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33986. private _defaultSubMeshCandidates;
  33987. /**
  33988. * @hidden
  33989. */
  33990. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33991. /**
  33992. * Sets the default candidate providers for the scene.
  33993. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33994. * and getCollidingSubMeshCandidates to their default function
  33995. */
  33996. setDefaultCandidateProviders(): void;
  33997. /**
  33998. * Gets the mesh that is currently under the pointer
  33999. */
  34000. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34001. /**
  34002. * Gets or sets the current on-screen X position of the pointer
  34003. */
  34004. pointerX: number;
  34005. /**
  34006. * Gets or sets the current on-screen Y position of the pointer
  34007. */
  34008. pointerY: number;
  34009. /**
  34010. * Gets the cached material (ie. the latest rendered one)
  34011. * @returns the cached material
  34012. */
  34013. getCachedMaterial(): Nullable<Material>;
  34014. /**
  34015. * Gets the cached effect (ie. the latest rendered one)
  34016. * @returns the cached effect
  34017. */
  34018. getCachedEffect(): Nullable<Effect>;
  34019. /**
  34020. * Gets the cached visibility state (ie. the latest rendered one)
  34021. * @returns the cached visibility state
  34022. */
  34023. getCachedVisibility(): Nullable<number>;
  34024. /**
  34025. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34026. * @param material defines the current material
  34027. * @param effect defines the current effect
  34028. * @param visibility defines the current visibility state
  34029. * @returns true if one parameter is not cached
  34030. */
  34031. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34032. /**
  34033. * Gets the engine associated with the scene
  34034. * @returns an Engine
  34035. */
  34036. getEngine(): Engine;
  34037. /**
  34038. * Gets the total number of vertices rendered per frame
  34039. * @returns the total number of vertices rendered per frame
  34040. */
  34041. getTotalVertices(): number;
  34042. /**
  34043. * Gets the performance counter for total vertices
  34044. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34045. */
  34046. readonly totalVerticesPerfCounter: PerfCounter;
  34047. /**
  34048. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34049. * @returns the total number of active indices rendered per frame
  34050. */
  34051. getActiveIndices(): number;
  34052. /**
  34053. * Gets the performance counter for active indices
  34054. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34055. */
  34056. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34057. /**
  34058. * Gets the total number of active particles rendered per frame
  34059. * @returns the total number of active particles rendered per frame
  34060. */
  34061. getActiveParticles(): number;
  34062. /**
  34063. * Gets the performance counter for active particles
  34064. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34065. */
  34066. readonly activeParticlesPerfCounter: PerfCounter;
  34067. /**
  34068. * Gets the total number of active bones rendered per frame
  34069. * @returns the total number of active bones rendered per frame
  34070. */
  34071. getActiveBones(): number;
  34072. /**
  34073. * Gets the performance counter for active bones
  34074. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34075. */
  34076. readonly activeBonesPerfCounter: PerfCounter;
  34077. /**
  34078. * Gets the array of active meshes
  34079. * @returns an array of AbstractMesh
  34080. */
  34081. getActiveMeshes(): SmartArray<AbstractMesh>;
  34082. /**
  34083. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34084. * @returns a number
  34085. */
  34086. getAnimationRatio(): number;
  34087. /**
  34088. * Gets an unique Id for the current render phase
  34089. * @returns a number
  34090. */
  34091. getRenderId(): number;
  34092. /**
  34093. * Gets an unique Id for the current frame
  34094. * @returns a number
  34095. */
  34096. getFrameId(): number;
  34097. /** Call this function if you want to manually increment the render Id*/
  34098. incrementRenderId(): void;
  34099. private _createUbo;
  34100. /**
  34101. * Use this method to simulate a pointer move on a mesh
  34102. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34103. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34104. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34105. * @returns the current scene
  34106. */
  34107. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34108. /**
  34109. * Use this method to simulate a pointer down on a mesh
  34110. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34111. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34112. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34113. * @returns the current scene
  34114. */
  34115. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34116. /**
  34117. * Use this method to simulate a pointer up on a mesh
  34118. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34119. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34120. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34121. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34122. * @returns the current scene
  34123. */
  34124. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34125. /**
  34126. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34127. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34128. * @returns true if the pointer was captured
  34129. */
  34130. isPointerCaptured(pointerId?: number): boolean;
  34131. /**
  34132. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34133. * @param attachUp defines if you want to attach events to pointerup
  34134. * @param attachDown defines if you want to attach events to pointerdown
  34135. * @param attachMove defines if you want to attach events to pointermove
  34136. */
  34137. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34138. /** Detaches all event handlers*/
  34139. detachControl(): void;
  34140. /**
  34141. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34142. * Delay loaded resources are not taking in account
  34143. * @return true if all required resources are ready
  34144. */
  34145. isReady(): boolean;
  34146. /** Resets all cached information relative to material (including effect and visibility) */
  34147. resetCachedMaterial(): void;
  34148. /**
  34149. * Registers a function to be called before every frame render
  34150. * @param func defines the function to register
  34151. */
  34152. registerBeforeRender(func: () => void): void;
  34153. /**
  34154. * Unregisters a function called before every frame render
  34155. * @param func defines the function to unregister
  34156. */
  34157. unregisterBeforeRender(func: () => void): void;
  34158. /**
  34159. * Registers a function to be called after every frame render
  34160. * @param func defines the function to register
  34161. */
  34162. registerAfterRender(func: () => void): void;
  34163. /**
  34164. * Unregisters a function called after every frame render
  34165. * @param func defines the function to unregister
  34166. */
  34167. unregisterAfterRender(func: () => void): void;
  34168. private _executeOnceBeforeRender;
  34169. /**
  34170. * The provided function will run before render once and will be disposed afterwards.
  34171. * A timeout delay can be provided so that the function will be executed in N ms.
  34172. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34173. * @param func The function to be executed.
  34174. * @param timeout optional delay in ms
  34175. */
  34176. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34177. /** @hidden */
  34178. _addPendingData(data: any): void;
  34179. /** @hidden */
  34180. _removePendingData(data: any): void;
  34181. /**
  34182. * Returns the number of items waiting to be loaded
  34183. * @returns the number of items waiting to be loaded
  34184. */
  34185. getWaitingItemsCount(): number;
  34186. /**
  34187. * Returns a boolean indicating if the scene is still loading data
  34188. */
  34189. readonly isLoading: boolean;
  34190. /**
  34191. * Registers a function to be executed when the scene is ready
  34192. * @param {Function} func - the function to be executed
  34193. */
  34194. executeWhenReady(func: () => void): void;
  34195. /**
  34196. * Returns a promise that resolves when the scene is ready
  34197. * @returns A promise that resolves when the scene is ready
  34198. */
  34199. whenReadyAsync(): Promise<void>;
  34200. /** @hidden */
  34201. _checkIsReady(): void;
  34202. /**
  34203. * Gets all animatable attached to the scene
  34204. */
  34205. readonly animatables: Animatable[];
  34206. /**
  34207. * Resets the last animation time frame.
  34208. * Useful to override when animations start running when loading a scene for the first time.
  34209. */
  34210. resetLastAnimationTimeFrame(): void;
  34211. /**
  34212. * Gets the current view matrix
  34213. * @returns a Matrix
  34214. */
  34215. getViewMatrix(): Matrix;
  34216. /**
  34217. * Gets the current projection matrix
  34218. * @returns a Matrix
  34219. */
  34220. getProjectionMatrix(): Matrix;
  34221. /**
  34222. * Gets the current transform matrix
  34223. * @returns a Matrix made of View * Projection
  34224. */
  34225. getTransformMatrix(): Matrix;
  34226. /**
  34227. * Sets the current transform matrix
  34228. * @param viewL defines the View matrix to use
  34229. * @param projectionL defines the Projection matrix to use
  34230. * @param viewR defines the right View matrix to use (if provided)
  34231. * @param projectionR defines the right Projection matrix to use (if provided)
  34232. */
  34233. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34234. /**
  34235. * Gets the uniform buffer used to store scene data
  34236. * @returns a UniformBuffer
  34237. */
  34238. getSceneUniformBuffer(): UniformBuffer;
  34239. /**
  34240. * Gets an unique (relatively to the current scene) Id
  34241. * @returns an unique number for the scene
  34242. */
  34243. getUniqueId(): number;
  34244. /**
  34245. * Add a mesh to the list of scene's meshes
  34246. * @param newMesh defines the mesh to add
  34247. * @param recursive if all child meshes should also be added to the scene
  34248. */
  34249. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34250. /**
  34251. * Remove a mesh for the list of scene's meshes
  34252. * @param toRemove defines the mesh to remove
  34253. * @param recursive if all child meshes should also be removed from the scene
  34254. * @returns the index where the mesh was in the mesh list
  34255. */
  34256. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34257. /**
  34258. * Add a transform node to the list of scene's transform nodes
  34259. * @param newTransformNode defines the transform node to add
  34260. */
  34261. addTransformNode(newTransformNode: TransformNode): void;
  34262. /**
  34263. * Remove a transform node for the list of scene's transform nodes
  34264. * @param toRemove defines the transform node to remove
  34265. * @returns the index where the transform node was in the transform node list
  34266. */
  34267. removeTransformNode(toRemove: TransformNode): number;
  34268. /**
  34269. * Remove a skeleton for the list of scene's skeletons
  34270. * @param toRemove defines the skeleton to remove
  34271. * @returns the index where the skeleton was in the skeleton list
  34272. */
  34273. removeSkeleton(toRemove: Skeleton): number;
  34274. /**
  34275. * Remove a morph target for the list of scene's morph targets
  34276. * @param toRemove defines the morph target to remove
  34277. * @returns the index where the morph target was in the morph target list
  34278. */
  34279. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34280. /**
  34281. * Remove a light for the list of scene's lights
  34282. * @param toRemove defines the light to remove
  34283. * @returns the index where the light was in the light list
  34284. */
  34285. removeLight(toRemove: Light): number;
  34286. /**
  34287. * Remove a camera for the list of scene's cameras
  34288. * @param toRemove defines the camera to remove
  34289. * @returns the index where the camera was in the camera list
  34290. */
  34291. removeCamera(toRemove: Camera): number;
  34292. /**
  34293. * Remove a particle system for the list of scene's particle systems
  34294. * @param toRemove defines the particle system to remove
  34295. * @returns the index where the particle system was in the particle system list
  34296. */
  34297. removeParticleSystem(toRemove: IParticleSystem): number;
  34298. /**
  34299. * Remove a animation for the list of scene's animations
  34300. * @param toRemove defines the animation to remove
  34301. * @returns the index where the animation was in the animation list
  34302. */
  34303. removeAnimation(toRemove: Animation): number;
  34304. /**
  34305. * Will stop the animation of the given target
  34306. * @param target - the target
  34307. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34308. * @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)
  34309. */
  34310. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34311. /**
  34312. * Removes the given animation group from this scene.
  34313. * @param toRemove The animation group to remove
  34314. * @returns The index of the removed animation group
  34315. */
  34316. removeAnimationGroup(toRemove: AnimationGroup): number;
  34317. /**
  34318. * Removes the given multi-material from this scene.
  34319. * @param toRemove The multi-material to remove
  34320. * @returns The index of the removed multi-material
  34321. */
  34322. removeMultiMaterial(toRemove: MultiMaterial): number;
  34323. /**
  34324. * Removes the given material from this scene.
  34325. * @param toRemove The material to remove
  34326. * @returns The index of the removed material
  34327. */
  34328. removeMaterial(toRemove: Material): number;
  34329. /**
  34330. * Removes the given action manager from this scene.
  34331. * @param toRemove The action manager to remove
  34332. * @returns The index of the removed action manager
  34333. */
  34334. removeActionManager(toRemove: AbstractActionManager): number;
  34335. /**
  34336. * Removes the given texture from this scene.
  34337. * @param toRemove The texture to remove
  34338. * @returns The index of the removed texture
  34339. */
  34340. removeTexture(toRemove: BaseTexture): number;
  34341. /**
  34342. * Adds the given light to this scene
  34343. * @param newLight The light to add
  34344. */
  34345. addLight(newLight: Light): void;
  34346. /**
  34347. * Sorts the list list based on light priorities
  34348. */
  34349. sortLightsByPriority(): void;
  34350. /**
  34351. * Adds the given camera to this scene
  34352. * @param newCamera The camera to add
  34353. */
  34354. addCamera(newCamera: Camera): void;
  34355. /**
  34356. * Adds the given skeleton to this scene
  34357. * @param newSkeleton The skeleton to add
  34358. */
  34359. addSkeleton(newSkeleton: Skeleton): void;
  34360. /**
  34361. * Adds the given particle system to this scene
  34362. * @param newParticleSystem The particle system to add
  34363. */
  34364. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34365. /**
  34366. * Adds the given animation to this scene
  34367. * @param newAnimation The animation to add
  34368. */
  34369. addAnimation(newAnimation: Animation): void;
  34370. /**
  34371. * Adds the given animation group to this scene.
  34372. * @param newAnimationGroup The animation group to add
  34373. */
  34374. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34375. /**
  34376. * Adds the given multi-material to this scene
  34377. * @param newMultiMaterial The multi-material to add
  34378. */
  34379. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34380. /**
  34381. * Adds the given material to this scene
  34382. * @param newMaterial The material to add
  34383. */
  34384. addMaterial(newMaterial: Material): void;
  34385. /**
  34386. * Adds the given morph target to this scene
  34387. * @param newMorphTargetManager The morph target to add
  34388. */
  34389. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34390. /**
  34391. * Adds the given geometry to this scene
  34392. * @param newGeometry The geometry to add
  34393. */
  34394. addGeometry(newGeometry: Geometry): void;
  34395. /**
  34396. * Adds the given action manager to this scene
  34397. * @param newActionManager The action manager to add
  34398. */
  34399. addActionManager(newActionManager: AbstractActionManager): void;
  34400. /**
  34401. * Adds the given texture to this scene.
  34402. * @param newTexture The texture to add
  34403. */
  34404. addTexture(newTexture: BaseTexture): void;
  34405. /**
  34406. * Switch active camera
  34407. * @param newCamera defines the new active camera
  34408. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34409. */
  34410. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34411. /**
  34412. * sets the active camera of the scene using its ID
  34413. * @param id defines the camera's ID
  34414. * @return the new active camera or null if none found.
  34415. */
  34416. setActiveCameraByID(id: string): Nullable<Camera>;
  34417. /**
  34418. * sets the active camera of the scene using its name
  34419. * @param name defines the camera's name
  34420. * @returns the new active camera or null if none found.
  34421. */
  34422. setActiveCameraByName(name: string): Nullable<Camera>;
  34423. /**
  34424. * get an animation group using its name
  34425. * @param name defines the material's name
  34426. * @return the animation group or null if none found.
  34427. */
  34428. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34429. /**
  34430. * Get a material using its unique id
  34431. * @param uniqueId defines the material's unique id
  34432. * @return the material or null if none found.
  34433. */
  34434. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34435. /**
  34436. * get a material using its id
  34437. * @param id defines the material's ID
  34438. * @return the material or null if none found.
  34439. */
  34440. getMaterialByID(id: string): Nullable<Material>;
  34441. /**
  34442. * Gets a the last added material using a given id
  34443. * @param id defines the material's ID
  34444. * @return the last material with the given id or null if none found.
  34445. */
  34446. getLastMaterialByID(id: string): Nullable<Material>;
  34447. /**
  34448. * Gets a material using its name
  34449. * @param name defines the material's name
  34450. * @return the material or null if none found.
  34451. */
  34452. getMaterialByName(name: string): Nullable<Material>;
  34453. /**
  34454. * Gets a camera using its id
  34455. * @param id defines the id to look for
  34456. * @returns the camera or null if not found
  34457. */
  34458. getCameraByID(id: string): Nullable<Camera>;
  34459. /**
  34460. * Gets a camera using its unique id
  34461. * @param uniqueId defines the unique id to look for
  34462. * @returns the camera or null if not found
  34463. */
  34464. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34465. /**
  34466. * Gets a camera using its name
  34467. * @param name defines the camera's name
  34468. * @return the camera or null if none found.
  34469. */
  34470. getCameraByName(name: string): Nullable<Camera>;
  34471. /**
  34472. * Gets a bone using its id
  34473. * @param id defines the bone's id
  34474. * @return the bone or null if not found
  34475. */
  34476. getBoneByID(id: string): Nullable<Bone>;
  34477. /**
  34478. * Gets a bone using its id
  34479. * @param name defines the bone's name
  34480. * @return the bone or null if not found
  34481. */
  34482. getBoneByName(name: string): Nullable<Bone>;
  34483. /**
  34484. * Gets a light node using its name
  34485. * @param name defines the the light's name
  34486. * @return the light or null if none found.
  34487. */
  34488. getLightByName(name: string): Nullable<Light>;
  34489. /**
  34490. * Gets a light node using its id
  34491. * @param id defines the light's id
  34492. * @return the light or null if none found.
  34493. */
  34494. getLightByID(id: string): Nullable<Light>;
  34495. /**
  34496. * Gets a light node using its scene-generated unique ID
  34497. * @param uniqueId defines the light's unique id
  34498. * @return the light or null if none found.
  34499. */
  34500. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34501. /**
  34502. * Gets a particle system by id
  34503. * @param id defines the particle system id
  34504. * @return the corresponding system or null if none found
  34505. */
  34506. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34507. /**
  34508. * Gets a geometry using its ID
  34509. * @param id defines the geometry's id
  34510. * @return the geometry or null if none found.
  34511. */
  34512. getGeometryByID(id: string): Nullable<Geometry>;
  34513. private _getGeometryByUniqueID;
  34514. /**
  34515. * Add a new geometry to this scene
  34516. * @param geometry defines the geometry to be added to the scene.
  34517. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34518. * @return a boolean defining if the geometry was added or not
  34519. */
  34520. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34521. /**
  34522. * Removes an existing geometry
  34523. * @param geometry defines the geometry to be removed from the scene
  34524. * @return a boolean defining if the geometry was removed or not
  34525. */
  34526. removeGeometry(geometry: Geometry): boolean;
  34527. /**
  34528. * Gets the list of geometries attached to the scene
  34529. * @returns an array of Geometry
  34530. */
  34531. getGeometries(): Geometry[];
  34532. /**
  34533. * Gets the first added mesh found of a given ID
  34534. * @param id defines the id to search for
  34535. * @return the mesh found or null if not found at all
  34536. */
  34537. getMeshByID(id: string): Nullable<AbstractMesh>;
  34538. /**
  34539. * Gets a list of meshes using their id
  34540. * @param id defines the id to search for
  34541. * @returns a list of meshes
  34542. */
  34543. getMeshesByID(id: string): Array<AbstractMesh>;
  34544. /**
  34545. * Gets the first added transform node found of a given ID
  34546. * @param id defines the id to search for
  34547. * @return the found transform node or null if not found at all.
  34548. */
  34549. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34550. /**
  34551. * Gets a transform node with its auto-generated unique id
  34552. * @param uniqueId efines the unique id to search for
  34553. * @return the found transform node or null if not found at all.
  34554. */
  34555. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34556. /**
  34557. * Gets a list of transform nodes using their id
  34558. * @param id defines the id to search for
  34559. * @returns a list of transform nodes
  34560. */
  34561. getTransformNodesByID(id: string): Array<TransformNode>;
  34562. /**
  34563. * Gets a mesh with its auto-generated unique id
  34564. * @param uniqueId defines the unique id to search for
  34565. * @return the found mesh or null if not found at all.
  34566. */
  34567. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34568. /**
  34569. * Gets a the last added mesh using a given id
  34570. * @param id defines the id to search for
  34571. * @return the found mesh or null if not found at all.
  34572. */
  34573. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34574. /**
  34575. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34576. * @param id defines the id to search for
  34577. * @return the found node or null if not found at all
  34578. */
  34579. getLastEntryByID(id: string): Nullable<Node>;
  34580. /**
  34581. * Gets a node (Mesh, Camera, Light) using a given id
  34582. * @param id defines the id to search for
  34583. * @return the found node or null if not found at all
  34584. */
  34585. getNodeByID(id: string): Nullable<Node>;
  34586. /**
  34587. * Gets a node (Mesh, Camera, Light) using a given name
  34588. * @param name defines the name to search for
  34589. * @return the found node or null if not found at all.
  34590. */
  34591. getNodeByName(name: string): Nullable<Node>;
  34592. /**
  34593. * Gets a mesh using a given name
  34594. * @param name defines the name to search for
  34595. * @return the found mesh or null if not found at all.
  34596. */
  34597. getMeshByName(name: string): Nullable<AbstractMesh>;
  34598. /**
  34599. * Gets a transform node using a given name
  34600. * @param name defines the name to search for
  34601. * @return the found transform node or null if not found at all.
  34602. */
  34603. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34604. /**
  34605. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34606. * @param id defines the id to search for
  34607. * @return the found skeleton or null if not found at all.
  34608. */
  34609. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34610. /**
  34611. * Gets a skeleton using a given auto generated unique id
  34612. * @param uniqueId defines the unique id to search for
  34613. * @return the found skeleton or null if not found at all.
  34614. */
  34615. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34616. /**
  34617. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34618. * @param id defines the id to search for
  34619. * @return the found skeleton or null if not found at all.
  34620. */
  34621. getSkeletonById(id: string): Nullable<Skeleton>;
  34622. /**
  34623. * Gets a skeleton using a given name
  34624. * @param name defines the name to search for
  34625. * @return the found skeleton or null if not found at all.
  34626. */
  34627. getSkeletonByName(name: string): Nullable<Skeleton>;
  34628. /**
  34629. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34630. * @param id defines the id to search for
  34631. * @return the found morph target manager or null if not found at all.
  34632. */
  34633. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34634. /**
  34635. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34636. * @param id defines the id to search for
  34637. * @return the found morph target or null if not found at all.
  34638. */
  34639. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34640. /**
  34641. * Gets a boolean indicating if the given mesh is active
  34642. * @param mesh defines the mesh to look for
  34643. * @returns true if the mesh is in the active list
  34644. */
  34645. isActiveMesh(mesh: AbstractMesh): boolean;
  34646. /**
  34647. * Return a unique id as a string which can serve as an identifier for the scene
  34648. */
  34649. readonly uid: string;
  34650. /**
  34651. * Add an externaly attached data from its key.
  34652. * This method call will fail and return false, if such key already exists.
  34653. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34654. * @param key the unique key that identifies the data
  34655. * @param data the data object to associate to the key for this Engine instance
  34656. * @return true if no such key were already present and the data was added successfully, false otherwise
  34657. */
  34658. addExternalData<T>(key: string, data: T): boolean;
  34659. /**
  34660. * Get an externaly attached data from its key
  34661. * @param key the unique key that identifies the data
  34662. * @return the associated data, if present (can be null), or undefined if not present
  34663. */
  34664. getExternalData<T>(key: string): Nullable<T>;
  34665. /**
  34666. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34667. * @param key the unique key that identifies the data
  34668. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34669. * @return the associated data, can be null if the factory returned null.
  34670. */
  34671. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34672. /**
  34673. * Remove an externaly attached data from the Engine instance
  34674. * @param key the unique key that identifies the data
  34675. * @return true if the data was successfully removed, false if it doesn't exist
  34676. */
  34677. removeExternalData(key: string): boolean;
  34678. private _evaluateSubMesh;
  34679. /**
  34680. * Clear the processed materials smart array preventing retention point in material dispose.
  34681. */
  34682. freeProcessedMaterials(): void;
  34683. private _preventFreeActiveMeshesAndRenderingGroups;
  34684. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34685. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34686. * when disposing several meshes in a row or a hierarchy of meshes.
  34687. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34688. */
  34689. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34690. /**
  34691. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34692. */
  34693. freeActiveMeshes(): void;
  34694. /**
  34695. * Clear the info related to rendering groups preventing retention points during dispose.
  34696. */
  34697. freeRenderingGroups(): void;
  34698. /** @hidden */
  34699. _isInIntermediateRendering(): boolean;
  34700. /**
  34701. * Lambda returning the list of potentially active meshes.
  34702. */
  34703. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34704. /**
  34705. * Lambda returning the list of potentially active sub meshes.
  34706. */
  34707. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34708. /**
  34709. * Lambda returning the list of potentially intersecting sub meshes.
  34710. */
  34711. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34712. /**
  34713. * Lambda returning the list of potentially colliding sub meshes.
  34714. */
  34715. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34716. private _activeMeshesFrozen;
  34717. /**
  34718. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34719. * @returns the current scene
  34720. */
  34721. freezeActiveMeshes(): Scene;
  34722. /**
  34723. * Use this function to restart evaluating active meshes on every frame
  34724. * @returns the current scene
  34725. */
  34726. unfreezeActiveMeshes(): Scene;
  34727. private _evaluateActiveMeshes;
  34728. private _activeMesh;
  34729. /**
  34730. * Update the transform matrix to update from the current active camera
  34731. * @param force defines a boolean used to force the update even if cache is up to date
  34732. */
  34733. updateTransformMatrix(force?: boolean): void;
  34734. private _bindFrameBuffer;
  34735. /** @hidden */
  34736. _allowPostProcessClearColor: boolean;
  34737. /** @hidden */
  34738. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34739. private _processSubCameras;
  34740. private _checkIntersections;
  34741. /** @hidden */
  34742. _advancePhysicsEngineStep(step: number): void;
  34743. /**
  34744. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34745. */
  34746. getDeterministicFrameTime: () => number;
  34747. /** @hidden */
  34748. _animate(): void;
  34749. /** Execute all animations (for a frame) */
  34750. animate(): void;
  34751. /**
  34752. * Render the scene
  34753. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34754. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34755. */
  34756. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34757. /**
  34758. * Freeze all materials
  34759. * A frozen material will not be updatable but should be faster to render
  34760. */
  34761. freezeMaterials(): void;
  34762. /**
  34763. * Unfreeze all materials
  34764. * A frozen material will not be updatable but should be faster to render
  34765. */
  34766. unfreezeMaterials(): void;
  34767. /**
  34768. * Releases all held ressources
  34769. */
  34770. dispose(): void;
  34771. /**
  34772. * Gets if the scene is already disposed
  34773. */
  34774. readonly isDisposed: boolean;
  34775. /**
  34776. * Call this function to reduce memory footprint of the scene.
  34777. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34778. */
  34779. clearCachedVertexData(): void;
  34780. /**
  34781. * This function will remove the local cached buffer data from texture.
  34782. * It will save memory but will prevent the texture from being rebuilt
  34783. */
  34784. cleanCachedTextureBuffer(): void;
  34785. /**
  34786. * Get the world extend vectors with an optional filter
  34787. *
  34788. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34789. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34790. */
  34791. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34792. min: Vector3;
  34793. max: Vector3;
  34794. };
  34795. /**
  34796. * Creates a ray that can be used to pick in the scene
  34797. * @param x defines the x coordinate of the origin (on-screen)
  34798. * @param y defines the y coordinate of the origin (on-screen)
  34799. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34800. * @param camera defines the camera to use for the picking
  34801. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34802. * @returns a Ray
  34803. */
  34804. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34805. /**
  34806. * Creates a ray that can be used to pick in the scene
  34807. * @param x defines the x coordinate of the origin (on-screen)
  34808. * @param y defines the y coordinate of the origin (on-screen)
  34809. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34810. * @param result defines the ray where to store the picking ray
  34811. * @param camera defines the camera to use for the picking
  34812. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34813. * @returns the current scene
  34814. */
  34815. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34816. /**
  34817. * Creates a ray that can be used to pick in the scene
  34818. * @param x defines the x coordinate of the origin (on-screen)
  34819. * @param y defines the y coordinate of the origin (on-screen)
  34820. * @param camera defines the camera to use for the picking
  34821. * @returns a Ray
  34822. */
  34823. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34824. /**
  34825. * Creates a ray that can be used to pick in the scene
  34826. * @param x defines the x coordinate of the origin (on-screen)
  34827. * @param y defines the y coordinate of the origin (on-screen)
  34828. * @param result defines the ray where to store the picking ray
  34829. * @param camera defines the camera to use for the picking
  34830. * @returns the current scene
  34831. */
  34832. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34833. /** Launch a ray to try to pick a mesh in the scene
  34834. * @param x position on screen
  34835. * @param y position on screen
  34836. * @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
  34837. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34838. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34839. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34840. * @returns a PickingInfo
  34841. */
  34842. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34843. /** Use the given ray to pick a mesh in the scene
  34844. * @param ray The ray to use to pick meshes
  34845. * @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
  34846. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34847. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34848. * @returns a PickingInfo
  34849. */
  34850. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34851. /**
  34852. * Launch a ray to try to pick a mesh in the scene
  34853. * @param x X position on screen
  34854. * @param y Y position on screen
  34855. * @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
  34856. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34857. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34858. * @returns an array of PickingInfo
  34859. */
  34860. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34861. /**
  34862. * Launch a ray to try to pick a mesh in the scene
  34863. * @param ray Ray to use
  34864. * @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
  34865. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34866. * @returns an array of PickingInfo
  34867. */
  34868. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34869. /**
  34870. * Force the value of meshUnderPointer
  34871. * @param mesh defines the mesh to use
  34872. */
  34873. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34874. /**
  34875. * Gets the mesh under the pointer
  34876. * @returns a Mesh or null if no mesh is under the pointer
  34877. */
  34878. getPointerOverMesh(): Nullable<AbstractMesh>;
  34879. /** @hidden */
  34880. _rebuildGeometries(): void;
  34881. /** @hidden */
  34882. _rebuildTextures(): void;
  34883. private _getByTags;
  34884. /**
  34885. * Get a list of meshes by tags
  34886. * @param tagsQuery defines the tags query to use
  34887. * @param forEach defines a predicate used to filter results
  34888. * @returns an array of Mesh
  34889. */
  34890. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34891. /**
  34892. * Get a list of cameras by tags
  34893. * @param tagsQuery defines the tags query to use
  34894. * @param forEach defines a predicate used to filter results
  34895. * @returns an array of Camera
  34896. */
  34897. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34898. /**
  34899. * Get a list of lights by tags
  34900. * @param tagsQuery defines the tags query to use
  34901. * @param forEach defines a predicate used to filter results
  34902. * @returns an array of Light
  34903. */
  34904. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34905. /**
  34906. * Get a list of materials by tags
  34907. * @param tagsQuery defines the tags query to use
  34908. * @param forEach defines a predicate used to filter results
  34909. * @returns an array of Material
  34910. */
  34911. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34912. /**
  34913. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34914. * This allowed control for front to back rendering or reversly depending of the special needs.
  34915. *
  34916. * @param renderingGroupId The rendering group id corresponding to its index
  34917. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34918. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34919. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34920. */
  34921. 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;
  34922. /**
  34923. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34924. *
  34925. * @param renderingGroupId The rendering group id corresponding to its index
  34926. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34927. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34928. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34929. */
  34930. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34931. /**
  34932. * Gets the current auto clear configuration for one rendering group of the rendering
  34933. * manager.
  34934. * @param index the rendering group index to get the information for
  34935. * @returns The auto clear setup for the requested rendering group
  34936. */
  34937. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34938. private _blockMaterialDirtyMechanism;
  34939. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34940. blockMaterialDirtyMechanism: boolean;
  34941. /**
  34942. * Will flag all materials as dirty to trigger new shader compilation
  34943. * @param flag defines the flag used to specify which material part must be marked as dirty
  34944. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34945. */
  34946. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34947. /** @hidden */
  34948. _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;
  34949. /** @hidden */
  34950. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34951. }
  34952. }
  34953. declare module "babylonjs/assetContainer" {
  34954. import { AbstractScene } from "babylonjs/abstractScene";
  34955. import { Scene } from "babylonjs/scene";
  34956. import { Mesh } from "babylonjs/Meshes/mesh";
  34957. /**
  34958. * Set of assets to keep when moving a scene into an asset container.
  34959. */
  34960. export class KeepAssets extends AbstractScene {
  34961. }
  34962. /**
  34963. * Container with a set of assets that can be added or removed from a scene.
  34964. */
  34965. export class AssetContainer extends AbstractScene {
  34966. /**
  34967. * The scene the AssetContainer belongs to.
  34968. */
  34969. scene: Scene;
  34970. /**
  34971. * Instantiates an AssetContainer.
  34972. * @param scene The scene the AssetContainer belongs to.
  34973. */
  34974. constructor(scene: Scene);
  34975. /**
  34976. * Adds all the assets from the container to the scene.
  34977. */
  34978. addAllToScene(): void;
  34979. /**
  34980. * Removes all the assets in the container from the scene
  34981. */
  34982. removeAllFromScene(): void;
  34983. /**
  34984. * Disposes all the assets in the container
  34985. */
  34986. dispose(): void;
  34987. private _moveAssets;
  34988. /**
  34989. * Removes all the assets contained in the scene and adds them to the container.
  34990. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34991. */
  34992. moveAllFromScene(keepAssets?: KeepAssets): void;
  34993. /**
  34994. * 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.
  34995. * @returns the root mesh
  34996. */
  34997. createRootMesh(): Mesh;
  34998. }
  34999. }
  35000. declare module "babylonjs/abstractScene" {
  35001. import { Scene } from "babylonjs/scene";
  35002. import { Nullable } from "babylonjs/types";
  35003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35004. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35005. import { Geometry } from "babylonjs/Meshes/geometry";
  35006. import { Skeleton } from "babylonjs/Bones/skeleton";
  35007. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35008. import { AssetContainer } from "babylonjs/assetContainer";
  35009. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35010. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35011. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35012. import { Material } from "babylonjs/Materials/material";
  35013. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35014. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35015. import { Camera } from "babylonjs/Cameras/camera";
  35016. import { Light } from "babylonjs/Lights/light";
  35017. import { Node } from "babylonjs/node";
  35018. import { Animation } from "babylonjs/Animations/animation";
  35019. /**
  35020. * Defines how the parser contract is defined.
  35021. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35022. */
  35023. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35024. /**
  35025. * Defines how the individual parser contract is defined.
  35026. * These parser can parse an individual asset
  35027. */
  35028. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35029. /**
  35030. * Base class of the scene acting as a container for the different elements composing a scene.
  35031. * This class is dynamically extended by the different components of the scene increasing
  35032. * flexibility and reducing coupling
  35033. */
  35034. export abstract class AbstractScene {
  35035. /**
  35036. * Stores the list of available parsers in the application.
  35037. */
  35038. private static _BabylonFileParsers;
  35039. /**
  35040. * Stores the list of available individual parsers in the application.
  35041. */
  35042. private static _IndividualBabylonFileParsers;
  35043. /**
  35044. * Adds a parser in the list of available ones
  35045. * @param name Defines the name of the parser
  35046. * @param parser Defines the parser to add
  35047. */
  35048. static AddParser(name: string, parser: BabylonFileParser): void;
  35049. /**
  35050. * Gets a general parser from the list of avaialble ones
  35051. * @param name Defines the name of the parser
  35052. * @returns the requested parser or null
  35053. */
  35054. static GetParser(name: string): Nullable<BabylonFileParser>;
  35055. /**
  35056. * Adds n individual parser in the list of available ones
  35057. * @param name Defines the name of the parser
  35058. * @param parser Defines the parser to add
  35059. */
  35060. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35061. /**
  35062. * Gets an individual parser from the list of avaialble ones
  35063. * @param name Defines the name of the parser
  35064. * @returns the requested parser or null
  35065. */
  35066. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35067. /**
  35068. * Parser json data and populate both a scene and its associated container object
  35069. * @param jsonData Defines the data to parse
  35070. * @param scene Defines the scene to parse the data for
  35071. * @param container Defines the container attached to the parsing sequence
  35072. * @param rootUrl Defines the root url of the data
  35073. */
  35074. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35075. /**
  35076. * Gets the list of root nodes (ie. nodes with no parent)
  35077. */
  35078. rootNodes: Node[];
  35079. /** All of the cameras added to this scene
  35080. * @see http://doc.babylonjs.com/babylon101/cameras
  35081. */
  35082. cameras: Camera[];
  35083. /**
  35084. * All of the lights added to this scene
  35085. * @see http://doc.babylonjs.com/babylon101/lights
  35086. */
  35087. lights: Light[];
  35088. /**
  35089. * All of the (abstract) meshes added to this scene
  35090. */
  35091. meshes: AbstractMesh[];
  35092. /**
  35093. * The list of skeletons added to the scene
  35094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35095. */
  35096. skeletons: Skeleton[];
  35097. /**
  35098. * All of the particle systems added to this scene
  35099. * @see http://doc.babylonjs.com/babylon101/particles
  35100. */
  35101. particleSystems: IParticleSystem[];
  35102. /**
  35103. * Gets a list of Animations associated with the scene
  35104. */
  35105. animations: Animation[];
  35106. /**
  35107. * All of the animation groups added to this scene
  35108. * @see http://doc.babylonjs.com/how_to/group
  35109. */
  35110. animationGroups: AnimationGroup[];
  35111. /**
  35112. * All of the multi-materials added to this scene
  35113. * @see http://doc.babylonjs.com/how_to/multi_materials
  35114. */
  35115. multiMaterials: MultiMaterial[];
  35116. /**
  35117. * All of the materials added to this scene
  35118. * In the context of a Scene, it is not supposed to be modified manually.
  35119. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35120. * Note also that the order of the Material wihin the array is not significant and might change.
  35121. * @see http://doc.babylonjs.com/babylon101/materials
  35122. */
  35123. materials: Material[];
  35124. /**
  35125. * The list of morph target managers added to the scene
  35126. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35127. */
  35128. morphTargetManagers: MorphTargetManager[];
  35129. /**
  35130. * The list of geometries used in the scene.
  35131. */
  35132. geometries: Geometry[];
  35133. /**
  35134. * All of the tranform nodes added to this scene
  35135. * In the context of a Scene, it is not supposed to be modified manually.
  35136. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35137. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35138. * @see http://doc.babylonjs.com/how_to/transformnode
  35139. */
  35140. transformNodes: TransformNode[];
  35141. /**
  35142. * ActionManagers available on the scene.
  35143. */
  35144. actionManagers: AbstractActionManager[];
  35145. /**
  35146. * Textures to keep.
  35147. */
  35148. textures: BaseTexture[];
  35149. /**
  35150. * Environment texture for the scene
  35151. */
  35152. environmentTexture: Nullable<BaseTexture>;
  35153. }
  35154. }
  35155. declare module "babylonjs/Audio/sound" {
  35156. import { Observable } from "babylonjs/Misc/observable";
  35157. import { Vector3 } from "babylonjs/Maths/math";
  35158. import { Nullable } from "babylonjs/types";
  35159. import { Scene } from "babylonjs/scene";
  35160. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35161. /**
  35162. * Interface used to define options for Sound class
  35163. */
  35164. export interface ISoundOptions {
  35165. /**
  35166. * Does the sound autoplay once loaded.
  35167. */
  35168. autoplay?: boolean;
  35169. /**
  35170. * Does the sound loop after it finishes playing once.
  35171. */
  35172. loop?: boolean;
  35173. /**
  35174. * Sound's volume
  35175. */
  35176. volume?: number;
  35177. /**
  35178. * Is it a spatial sound?
  35179. */
  35180. spatialSound?: boolean;
  35181. /**
  35182. * Maximum distance to hear that sound
  35183. */
  35184. maxDistance?: number;
  35185. /**
  35186. * Uses user defined attenuation function
  35187. */
  35188. useCustomAttenuation?: boolean;
  35189. /**
  35190. * Define the roll off factor of spatial sounds.
  35191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35192. */
  35193. rolloffFactor?: number;
  35194. /**
  35195. * Define the reference distance the sound should be heard perfectly.
  35196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35197. */
  35198. refDistance?: number;
  35199. /**
  35200. * Define the distance attenuation model the sound will follow.
  35201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35202. */
  35203. distanceModel?: string;
  35204. /**
  35205. * Defines the playback speed (1 by default)
  35206. */
  35207. playbackRate?: number;
  35208. /**
  35209. * Defines if the sound is from a streaming source
  35210. */
  35211. streaming?: boolean;
  35212. /**
  35213. * Defines an optional length (in seconds) inside the sound file
  35214. */
  35215. length?: number;
  35216. /**
  35217. * Defines an optional offset (in seconds) inside the sound file
  35218. */
  35219. offset?: number;
  35220. /**
  35221. * If true, URLs will not be required to state the audio file codec to use.
  35222. */
  35223. skipCodecCheck?: boolean;
  35224. }
  35225. /**
  35226. * Defines a sound that can be played in the application.
  35227. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35229. */
  35230. export class Sound {
  35231. /**
  35232. * The name of the sound in the scene.
  35233. */
  35234. name: string;
  35235. /**
  35236. * Does the sound autoplay once loaded.
  35237. */
  35238. autoplay: boolean;
  35239. /**
  35240. * Does the sound loop after it finishes playing once.
  35241. */
  35242. loop: boolean;
  35243. /**
  35244. * Does the sound use a custom attenuation curve to simulate the falloff
  35245. * happening when the source gets further away from the camera.
  35246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35247. */
  35248. useCustomAttenuation: boolean;
  35249. /**
  35250. * The sound track id this sound belongs to.
  35251. */
  35252. soundTrackId: number;
  35253. /**
  35254. * Is this sound currently played.
  35255. */
  35256. isPlaying: boolean;
  35257. /**
  35258. * Is this sound currently paused.
  35259. */
  35260. isPaused: boolean;
  35261. /**
  35262. * Does this sound enables spatial sound.
  35263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35264. */
  35265. spatialSound: boolean;
  35266. /**
  35267. * Define the reference distance the sound should be heard perfectly.
  35268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35269. */
  35270. refDistance: number;
  35271. /**
  35272. * Define the roll off factor of spatial sounds.
  35273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35274. */
  35275. rolloffFactor: number;
  35276. /**
  35277. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35279. */
  35280. maxDistance: number;
  35281. /**
  35282. * Define the distance attenuation model the sound will follow.
  35283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35284. */
  35285. distanceModel: string;
  35286. /**
  35287. * @hidden
  35288. * Back Compat
  35289. **/
  35290. onended: () => any;
  35291. /**
  35292. * Observable event when the current playing sound finishes.
  35293. */
  35294. onEndedObservable: Observable<Sound>;
  35295. private _panningModel;
  35296. private _playbackRate;
  35297. private _streaming;
  35298. private _startTime;
  35299. private _startOffset;
  35300. private _position;
  35301. /** @hidden */
  35302. _positionInEmitterSpace: boolean;
  35303. private _localDirection;
  35304. private _volume;
  35305. private _isReadyToPlay;
  35306. private _isDirectional;
  35307. private _readyToPlayCallback;
  35308. private _audioBuffer;
  35309. private _soundSource;
  35310. private _streamingSource;
  35311. private _soundPanner;
  35312. private _soundGain;
  35313. private _inputAudioNode;
  35314. private _outputAudioNode;
  35315. private _coneInnerAngle;
  35316. private _coneOuterAngle;
  35317. private _coneOuterGain;
  35318. private _scene;
  35319. private _connectedTransformNode;
  35320. private _customAttenuationFunction;
  35321. private _registerFunc;
  35322. private _isOutputConnected;
  35323. private _htmlAudioElement;
  35324. private _urlType;
  35325. private _length?;
  35326. private _offset?;
  35327. /** @hidden */
  35328. static _SceneComponentInitialization: (scene: Scene) => void;
  35329. /**
  35330. * Create a sound and attach it to a scene
  35331. * @param name Name of your sound
  35332. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35333. * @param scene defines the scene the sound belongs to
  35334. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35335. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35336. */
  35337. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35338. /**
  35339. * Release the sound and its associated resources
  35340. */
  35341. dispose(): void;
  35342. /**
  35343. * Gets if the sounds is ready to be played or not.
  35344. * @returns true if ready, otherwise false
  35345. */
  35346. isReady(): boolean;
  35347. private _soundLoaded;
  35348. /**
  35349. * Sets the data of the sound from an audiobuffer
  35350. * @param audioBuffer The audioBuffer containing the data
  35351. */
  35352. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35353. /**
  35354. * Updates the current sounds options such as maxdistance, loop...
  35355. * @param options A JSON object containing values named as the object properties
  35356. */
  35357. updateOptions(options: ISoundOptions): void;
  35358. private _createSpatialParameters;
  35359. private _updateSpatialParameters;
  35360. /**
  35361. * Switch the panning model to HRTF:
  35362. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35364. */
  35365. switchPanningModelToHRTF(): void;
  35366. /**
  35367. * Switch the panning model to Equal Power:
  35368. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35370. */
  35371. switchPanningModelToEqualPower(): void;
  35372. private _switchPanningModel;
  35373. /**
  35374. * Connect this sound to a sound track audio node like gain...
  35375. * @param soundTrackAudioNode the sound track audio node to connect to
  35376. */
  35377. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35378. /**
  35379. * Transform this sound into a directional source
  35380. * @param coneInnerAngle Size of the inner cone in degree
  35381. * @param coneOuterAngle Size of the outer cone in degree
  35382. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35383. */
  35384. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35385. /**
  35386. * Gets or sets the inner angle for the directional cone.
  35387. */
  35388. /**
  35389. * Gets or sets the inner angle for the directional cone.
  35390. */
  35391. directionalConeInnerAngle: number;
  35392. /**
  35393. * Gets or sets the outer angle for the directional cone.
  35394. */
  35395. /**
  35396. * Gets or sets the outer angle for the directional cone.
  35397. */
  35398. directionalConeOuterAngle: number;
  35399. /**
  35400. * Sets the position of the emitter if spatial sound is enabled
  35401. * @param newPosition Defines the new posisiton
  35402. */
  35403. setPosition(newPosition: Vector3): void;
  35404. /**
  35405. * Sets the local direction of the emitter if spatial sound is enabled
  35406. * @param newLocalDirection Defines the new local direction
  35407. */
  35408. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35409. private _updateDirection;
  35410. /** @hidden */
  35411. updateDistanceFromListener(): void;
  35412. /**
  35413. * Sets a new custom attenuation function for the sound.
  35414. * @param callback Defines the function used for the attenuation
  35415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35416. */
  35417. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35418. /**
  35419. * Play the sound
  35420. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35421. * @param offset (optional) Start the sound at a specific time in seconds
  35422. * @param length (optional) Sound duration (in seconds)
  35423. */
  35424. play(time?: number, offset?: number, length?: number): void;
  35425. private _onended;
  35426. /**
  35427. * Stop the sound
  35428. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35429. */
  35430. stop(time?: number): void;
  35431. /**
  35432. * Put the sound in pause
  35433. */
  35434. pause(): void;
  35435. /**
  35436. * Sets a dedicated volume for this sounds
  35437. * @param newVolume Define the new volume of the sound
  35438. * @param time Define time for gradual change to new volume
  35439. */
  35440. setVolume(newVolume: number, time?: number): void;
  35441. /**
  35442. * Set the sound play back rate
  35443. * @param newPlaybackRate Define the playback rate the sound should be played at
  35444. */
  35445. setPlaybackRate(newPlaybackRate: number): void;
  35446. /**
  35447. * Gets the volume of the sound.
  35448. * @returns the volume of the sound
  35449. */
  35450. getVolume(): number;
  35451. /**
  35452. * Attach the sound to a dedicated mesh
  35453. * @param transformNode The transform node to connect the sound with
  35454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35455. */
  35456. attachToMesh(transformNode: TransformNode): void;
  35457. /**
  35458. * Detach the sound from the previously attached mesh
  35459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35460. */
  35461. detachFromMesh(): void;
  35462. private _onRegisterAfterWorldMatrixUpdate;
  35463. /**
  35464. * Clone the current sound in the scene.
  35465. * @returns the new sound clone
  35466. */
  35467. clone(): Nullable<Sound>;
  35468. /**
  35469. * Gets the current underlying audio buffer containing the data
  35470. * @returns the audio buffer
  35471. */
  35472. getAudioBuffer(): Nullable<AudioBuffer>;
  35473. /**
  35474. * Serializes the Sound in a JSON representation
  35475. * @returns the JSON representation of the sound
  35476. */
  35477. serialize(): any;
  35478. /**
  35479. * Parse a JSON representation of a sound to innstantiate in a given scene
  35480. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35481. * @param scene Define the scene the new parsed sound should be created in
  35482. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35483. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35484. * @returns the newly parsed sound
  35485. */
  35486. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35487. }
  35488. }
  35489. declare module "babylonjs/Actions/directAudioActions" {
  35490. import { Action } from "babylonjs/Actions/action";
  35491. import { Condition } from "babylonjs/Actions/condition";
  35492. import { Sound } from "babylonjs/Audio/sound";
  35493. /**
  35494. * This defines an action helpful to play a defined sound on a triggered action.
  35495. */
  35496. export class PlaySoundAction extends Action {
  35497. private _sound;
  35498. /**
  35499. * Instantiate the action
  35500. * @param triggerOptions defines the trigger options
  35501. * @param sound defines the sound to play
  35502. * @param condition defines the trigger related conditions
  35503. */
  35504. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35505. /** @hidden */
  35506. _prepare(): void;
  35507. /**
  35508. * Execute the action and play the sound.
  35509. */
  35510. execute(): void;
  35511. /**
  35512. * Serializes the actions and its related information.
  35513. * @param parent defines the object to serialize in
  35514. * @returns the serialized object
  35515. */
  35516. serialize(parent: any): any;
  35517. }
  35518. /**
  35519. * This defines an action helpful to stop a defined sound on a triggered action.
  35520. */
  35521. export class StopSoundAction extends Action {
  35522. private _sound;
  35523. /**
  35524. * Instantiate the action
  35525. * @param triggerOptions defines the trigger options
  35526. * @param sound defines the sound to stop
  35527. * @param condition defines the trigger related conditions
  35528. */
  35529. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35530. /** @hidden */
  35531. _prepare(): void;
  35532. /**
  35533. * Execute the action and stop the sound.
  35534. */
  35535. execute(): void;
  35536. /**
  35537. * Serializes the actions and its related information.
  35538. * @param parent defines the object to serialize in
  35539. * @returns the serialized object
  35540. */
  35541. serialize(parent: any): any;
  35542. }
  35543. }
  35544. declare module "babylonjs/Actions/interpolateValueAction" {
  35545. import { Action } from "babylonjs/Actions/action";
  35546. import { Condition } from "babylonjs/Actions/condition";
  35547. import { Observable } from "babylonjs/Misc/observable";
  35548. /**
  35549. * This defines an action responsible to change the value of a property
  35550. * by interpolating between its current value and the newly set one once triggered.
  35551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35552. */
  35553. export class InterpolateValueAction extends Action {
  35554. /**
  35555. * Defines the path of the property where the value should be interpolated
  35556. */
  35557. propertyPath: string;
  35558. /**
  35559. * Defines the target value at the end of the interpolation.
  35560. */
  35561. value: any;
  35562. /**
  35563. * Defines the time it will take for the property to interpolate to the value.
  35564. */
  35565. duration: number;
  35566. /**
  35567. * Defines if the other scene animations should be stopped when the action has been triggered
  35568. */
  35569. stopOtherAnimations?: boolean;
  35570. /**
  35571. * Defines a callback raised once the interpolation animation has been done.
  35572. */
  35573. onInterpolationDone?: () => void;
  35574. /**
  35575. * Observable triggered once the interpolation animation has been done.
  35576. */
  35577. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35578. private _target;
  35579. private _effectiveTarget;
  35580. private _property;
  35581. /**
  35582. * Instantiate the action
  35583. * @param triggerOptions defines the trigger options
  35584. * @param target defines the object containing the value to interpolate
  35585. * @param propertyPath defines the path to the property in the target object
  35586. * @param value defines the target value at the end of the interpolation
  35587. * @param duration deines the time it will take for the property to interpolate to the value.
  35588. * @param condition defines the trigger related conditions
  35589. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35590. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35591. */
  35592. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35593. /** @hidden */
  35594. _prepare(): void;
  35595. /**
  35596. * Execute the action starts the value interpolation.
  35597. */
  35598. execute(): void;
  35599. /**
  35600. * Serializes the actions and its related information.
  35601. * @param parent defines the object to serialize in
  35602. * @returns the serialized object
  35603. */
  35604. serialize(parent: any): any;
  35605. }
  35606. }
  35607. declare module "babylonjs/Actions/index" {
  35608. export * from "babylonjs/Actions/action";
  35609. export * from "babylonjs/Actions/actionEvent";
  35610. export * from "babylonjs/Actions/actionManager";
  35611. export * from "babylonjs/Actions/condition";
  35612. export * from "babylonjs/Actions/directActions";
  35613. export * from "babylonjs/Actions/directAudioActions";
  35614. export * from "babylonjs/Actions/interpolateValueAction";
  35615. }
  35616. declare module "babylonjs/Animations/index" {
  35617. export * from "babylonjs/Animations/animatable";
  35618. export * from "babylonjs/Animations/animation";
  35619. export * from "babylonjs/Animations/animationGroup";
  35620. export * from "babylonjs/Animations/animationPropertiesOverride";
  35621. export * from "babylonjs/Animations/easing";
  35622. export * from "babylonjs/Animations/runtimeAnimation";
  35623. export * from "babylonjs/Animations/animationEvent";
  35624. export * from "babylonjs/Animations/animationGroup";
  35625. export * from "babylonjs/Animations/animationKey";
  35626. export * from "babylonjs/Animations/animationRange";
  35627. }
  35628. declare module "babylonjs/Audio/soundTrack" {
  35629. import { Sound } from "babylonjs/Audio/sound";
  35630. import { Analyser } from "babylonjs/Audio/analyser";
  35631. import { Scene } from "babylonjs/scene";
  35632. /**
  35633. * Options allowed during the creation of a sound track.
  35634. */
  35635. export interface ISoundTrackOptions {
  35636. /**
  35637. * The volume the sound track should take during creation
  35638. */
  35639. volume?: number;
  35640. /**
  35641. * Define if the sound track is the main sound track of the scene
  35642. */
  35643. mainTrack?: boolean;
  35644. }
  35645. /**
  35646. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35647. * It will be also used in a future release to apply effects on a specific track.
  35648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35649. */
  35650. export class SoundTrack {
  35651. /**
  35652. * The unique identifier of the sound track in the scene.
  35653. */
  35654. id: number;
  35655. /**
  35656. * The list of sounds included in the sound track.
  35657. */
  35658. soundCollection: Array<Sound>;
  35659. private _outputAudioNode;
  35660. private _scene;
  35661. private _isMainTrack;
  35662. private _connectedAnalyser;
  35663. private _options;
  35664. private _isInitialized;
  35665. /**
  35666. * Creates a new sound track.
  35667. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35668. * @param scene Define the scene the sound track belongs to
  35669. * @param options
  35670. */
  35671. constructor(scene: Scene, options?: ISoundTrackOptions);
  35672. private _initializeSoundTrackAudioGraph;
  35673. /**
  35674. * Release the sound track and its associated resources
  35675. */
  35676. dispose(): void;
  35677. /**
  35678. * Adds a sound to this sound track
  35679. * @param sound define the cound to add
  35680. * @ignoreNaming
  35681. */
  35682. AddSound(sound: Sound): void;
  35683. /**
  35684. * Removes a sound to this sound track
  35685. * @param sound define the cound to remove
  35686. * @ignoreNaming
  35687. */
  35688. RemoveSound(sound: Sound): void;
  35689. /**
  35690. * Set a global volume for the full sound track.
  35691. * @param newVolume Define the new volume of the sound track
  35692. */
  35693. setVolume(newVolume: number): void;
  35694. /**
  35695. * Switch the panning model to HRTF:
  35696. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35698. */
  35699. switchPanningModelToHRTF(): void;
  35700. /**
  35701. * Switch the panning model to Equal Power:
  35702. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35704. */
  35705. switchPanningModelToEqualPower(): void;
  35706. /**
  35707. * Connect the sound track to an audio analyser allowing some amazing
  35708. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35710. * @param analyser The analyser to connect to the engine
  35711. */
  35712. connectToAnalyser(analyser: Analyser): void;
  35713. }
  35714. }
  35715. declare module "babylonjs/Audio/audioSceneComponent" {
  35716. import { Sound } from "babylonjs/Audio/sound";
  35717. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35718. import { Nullable } from "babylonjs/types";
  35719. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35720. import { Scene } from "babylonjs/scene";
  35721. import { AbstractScene } from "babylonjs/abstractScene";
  35722. module "babylonjs/abstractScene" {
  35723. interface AbstractScene {
  35724. /**
  35725. * The list of sounds used in the scene.
  35726. */
  35727. sounds: Nullable<Array<Sound>>;
  35728. }
  35729. }
  35730. module "babylonjs/scene" {
  35731. interface Scene {
  35732. /**
  35733. * @hidden
  35734. * Backing field
  35735. */
  35736. _mainSoundTrack: SoundTrack;
  35737. /**
  35738. * The main sound track played by the scene.
  35739. * It cotains your primary collection of sounds.
  35740. */
  35741. mainSoundTrack: SoundTrack;
  35742. /**
  35743. * The list of sound tracks added to the scene
  35744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35745. */
  35746. soundTracks: Nullable<Array<SoundTrack>>;
  35747. /**
  35748. * Gets a sound using a given name
  35749. * @param name defines the name to search for
  35750. * @return the found sound or null if not found at all.
  35751. */
  35752. getSoundByName(name: string): Nullable<Sound>;
  35753. /**
  35754. * Gets or sets if audio support is enabled
  35755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35756. */
  35757. audioEnabled: boolean;
  35758. /**
  35759. * Gets or sets if audio will be output to headphones
  35760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35761. */
  35762. headphone: boolean;
  35763. }
  35764. }
  35765. /**
  35766. * Defines the sound scene component responsible to manage any sounds
  35767. * in a given scene.
  35768. */
  35769. export class AudioSceneComponent implements ISceneSerializableComponent {
  35770. /**
  35771. * The component name helpfull to identify the component in the list of scene components.
  35772. */
  35773. readonly name: string;
  35774. /**
  35775. * The scene the component belongs to.
  35776. */
  35777. scene: Scene;
  35778. private _audioEnabled;
  35779. /**
  35780. * Gets whether audio is enabled or not.
  35781. * Please use related enable/disable method to switch state.
  35782. */
  35783. readonly audioEnabled: boolean;
  35784. private _headphone;
  35785. /**
  35786. * Gets whether audio is outputing to headphone or not.
  35787. * Please use the according Switch methods to change output.
  35788. */
  35789. readonly headphone: boolean;
  35790. /**
  35791. * Creates a new instance of the component for the given scene
  35792. * @param scene Defines the scene to register the component in
  35793. */
  35794. constructor(scene: Scene);
  35795. /**
  35796. * Registers the component in a given scene
  35797. */
  35798. register(): void;
  35799. /**
  35800. * Rebuilds the elements related to this component in case of
  35801. * context lost for instance.
  35802. */
  35803. rebuild(): void;
  35804. /**
  35805. * Serializes the component data to the specified json object
  35806. * @param serializationObject The object to serialize to
  35807. */
  35808. serialize(serializationObject: any): void;
  35809. /**
  35810. * Adds all the elements from the container to the scene
  35811. * @param container the container holding the elements
  35812. */
  35813. addFromContainer(container: AbstractScene): void;
  35814. /**
  35815. * Removes all the elements in the container from the scene
  35816. * @param container contains the elements to remove
  35817. * @param dispose if the removed element should be disposed (default: false)
  35818. */
  35819. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35820. /**
  35821. * Disposes the component and the associated ressources.
  35822. */
  35823. dispose(): void;
  35824. /**
  35825. * Disables audio in the associated scene.
  35826. */
  35827. disableAudio(): void;
  35828. /**
  35829. * Enables audio in the associated scene.
  35830. */
  35831. enableAudio(): void;
  35832. /**
  35833. * Switch audio to headphone output.
  35834. */
  35835. switchAudioModeForHeadphones(): void;
  35836. /**
  35837. * Switch audio to normal speakers.
  35838. */
  35839. switchAudioModeForNormalSpeakers(): void;
  35840. private _afterRender;
  35841. }
  35842. }
  35843. declare module "babylonjs/Audio/weightedsound" {
  35844. import { Sound } from "babylonjs/Audio/sound";
  35845. /**
  35846. * Wraps one or more Sound objects and selects one with random weight for playback.
  35847. */
  35848. export class WeightedSound {
  35849. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35850. loop: boolean;
  35851. private _coneInnerAngle;
  35852. private _coneOuterAngle;
  35853. private _volume;
  35854. /** A Sound is currently playing. */
  35855. isPlaying: boolean;
  35856. /** A Sound is currently paused. */
  35857. isPaused: boolean;
  35858. private _sounds;
  35859. private _weights;
  35860. private _currentIndex?;
  35861. /**
  35862. * Creates a new WeightedSound from the list of sounds given.
  35863. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35864. * @param sounds Array of Sounds that will be selected from.
  35865. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35866. */
  35867. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35868. /**
  35869. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35870. */
  35871. /**
  35872. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35873. */
  35874. directionalConeInnerAngle: number;
  35875. /**
  35876. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35877. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35878. */
  35879. /**
  35880. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35881. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35882. */
  35883. directionalConeOuterAngle: number;
  35884. /**
  35885. * Playback volume.
  35886. */
  35887. /**
  35888. * Playback volume.
  35889. */
  35890. volume: number;
  35891. private _onended;
  35892. /**
  35893. * Suspend playback
  35894. */
  35895. pause(): void;
  35896. /**
  35897. * Stop playback
  35898. */
  35899. stop(): void;
  35900. /**
  35901. * Start playback.
  35902. * @param startOffset Position the clip head at a specific time in seconds.
  35903. */
  35904. play(startOffset?: number): void;
  35905. }
  35906. }
  35907. declare module "babylonjs/Audio/index" {
  35908. export * from "babylonjs/Audio/analyser";
  35909. export * from "babylonjs/Audio/audioEngine";
  35910. export * from "babylonjs/Audio/audioSceneComponent";
  35911. export * from "babylonjs/Audio/sound";
  35912. export * from "babylonjs/Audio/soundTrack";
  35913. export * from "babylonjs/Audio/weightedsound";
  35914. }
  35915. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35916. import { Behavior } from "babylonjs/Behaviors/behavior";
  35917. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35918. import { BackEase } from "babylonjs/Animations/easing";
  35919. /**
  35920. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35921. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35922. */
  35923. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35924. /**
  35925. * Gets the name of the behavior.
  35926. */
  35927. readonly name: string;
  35928. /**
  35929. * The easing function used by animations
  35930. */
  35931. static EasingFunction: BackEase;
  35932. /**
  35933. * The easing mode used by animations
  35934. */
  35935. static EasingMode: number;
  35936. /**
  35937. * The duration of the animation, in milliseconds
  35938. */
  35939. transitionDuration: number;
  35940. /**
  35941. * Length of the distance animated by the transition when lower radius is reached
  35942. */
  35943. lowerRadiusTransitionRange: number;
  35944. /**
  35945. * Length of the distance animated by the transition when upper radius is reached
  35946. */
  35947. upperRadiusTransitionRange: number;
  35948. private _autoTransitionRange;
  35949. /**
  35950. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35951. */
  35952. /**
  35953. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35954. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35955. */
  35956. autoTransitionRange: boolean;
  35957. private _attachedCamera;
  35958. private _onAfterCheckInputsObserver;
  35959. private _onMeshTargetChangedObserver;
  35960. /**
  35961. * Initializes the behavior.
  35962. */
  35963. init(): void;
  35964. /**
  35965. * Attaches the behavior to its arc rotate camera.
  35966. * @param camera Defines the camera to attach the behavior to
  35967. */
  35968. attach(camera: ArcRotateCamera): void;
  35969. /**
  35970. * Detaches the behavior from its current arc rotate camera.
  35971. */
  35972. detach(): void;
  35973. private _radiusIsAnimating;
  35974. private _radiusBounceTransition;
  35975. private _animatables;
  35976. private _cachedWheelPrecision;
  35977. /**
  35978. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35979. * @param radiusLimit The limit to check against.
  35980. * @return Bool to indicate if at limit.
  35981. */
  35982. private _isRadiusAtLimit;
  35983. /**
  35984. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35985. * @param radiusDelta The delta by which to animate to. Can be negative.
  35986. */
  35987. private _applyBoundRadiusAnimation;
  35988. /**
  35989. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35990. */
  35991. protected _clearAnimationLocks(): void;
  35992. /**
  35993. * Stops and removes all animations that have been applied to the camera
  35994. */
  35995. stopAllAnimations(): void;
  35996. }
  35997. }
  35998. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35999. import { Behavior } from "babylonjs/Behaviors/behavior";
  36000. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36001. import { ExponentialEase } from "babylonjs/Animations/easing";
  36002. import { Nullable } from "babylonjs/types";
  36003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36004. import { Vector3 } from "babylonjs/Maths/math";
  36005. /**
  36006. * 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.
  36007. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36008. */
  36009. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36010. /**
  36011. * Gets the name of the behavior.
  36012. */
  36013. readonly name: string;
  36014. private _mode;
  36015. private _radiusScale;
  36016. private _positionScale;
  36017. private _defaultElevation;
  36018. private _elevationReturnTime;
  36019. private _elevationReturnWaitTime;
  36020. private _zoomStopsAnimation;
  36021. private _framingTime;
  36022. /**
  36023. * The easing function used by animations
  36024. */
  36025. static EasingFunction: ExponentialEase;
  36026. /**
  36027. * The easing mode used by animations
  36028. */
  36029. static EasingMode: number;
  36030. /**
  36031. * Sets the current mode used by the behavior
  36032. */
  36033. /**
  36034. * Gets current mode used by the behavior.
  36035. */
  36036. mode: number;
  36037. /**
  36038. * Sets the scale applied to the radius (1 by default)
  36039. */
  36040. /**
  36041. * Gets the scale applied to the radius
  36042. */
  36043. radiusScale: number;
  36044. /**
  36045. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36046. */
  36047. /**
  36048. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36049. */
  36050. positionScale: number;
  36051. /**
  36052. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36053. * behaviour is triggered, in radians.
  36054. */
  36055. /**
  36056. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36057. * behaviour is triggered, in radians.
  36058. */
  36059. defaultElevation: number;
  36060. /**
  36061. * Sets the time (in milliseconds) taken to return to the default beta position.
  36062. * Negative value indicates camera should not return to default.
  36063. */
  36064. /**
  36065. * Gets the time (in milliseconds) taken to return to the default beta position.
  36066. * Negative value indicates camera should not return to default.
  36067. */
  36068. elevationReturnTime: number;
  36069. /**
  36070. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36071. */
  36072. /**
  36073. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36074. */
  36075. elevationReturnWaitTime: number;
  36076. /**
  36077. * Sets the flag that indicates if user zooming should stop animation.
  36078. */
  36079. /**
  36080. * Gets the flag that indicates if user zooming should stop animation.
  36081. */
  36082. zoomStopsAnimation: boolean;
  36083. /**
  36084. * Sets the transition time when framing the mesh, in milliseconds
  36085. */
  36086. /**
  36087. * Gets the transition time when framing the mesh, in milliseconds
  36088. */
  36089. framingTime: number;
  36090. /**
  36091. * Define if the behavior should automatically change the configured
  36092. * camera limits and sensibilities.
  36093. */
  36094. autoCorrectCameraLimitsAndSensibility: boolean;
  36095. private _onPrePointerObservableObserver;
  36096. private _onAfterCheckInputsObserver;
  36097. private _onMeshTargetChangedObserver;
  36098. private _attachedCamera;
  36099. private _isPointerDown;
  36100. private _lastInteractionTime;
  36101. /**
  36102. * Initializes the behavior.
  36103. */
  36104. init(): void;
  36105. /**
  36106. * Attaches the behavior to its arc rotate camera.
  36107. * @param camera Defines the camera to attach the behavior to
  36108. */
  36109. attach(camera: ArcRotateCamera): void;
  36110. /**
  36111. * Detaches the behavior from its current arc rotate camera.
  36112. */
  36113. detach(): void;
  36114. private _animatables;
  36115. private _betaIsAnimating;
  36116. private _betaTransition;
  36117. private _radiusTransition;
  36118. private _vectorTransition;
  36119. /**
  36120. * Targets the given mesh and updates zoom level accordingly.
  36121. * @param mesh The mesh to target.
  36122. * @param radius Optional. If a cached radius position already exists, overrides default.
  36123. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36124. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36125. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36126. */
  36127. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36128. /**
  36129. * Targets the given mesh with its children and updates zoom level accordingly.
  36130. * @param mesh The mesh to target.
  36131. * @param radius Optional. If a cached radius position already exists, overrides default.
  36132. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36133. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36134. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36135. */
  36136. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36137. /**
  36138. * Targets the given meshes with their children and updates zoom level accordingly.
  36139. * @param meshes The mesh to target.
  36140. * @param radius Optional. If a cached radius position already exists, overrides default.
  36141. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36142. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36143. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36144. */
  36145. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36146. /**
  36147. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36148. * @param minimumWorld Determines the smaller position of the bounding box extend
  36149. * @param maximumWorld Determines the bigger position of the bounding box extend
  36150. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36151. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36152. */
  36153. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36154. /**
  36155. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36156. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36157. * frustum width.
  36158. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36159. * to fully enclose the mesh in the viewing frustum.
  36160. */
  36161. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36162. /**
  36163. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36164. * is automatically returned to its default position (expected to be above ground plane).
  36165. */
  36166. private _maintainCameraAboveGround;
  36167. /**
  36168. * Returns the frustum slope based on the canvas ratio and camera FOV
  36169. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36170. */
  36171. private _getFrustumSlope;
  36172. /**
  36173. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36174. */
  36175. private _clearAnimationLocks;
  36176. /**
  36177. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36178. */
  36179. private _applyUserInteraction;
  36180. /**
  36181. * Stops and removes all animations that have been applied to the camera
  36182. */
  36183. stopAllAnimations(): void;
  36184. /**
  36185. * Gets a value indicating if the user is moving the camera
  36186. */
  36187. readonly isUserIsMoving: boolean;
  36188. /**
  36189. * The camera can move all the way towards the mesh.
  36190. */
  36191. static IgnoreBoundsSizeMode: number;
  36192. /**
  36193. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36194. */
  36195. static FitFrustumSidesMode: number;
  36196. }
  36197. }
  36198. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36199. import { Nullable } from "babylonjs/types";
  36200. import { Camera } from "babylonjs/Cameras/camera";
  36201. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36202. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36203. /**
  36204. * Base class for Camera Pointer Inputs.
  36205. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36206. * for example usage.
  36207. */
  36208. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36209. /**
  36210. * Defines the camera the input is attached to.
  36211. */
  36212. abstract camera: Camera;
  36213. /**
  36214. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36215. */
  36216. protected _altKey: boolean;
  36217. protected _ctrlKey: boolean;
  36218. protected _metaKey: boolean;
  36219. protected _shiftKey: boolean;
  36220. /**
  36221. * Which mouse buttons were pressed at time of last mouse event.
  36222. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36223. */
  36224. protected _buttonsPressed: number;
  36225. /**
  36226. * Defines the buttons associated with the input to handle camera move.
  36227. */
  36228. buttons: number[];
  36229. /**
  36230. * Attach the input controls to a specific dom element to get the input from.
  36231. * @param element Defines the element the controls should be listened from
  36232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36233. */
  36234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36235. /**
  36236. * Detach the current controls from the specified dom element.
  36237. * @param element Defines the element to stop listening the inputs from
  36238. */
  36239. detachControl(element: Nullable<HTMLElement>): void;
  36240. /**
  36241. * Gets the class name of the current input.
  36242. * @returns the class name
  36243. */
  36244. getClassName(): string;
  36245. /**
  36246. * Get the friendly name associated with the input class.
  36247. * @returns the input friendly name
  36248. */
  36249. getSimpleName(): string;
  36250. /**
  36251. * Called on pointer POINTERDOUBLETAP event.
  36252. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36253. */
  36254. protected onDoubleTap(type: string): void;
  36255. /**
  36256. * Called on pointer POINTERMOVE event if only a single touch is active.
  36257. * Override this method to provide functionality.
  36258. */
  36259. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36260. /**
  36261. * Called on pointer POINTERMOVE event if multiple touches are active.
  36262. * Override this method to provide functionality.
  36263. */
  36264. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36265. /**
  36266. * Called on JS contextmenu event.
  36267. * Override this method to provide functionality.
  36268. */
  36269. protected onContextMenu(evt: PointerEvent): void;
  36270. /**
  36271. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36272. * press.
  36273. * Override this method to provide functionality.
  36274. */
  36275. protected onButtonDown(evt: PointerEvent): void;
  36276. /**
  36277. * Called each time a new POINTERUP event occurs. Ie, for each button
  36278. * release.
  36279. * Override this method to provide functionality.
  36280. */
  36281. protected onButtonUp(evt: PointerEvent): void;
  36282. /**
  36283. * Called when window becomes inactive.
  36284. * Override this method to provide functionality.
  36285. */
  36286. protected onLostFocus(): void;
  36287. private _pointerInput;
  36288. private _observer;
  36289. private _onLostFocus;
  36290. private pointA;
  36291. private pointB;
  36292. }
  36293. }
  36294. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36295. import { Nullable } from "babylonjs/types";
  36296. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36297. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36298. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36299. /**
  36300. * Manage the pointers inputs to control an arc rotate camera.
  36301. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36302. */
  36303. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36304. /**
  36305. * Defines the camera the input is attached to.
  36306. */
  36307. camera: ArcRotateCamera;
  36308. /**
  36309. * Gets the class name of the current input.
  36310. * @returns the class name
  36311. */
  36312. getClassName(): string;
  36313. /**
  36314. * Defines the buttons associated with the input to handle camera move.
  36315. */
  36316. buttons: number[];
  36317. /**
  36318. * Defines the pointer angular sensibility along the X axis or how fast is
  36319. * the camera rotating.
  36320. */
  36321. angularSensibilityX: number;
  36322. /**
  36323. * Defines the pointer angular sensibility along the Y axis or how fast is
  36324. * the camera rotating.
  36325. */
  36326. angularSensibilityY: number;
  36327. /**
  36328. * Defines the pointer pinch precision or how fast is the camera zooming.
  36329. */
  36330. pinchPrecision: number;
  36331. /**
  36332. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36333. * from 0.
  36334. * It defines the percentage of current camera.radius to use as delta when
  36335. * pinch zoom is used.
  36336. */
  36337. pinchDeltaPercentage: number;
  36338. /**
  36339. * Defines the pointer panning sensibility or how fast is the camera moving.
  36340. */
  36341. panningSensibility: number;
  36342. /**
  36343. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36344. */
  36345. multiTouchPanning: boolean;
  36346. /**
  36347. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36348. * zoom (pinch) through multitouch.
  36349. */
  36350. multiTouchPanAndZoom: boolean;
  36351. /**
  36352. * Revers pinch action direction.
  36353. */
  36354. pinchInwards: boolean;
  36355. private _isPanClick;
  36356. private _twoFingerActivityCount;
  36357. private _isPinching;
  36358. /**
  36359. * Called on pointer POINTERMOVE event if only a single touch is active.
  36360. */
  36361. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36362. /**
  36363. * Called on pointer POINTERDOUBLETAP event.
  36364. */
  36365. protected onDoubleTap(type: string): void;
  36366. /**
  36367. * Called on pointer POINTERMOVE event if multiple touches are active.
  36368. */
  36369. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36370. /**
  36371. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36372. * press.
  36373. */
  36374. protected onButtonDown(evt: PointerEvent): void;
  36375. /**
  36376. * Called each time a new POINTERUP event occurs. Ie, for each button
  36377. * release.
  36378. */
  36379. protected onButtonUp(evt: PointerEvent): void;
  36380. /**
  36381. * Called when window becomes inactive.
  36382. */
  36383. protected onLostFocus(): void;
  36384. }
  36385. }
  36386. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36387. import { Nullable } from "babylonjs/types";
  36388. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36389. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36390. /**
  36391. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36393. */
  36394. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36395. /**
  36396. * Defines the camera the input is attached to.
  36397. */
  36398. camera: ArcRotateCamera;
  36399. /**
  36400. * Defines the list of key codes associated with the up action (increase alpha)
  36401. */
  36402. keysUp: number[];
  36403. /**
  36404. * Defines the list of key codes associated with the down action (decrease alpha)
  36405. */
  36406. keysDown: number[];
  36407. /**
  36408. * Defines the list of key codes associated with the left action (increase beta)
  36409. */
  36410. keysLeft: number[];
  36411. /**
  36412. * Defines the list of key codes associated with the right action (decrease beta)
  36413. */
  36414. keysRight: number[];
  36415. /**
  36416. * Defines the list of key codes associated with the reset action.
  36417. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36418. */
  36419. keysReset: number[];
  36420. /**
  36421. * Defines the panning sensibility of the inputs.
  36422. * (How fast is the camera paning)
  36423. */
  36424. panningSensibility: number;
  36425. /**
  36426. * Defines the zooming sensibility of the inputs.
  36427. * (How fast is the camera zooming)
  36428. */
  36429. zoomingSensibility: number;
  36430. /**
  36431. * Defines wether maintaining the alt key down switch the movement mode from
  36432. * orientation to zoom.
  36433. */
  36434. useAltToZoom: boolean;
  36435. /**
  36436. * Rotation speed of the camera
  36437. */
  36438. angularSpeed: number;
  36439. private _keys;
  36440. private _ctrlPressed;
  36441. private _altPressed;
  36442. private _onCanvasBlurObserver;
  36443. private _onKeyboardObserver;
  36444. private _engine;
  36445. private _scene;
  36446. /**
  36447. * Attach the input controls to a specific dom element to get the input from.
  36448. * @param element Defines the element the controls should be listened from
  36449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36450. */
  36451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36452. /**
  36453. * Detach the current controls from the specified dom element.
  36454. * @param element Defines the element to stop listening the inputs from
  36455. */
  36456. detachControl(element: Nullable<HTMLElement>): void;
  36457. /**
  36458. * Update the current camera state depending on the inputs that have been used this frame.
  36459. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36460. */
  36461. checkInputs(): void;
  36462. /**
  36463. * Gets the class name of the current intput.
  36464. * @returns the class name
  36465. */
  36466. getClassName(): string;
  36467. /**
  36468. * Get the friendly name associated with the input class.
  36469. * @returns the input friendly name
  36470. */
  36471. getSimpleName(): string;
  36472. }
  36473. }
  36474. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36475. import { Nullable } from "babylonjs/types";
  36476. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36477. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36478. /**
  36479. * Manage the mouse wheel inputs to control an arc rotate camera.
  36480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36481. */
  36482. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36483. /**
  36484. * Defines the camera the input is attached to.
  36485. */
  36486. camera: ArcRotateCamera;
  36487. /**
  36488. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36489. */
  36490. wheelPrecision: number;
  36491. /**
  36492. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36493. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36494. */
  36495. wheelDeltaPercentage: number;
  36496. private _wheel;
  36497. private _observer;
  36498. private computeDeltaFromMouseWheelLegacyEvent;
  36499. /**
  36500. * Attach the input controls to a specific dom element to get the input from.
  36501. * @param element Defines the element the controls should be listened from
  36502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36503. */
  36504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36505. /**
  36506. * Detach the current controls from the specified dom element.
  36507. * @param element Defines the element to stop listening the inputs from
  36508. */
  36509. detachControl(element: Nullable<HTMLElement>): void;
  36510. /**
  36511. * Gets the class name of the current intput.
  36512. * @returns the class name
  36513. */
  36514. getClassName(): string;
  36515. /**
  36516. * Get the friendly name associated with the input class.
  36517. * @returns the input friendly name
  36518. */
  36519. getSimpleName(): string;
  36520. }
  36521. }
  36522. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36523. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36524. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36525. /**
  36526. * Default Inputs manager for the ArcRotateCamera.
  36527. * It groups all the default supported inputs for ease of use.
  36528. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36529. */
  36530. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36531. /**
  36532. * Instantiates a new ArcRotateCameraInputsManager.
  36533. * @param camera Defines the camera the inputs belong to
  36534. */
  36535. constructor(camera: ArcRotateCamera);
  36536. /**
  36537. * Add mouse wheel input support to the input manager.
  36538. * @returns the current input manager
  36539. */
  36540. addMouseWheel(): ArcRotateCameraInputsManager;
  36541. /**
  36542. * Add pointers input support to the input manager.
  36543. * @returns the current input manager
  36544. */
  36545. addPointers(): ArcRotateCameraInputsManager;
  36546. /**
  36547. * Add keyboard input support to the input manager.
  36548. * @returns the current input manager
  36549. */
  36550. addKeyboard(): ArcRotateCameraInputsManager;
  36551. }
  36552. }
  36553. declare module "babylonjs/Cameras/arcRotateCamera" {
  36554. import { Observable } from "babylonjs/Misc/observable";
  36555. import { Nullable } from "babylonjs/types";
  36556. import { Scene } from "babylonjs/scene";
  36557. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36559. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36560. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36561. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36562. import { Camera } from "babylonjs/Cameras/camera";
  36563. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36564. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36565. import { Collider } from "babylonjs/Collisions/collider";
  36566. /**
  36567. * This represents an orbital type of camera.
  36568. *
  36569. * 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.
  36570. * 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.
  36571. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36572. */
  36573. export class ArcRotateCamera extends TargetCamera {
  36574. /**
  36575. * Defines the rotation angle of the camera along the longitudinal axis.
  36576. */
  36577. alpha: number;
  36578. /**
  36579. * Defines the rotation angle of the camera along the latitudinal axis.
  36580. */
  36581. beta: number;
  36582. /**
  36583. * Defines the radius of the camera from it s target point.
  36584. */
  36585. radius: number;
  36586. protected _target: Vector3;
  36587. protected _targetHost: Nullable<AbstractMesh>;
  36588. /**
  36589. * Defines the target point of the camera.
  36590. * The camera looks towards it form the radius distance.
  36591. */
  36592. target: Vector3;
  36593. /**
  36594. * Define the current local position of the camera in the scene
  36595. */
  36596. position: Vector3;
  36597. protected _upVector: Vector3;
  36598. protected _upToYMatrix: Matrix;
  36599. protected _YToUpMatrix: Matrix;
  36600. /**
  36601. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36602. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36603. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36604. */
  36605. upVector: Vector3;
  36606. /**
  36607. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36608. */
  36609. setMatUp(): void;
  36610. /**
  36611. * Current inertia value on the longitudinal axis.
  36612. * The bigger this number the longer it will take for the camera to stop.
  36613. */
  36614. inertialAlphaOffset: number;
  36615. /**
  36616. * Current inertia value on the latitudinal axis.
  36617. * The bigger this number the longer it will take for the camera to stop.
  36618. */
  36619. inertialBetaOffset: number;
  36620. /**
  36621. * Current inertia value on the radius axis.
  36622. * The bigger this number the longer it will take for the camera to stop.
  36623. */
  36624. inertialRadiusOffset: number;
  36625. /**
  36626. * Minimum allowed angle on the longitudinal axis.
  36627. * This can help limiting how the Camera is able to move in the scene.
  36628. */
  36629. lowerAlphaLimit: Nullable<number>;
  36630. /**
  36631. * Maximum allowed angle on the longitudinal axis.
  36632. * This can help limiting how the Camera is able to move in the scene.
  36633. */
  36634. upperAlphaLimit: Nullable<number>;
  36635. /**
  36636. * Minimum allowed angle on the latitudinal axis.
  36637. * This can help limiting how the Camera is able to move in the scene.
  36638. */
  36639. lowerBetaLimit: number;
  36640. /**
  36641. * Maximum allowed angle on the latitudinal axis.
  36642. * This can help limiting how the Camera is able to move in the scene.
  36643. */
  36644. upperBetaLimit: number;
  36645. /**
  36646. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36647. * This can help limiting how the Camera is able to move in the scene.
  36648. */
  36649. lowerRadiusLimit: Nullable<number>;
  36650. /**
  36651. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36652. * This can help limiting how the Camera is able to move in the scene.
  36653. */
  36654. upperRadiusLimit: Nullable<number>;
  36655. /**
  36656. * Defines the current inertia value used during panning of the camera along the X axis.
  36657. */
  36658. inertialPanningX: number;
  36659. /**
  36660. * Defines the current inertia value used during panning of the camera along the Y axis.
  36661. */
  36662. inertialPanningY: number;
  36663. /**
  36664. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36665. * Basically if your fingers moves away from more than this distance you will be considered
  36666. * in pinch mode.
  36667. */
  36668. pinchToPanMaxDistance: number;
  36669. /**
  36670. * Defines the maximum distance the camera can pan.
  36671. * This could help keeping the cammera always in your scene.
  36672. */
  36673. panningDistanceLimit: Nullable<number>;
  36674. /**
  36675. * Defines the target of the camera before paning.
  36676. */
  36677. panningOriginTarget: Vector3;
  36678. /**
  36679. * Defines the value of the inertia used during panning.
  36680. * 0 would mean stop inertia and one would mean no decelleration at all.
  36681. */
  36682. panningInertia: number;
  36683. /**
  36684. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36685. */
  36686. angularSensibilityX: number;
  36687. /**
  36688. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36689. */
  36690. angularSensibilityY: number;
  36691. /**
  36692. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36693. */
  36694. pinchPrecision: number;
  36695. /**
  36696. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36697. * It will be used instead of pinchDeltaPrecision if different from 0.
  36698. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36699. */
  36700. pinchDeltaPercentage: number;
  36701. /**
  36702. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36703. */
  36704. panningSensibility: number;
  36705. /**
  36706. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36707. */
  36708. keysUp: number[];
  36709. /**
  36710. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36711. */
  36712. keysDown: number[];
  36713. /**
  36714. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36715. */
  36716. keysLeft: number[];
  36717. /**
  36718. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36719. */
  36720. keysRight: number[];
  36721. /**
  36722. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36723. */
  36724. wheelPrecision: number;
  36725. /**
  36726. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36727. * It will be used instead of pinchDeltaPrecision if different from 0.
  36728. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36729. */
  36730. wheelDeltaPercentage: number;
  36731. /**
  36732. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36733. */
  36734. zoomOnFactor: number;
  36735. /**
  36736. * Defines a screen offset for the camera position.
  36737. */
  36738. targetScreenOffset: Vector2;
  36739. /**
  36740. * Allows the camera to be completely reversed.
  36741. * If false the camera can not arrive upside down.
  36742. */
  36743. allowUpsideDown: boolean;
  36744. /**
  36745. * Define if double tap/click is used to restore the previously saved state of the camera.
  36746. */
  36747. useInputToRestoreState: boolean;
  36748. /** @hidden */
  36749. _viewMatrix: Matrix;
  36750. /** @hidden */
  36751. _useCtrlForPanning: boolean;
  36752. /** @hidden */
  36753. _panningMouseButton: number;
  36754. /**
  36755. * Defines the input associated to the camera.
  36756. */
  36757. inputs: ArcRotateCameraInputsManager;
  36758. /** @hidden */
  36759. _reset: () => void;
  36760. /**
  36761. * Defines the allowed panning axis.
  36762. */
  36763. panningAxis: Vector3;
  36764. protected _localDirection: Vector3;
  36765. protected _transformedDirection: Vector3;
  36766. private _bouncingBehavior;
  36767. /**
  36768. * Gets the bouncing behavior of the camera if it has been enabled.
  36769. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36770. */
  36771. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36772. /**
  36773. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36774. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36775. */
  36776. useBouncingBehavior: boolean;
  36777. private _framingBehavior;
  36778. /**
  36779. * Gets the framing behavior of the camera if it has been enabled.
  36780. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36781. */
  36782. readonly framingBehavior: Nullable<FramingBehavior>;
  36783. /**
  36784. * Defines if the framing behavior of the camera is enabled on the camera.
  36785. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36786. */
  36787. useFramingBehavior: boolean;
  36788. private _autoRotationBehavior;
  36789. /**
  36790. * Gets the auto rotation behavior of the camera if it has been enabled.
  36791. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36792. */
  36793. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36794. /**
  36795. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36796. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36797. */
  36798. useAutoRotationBehavior: boolean;
  36799. /**
  36800. * Observable triggered when the mesh target has been changed on the camera.
  36801. */
  36802. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36803. /**
  36804. * Event raised when the camera is colliding with a mesh.
  36805. */
  36806. onCollide: (collidedMesh: AbstractMesh) => void;
  36807. /**
  36808. * Defines whether the camera should check collision with the objects oh the scene.
  36809. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36810. */
  36811. checkCollisions: boolean;
  36812. /**
  36813. * Defines the collision radius of the camera.
  36814. * This simulates a sphere around the camera.
  36815. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36816. */
  36817. collisionRadius: Vector3;
  36818. protected _collider: Collider;
  36819. protected _previousPosition: Vector3;
  36820. protected _collisionVelocity: Vector3;
  36821. protected _newPosition: Vector3;
  36822. protected _previousAlpha: number;
  36823. protected _previousBeta: number;
  36824. protected _previousRadius: number;
  36825. protected _collisionTriggered: boolean;
  36826. protected _targetBoundingCenter: Nullable<Vector3>;
  36827. private _computationVector;
  36828. /**
  36829. * Instantiates a new ArcRotateCamera in a given scene
  36830. * @param name Defines the name of the camera
  36831. * @param alpha Defines the camera rotation along the logitudinal axis
  36832. * @param beta Defines the camera rotation along the latitudinal axis
  36833. * @param radius Defines the camera distance from its target
  36834. * @param target Defines the camera target
  36835. * @param scene Defines the scene the camera belongs to
  36836. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36837. */
  36838. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36839. /** @hidden */
  36840. _initCache(): void;
  36841. /** @hidden */
  36842. _updateCache(ignoreParentClass?: boolean): void;
  36843. protected _getTargetPosition(): Vector3;
  36844. private _storedAlpha;
  36845. private _storedBeta;
  36846. private _storedRadius;
  36847. private _storedTarget;
  36848. /**
  36849. * Stores the current state of the camera (alpha, beta, radius and target)
  36850. * @returns the camera itself
  36851. */
  36852. storeState(): Camera;
  36853. /**
  36854. * @hidden
  36855. * Restored camera state. You must call storeState() first
  36856. */
  36857. _restoreStateValues(): boolean;
  36858. /** @hidden */
  36859. _isSynchronizedViewMatrix(): boolean;
  36860. /**
  36861. * Attached controls to the current camera.
  36862. * @param element Defines the element the controls should be listened from
  36863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36864. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36865. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36866. */
  36867. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36868. /**
  36869. * Detach the current controls from the camera.
  36870. * The camera will stop reacting to inputs.
  36871. * @param element Defines the element to stop listening the inputs from
  36872. */
  36873. detachControl(element: HTMLElement): void;
  36874. /** @hidden */
  36875. _checkInputs(): void;
  36876. protected _checkLimits(): void;
  36877. /**
  36878. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36879. */
  36880. rebuildAnglesAndRadius(): void;
  36881. /**
  36882. * Use a position to define the current camera related information like aplha, beta and radius
  36883. * @param position Defines the position to set the camera at
  36884. */
  36885. setPosition(position: Vector3): void;
  36886. /**
  36887. * Defines the target the camera should look at.
  36888. * This will automatically adapt alpha beta and radius to fit within the new target.
  36889. * @param target Defines the new target as a Vector or a mesh
  36890. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36891. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36892. */
  36893. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36894. /** @hidden */
  36895. _getViewMatrix(): Matrix;
  36896. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36897. /**
  36898. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36899. * @param meshes Defines the mesh to zoom on
  36900. * @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)
  36901. */
  36902. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36903. /**
  36904. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36905. * The target will be changed but the radius
  36906. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36907. * @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)
  36908. */
  36909. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36910. min: Vector3;
  36911. max: Vector3;
  36912. distance: number;
  36913. }, doNotUpdateMaxZ?: boolean): void;
  36914. /**
  36915. * @override
  36916. * Override Camera.createRigCamera
  36917. */
  36918. createRigCamera(name: string, cameraIndex: number): Camera;
  36919. /**
  36920. * @hidden
  36921. * @override
  36922. * Override Camera._updateRigCameras
  36923. */
  36924. _updateRigCameras(): void;
  36925. /**
  36926. * Destroy the camera and release the current resources hold by it.
  36927. */
  36928. dispose(): void;
  36929. /**
  36930. * Gets the current object class name.
  36931. * @return the class name
  36932. */
  36933. getClassName(): string;
  36934. }
  36935. }
  36936. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36937. import { Behavior } from "babylonjs/Behaviors/behavior";
  36938. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36939. /**
  36940. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36941. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36942. */
  36943. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36944. /**
  36945. * Gets the name of the behavior.
  36946. */
  36947. readonly name: string;
  36948. private _zoomStopsAnimation;
  36949. private _idleRotationSpeed;
  36950. private _idleRotationWaitTime;
  36951. private _idleRotationSpinupTime;
  36952. /**
  36953. * Sets the flag that indicates if user zooming should stop animation.
  36954. */
  36955. /**
  36956. * Gets the flag that indicates if user zooming should stop animation.
  36957. */
  36958. zoomStopsAnimation: boolean;
  36959. /**
  36960. * Sets the default speed at which the camera rotates around the model.
  36961. */
  36962. /**
  36963. * Gets the default speed at which the camera rotates around the model.
  36964. */
  36965. idleRotationSpeed: number;
  36966. /**
  36967. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36968. */
  36969. /**
  36970. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36971. */
  36972. idleRotationWaitTime: number;
  36973. /**
  36974. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36975. */
  36976. /**
  36977. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36978. */
  36979. idleRotationSpinupTime: number;
  36980. /**
  36981. * Gets a value indicating if the camera is currently rotating because of this behavior
  36982. */
  36983. readonly rotationInProgress: boolean;
  36984. private _onPrePointerObservableObserver;
  36985. private _onAfterCheckInputsObserver;
  36986. private _attachedCamera;
  36987. private _isPointerDown;
  36988. private _lastFrameTime;
  36989. private _lastInteractionTime;
  36990. private _cameraRotationSpeed;
  36991. /**
  36992. * Initializes the behavior.
  36993. */
  36994. init(): void;
  36995. /**
  36996. * Attaches the behavior to its arc rotate camera.
  36997. * @param camera Defines the camera to attach the behavior to
  36998. */
  36999. attach(camera: ArcRotateCamera): void;
  37000. /**
  37001. * Detaches the behavior from its current arc rotate camera.
  37002. */
  37003. detach(): void;
  37004. /**
  37005. * Returns true if user is scrolling.
  37006. * @return true if user is scrolling.
  37007. */
  37008. private _userIsZooming;
  37009. private _lastFrameRadius;
  37010. private _shouldAnimationStopForInteraction;
  37011. /**
  37012. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37013. */
  37014. private _applyUserInteraction;
  37015. private _userIsMoving;
  37016. }
  37017. }
  37018. declare module "babylonjs/Behaviors/Cameras/index" {
  37019. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37020. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37021. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37022. }
  37023. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37024. import { Mesh } from "babylonjs/Meshes/mesh";
  37025. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37026. import { Behavior } from "babylonjs/Behaviors/behavior";
  37027. /**
  37028. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37029. */
  37030. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37031. private ui;
  37032. /**
  37033. * The name of the behavior
  37034. */
  37035. name: string;
  37036. /**
  37037. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37038. */
  37039. distanceAwayFromFace: number;
  37040. /**
  37041. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37042. */
  37043. distanceAwayFromBottomOfFace: number;
  37044. private _faceVectors;
  37045. private _target;
  37046. private _scene;
  37047. private _onRenderObserver;
  37048. private _tmpMatrix;
  37049. private _tmpVector;
  37050. /**
  37051. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37052. * @param ui The transform node that should be attched to the mesh
  37053. */
  37054. constructor(ui: TransformNode);
  37055. /**
  37056. * Initializes the behavior
  37057. */
  37058. init(): void;
  37059. private _closestFace;
  37060. private _zeroVector;
  37061. private _lookAtTmpMatrix;
  37062. private _lookAtToRef;
  37063. /**
  37064. * Attaches the AttachToBoxBehavior to the passed in mesh
  37065. * @param target The mesh that the specified node will be attached to
  37066. */
  37067. attach(target: Mesh): void;
  37068. /**
  37069. * Detaches the behavior from the mesh
  37070. */
  37071. detach(): void;
  37072. }
  37073. }
  37074. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37075. import { Behavior } from "babylonjs/Behaviors/behavior";
  37076. import { Mesh } from "babylonjs/Meshes/mesh";
  37077. /**
  37078. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37079. */
  37080. export class FadeInOutBehavior implements Behavior<Mesh> {
  37081. /**
  37082. * Time in milliseconds to delay before fading in (Default: 0)
  37083. */
  37084. delay: number;
  37085. /**
  37086. * Time in milliseconds for the mesh to fade in (Default: 300)
  37087. */
  37088. fadeInTime: number;
  37089. private _millisecondsPerFrame;
  37090. private _hovered;
  37091. private _hoverValue;
  37092. private _ownerNode;
  37093. /**
  37094. * Instatiates the FadeInOutBehavior
  37095. */
  37096. constructor();
  37097. /**
  37098. * The name of the behavior
  37099. */
  37100. readonly name: string;
  37101. /**
  37102. * Initializes the behavior
  37103. */
  37104. init(): void;
  37105. /**
  37106. * Attaches the fade behavior on the passed in mesh
  37107. * @param ownerNode The mesh that will be faded in/out once attached
  37108. */
  37109. attach(ownerNode: Mesh): void;
  37110. /**
  37111. * Detaches the behavior from the mesh
  37112. */
  37113. detach(): void;
  37114. /**
  37115. * Triggers the mesh to begin fading in or out
  37116. * @param value if the object should fade in or out (true to fade in)
  37117. */
  37118. fadeIn(value: boolean): void;
  37119. private _update;
  37120. private _setAllVisibility;
  37121. }
  37122. }
  37123. declare module "babylonjs/Misc/pivotTools" {
  37124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37125. /**
  37126. * Class containing a set of static utilities functions for managing Pivots
  37127. * @hidden
  37128. */
  37129. export class PivotTools {
  37130. private static _PivotCached;
  37131. private static _OldPivotPoint;
  37132. private static _PivotTranslation;
  37133. private static _PivotTmpVector;
  37134. /** @hidden */
  37135. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37136. /** @hidden */
  37137. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37138. }
  37139. }
  37140. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37141. import { Scene } from "babylonjs/scene";
  37142. import { Vector4, Plane } from "babylonjs/Maths/math";
  37143. import { Mesh } from "babylonjs/Meshes/mesh";
  37144. import { Nullable } from "babylonjs/types";
  37145. /**
  37146. * Class containing static functions to help procedurally build meshes
  37147. */
  37148. export class PlaneBuilder {
  37149. /**
  37150. * Creates a plane mesh
  37151. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37152. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37153. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37157. * @param name defines the name of the mesh
  37158. * @param options defines the options used to create the mesh
  37159. * @param scene defines the hosting scene
  37160. * @returns the plane mesh
  37161. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37162. */
  37163. static CreatePlane(name: string, options: {
  37164. size?: number;
  37165. width?: number;
  37166. height?: number;
  37167. sideOrientation?: number;
  37168. frontUVs?: Vector4;
  37169. backUVs?: Vector4;
  37170. updatable?: boolean;
  37171. sourcePlane?: Plane;
  37172. }, scene?: Nullable<Scene>): Mesh;
  37173. }
  37174. }
  37175. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37176. import { Behavior } from "babylonjs/Behaviors/behavior";
  37177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37178. import { Observable } from "babylonjs/Misc/observable";
  37179. import { Vector3 } from "babylonjs/Maths/math";
  37180. import { Ray } from "babylonjs/Culling/ray";
  37181. import "babylonjs/Meshes/Builders/planeBuilder";
  37182. /**
  37183. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37184. */
  37185. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37186. private static _AnyMouseID;
  37187. /**
  37188. * Abstract mesh the behavior is set on
  37189. */
  37190. attachedNode: AbstractMesh;
  37191. private _dragPlane;
  37192. private _scene;
  37193. private _pointerObserver;
  37194. private _beforeRenderObserver;
  37195. private static _planeScene;
  37196. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37197. /**
  37198. * 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)
  37199. */
  37200. maxDragAngle: number;
  37201. /**
  37202. * @hidden
  37203. */
  37204. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37205. /**
  37206. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37207. */
  37208. currentDraggingPointerID: number;
  37209. /**
  37210. * The last position where the pointer hit the drag plane in world space
  37211. */
  37212. lastDragPosition: Vector3;
  37213. /**
  37214. * If the behavior is currently in a dragging state
  37215. */
  37216. dragging: boolean;
  37217. /**
  37218. * 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)
  37219. */
  37220. dragDeltaRatio: number;
  37221. /**
  37222. * If the drag plane orientation should be updated during the dragging (Default: true)
  37223. */
  37224. updateDragPlane: boolean;
  37225. private _debugMode;
  37226. private _moving;
  37227. /**
  37228. * Fires each time the attached mesh is dragged with the pointer
  37229. * * delta between last drag position and current drag position in world space
  37230. * * dragDistance along the drag axis
  37231. * * dragPlaneNormal normal of the current drag plane used during the drag
  37232. * * dragPlanePoint in world space where the drag intersects the drag plane
  37233. */
  37234. onDragObservable: Observable<{
  37235. delta: Vector3;
  37236. dragPlanePoint: Vector3;
  37237. dragPlaneNormal: Vector3;
  37238. dragDistance: number;
  37239. pointerId: number;
  37240. }>;
  37241. /**
  37242. * Fires each time a drag begins (eg. mouse down on mesh)
  37243. */
  37244. onDragStartObservable: Observable<{
  37245. dragPlanePoint: Vector3;
  37246. pointerId: number;
  37247. }>;
  37248. /**
  37249. * Fires each time a drag ends (eg. mouse release after drag)
  37250. */
  37251. onDragEndObservable: Observable<{
  37252. dragPlanePoint: Vector3;
  37253. pointerId: number;
  37254. }>;
  37255. /**
  37256. * If the attached mesh should be moved when dragged
  37257. */
  37258. moveAttached: boolean;
  37259. /**
  37260. * If the drag behavior will react to drag events (Default: true)
  37261. */
  37262. enabled: boolean;
  37263. /**
  37264. * If pointer events should start and release the drag (Default: true)
  37265. */
  37266. startAndReleaseDragOnPointerEvents: boolean;
  37267. /**
  37268. * If camera controls should be detached during the drag
  37269. */
  37270. detachCameraControls: boolean;
  37271. /**
  37272. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37273. */
  37274. useObjectOrienationForDragging: boolean;
  37275. private _options;
  37276. /**
  37277. * Creates a pointer drag behavior that can be attached to a mesh
  37278. * @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)
  37279. */
  37280. constructor(options?: {
  37281. dragAxis?: Vector3;
  37282. dragPlaneNormal?: Vector3;
  37283. });
  37284. /**
  37285. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37286. */
  37287. validateDrag: (targetPosition: Vector3) => boolean;
  37288. /**
  37289. * The name of the behavior
  37290. */
  37291. readonly name: string;
  37292. /**
  37293. * Initializes the behavior
  37294. */
  37295. init(): void;
  37296. private _tmpVector;
  37297. private _alternatePickedPoint;
  37298. private _worldDragAxis;
  37299. private _targetPosition;
  37300. private _attachedElement;
  37301. /**
  37302. * Attaches the drag behavior the passed in mesh
  37303. * @param ownerNode The mesh that will be dragged around once attached
  37304. */
  37305. attach(ownerNode: AbstractMesh): void;
  37306. /**
  37307. * Force relase the drag action by code.
  37308. */
  37309. releaseDrag(): void;
  37310. private _startDragRay;
  37311. private _lastPointerRay;
  37312. /**
  37313. * Simulates the start of a pointer drag event on the behavior
  37314. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37315. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37316. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37317. */
  37318. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37319. private _startDrag;
  37320. private _dragDelta;
  37321. private _moveDrag;
  37322. private _pickWithRayOnDragPlane;
  37323. private _pointA;
  37324. private _pointB;
  37325. private _pointC;
  37326. private _lineA;
  37327. private _lineB;
  37328. private _localAxis;
  37329. private _lookAt;
  37330. private _updateDragPlanePosition;
  37331. /**
  37332. * Detaches the behavior from the mesh
  37333. */
  37334. detach(): void;
  37335. }
  37336. }
  37337. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37338. import { Mesh } from "babylonjs/Meshes/mesh";
  37339. import { Behavior } from "babylonjs/Behaviors/behavior";
  37340. /**
  37341. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37342. */
  37343. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37344. private _dragBehaviorA;
  37345. private _dragBehaviorB;
  37346. private _startDistance;
  37347. private _initialScale;
  37348. private _targetScale;
  37349. private _ownerNode;
  37350. private _sceneRenderObserver;
  37351. /**
  37352. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37353. */
  37354. constructor();
  37355. /**
  37356. * The name of the behavior
  37357. */
  37358. readonly name: string;
  37359. /**
  37360. * Initializes the behavior
  37361. */
  37362. init(): void;
  37363. private _getCurrentDistance;
  37364. /**
  37365. * Attaches the scale behavior the passed in mesh
  37366. * @param ownerNode The mesh that will be scaled around once attached
  37367. */
  37368. attach(ownerNode: Mesh): void;
  37369. /**
  37370. * Detaches the behavior from the mesh
  37371. */
  37372. detach(): void;
  37373. }
  37374. }
  37375. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37376. import { Behavior } from "babylonjs/Behaviors/behavior";
  37377. import { Mesh } from "babylonjs/Meshes/mesh";
  37378. import { Observable } from "babylonjs/Misc/observable";
  37379. /**
  37380. * 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
  37381. */
  37382. export class SixDofDragBehavior implements Behavior<Mesh> {
  37383. private static _virtualScene;
  37384. private _ownerNode;
  37385. private _sceneRenderObserver;
  37386. private _scene;
  37387. private _targetPosition;
  37388. private _virtualOriginMesh;
  37389. private _virtualDragMesh;
  37390. private _pointerObserver;
  37391. private _moving;
  37392. private _startingOrientation;
  37393. /**
  37394. * 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)
  37395. */
  37396. private zDragFactor;
  37397. /**
  37398. * If the object should rotate to face the drag origin
  37399. */
  37400. rotateDraggedObject: boolean;
  37401. /**
  37402. * If the behavior is currently in a dragging state
  37403. */
  37404. dragging: boolean;
  37405. /**
  37406. * 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)
  37407. */
  37408. dragDeltaRatio: number;
  37409. /**
  37410. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37411. */
  37412. currentDraggingPointerID: number;
  37413. /**
  37414. * If camera controls should be detached during the drag
  37415. */
  37416. detachCameraControls: boolean;
  37417. /**
  37418. * Fires each time a drag starts
  37419. */
  37420. onDragStartObservable: Observable<{}>;
  37421. /**
  37422. * Fires each time a drag ends (eg. mouse release after drag)
  37423. */
  37424. onDragEndObservable: Observable<{}>;
  37425. /**
  37426. * 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
  37427. */
  37428. constructor();
  37429. /**
  37430. * The name of the behavior
  37431. */
  37432. readonly name: string;
  37433. /**
  37434. * Initializes the behavior
  37435. */
  37436. init(): void;
  37437. /**
  37438. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37439. */
  37440. private readonly _pointerCamera;
  37441. /**
  37442. * Attaches the scale behavior the passed in mesh
  37443. * @param ownerNode The mesh that will be scaled around once attached
  37444. */
  37445. attach(ownerNode: Mesh): void;
  37446. /**
  37447. * Detaches the behavior from the mesh
  37448. */
  37449. detach(): void;
  37450. }
  37451. }
  37452. declare module "babylonjs/Behaviors/Meshes/index" {
  37453. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37454. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37455. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37456. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37457. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37458. }
  37459. declare module "babylonjs/Behaviors/index" {
  37460. export * from "babylonjs/Behaviors/behavior";
  37461. export * from "babylonjs/Behaviors/Cameras/index";
  37462. export * from "babylonjs/Behaviors/Meshes/index";
  37463. }
  37464. declare module "babylonjs/Bones/boneIKController" {
  37465. import { Bone } from "babylonjs/Bones/bone";
  37466. import { Vector3 } from "babylonjs/Maths/math";
  37467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37468. import { Nullable } from "babylonjs/types";
  37469. /**
  37470. * Class used to apply inverse kinematics to bones
  37471. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37472. */
  37473. export class BoneIKController {
  37474. private static _tmpVecs;
  37475. private static _tmpQuat;
  37476. private static _tmpMats;
  37477. /**
  37478. * Gets or sets the target mesh
  37479. */
  37480. targetMesh: AbstractMesh;
  37481. /** Gets or sets the mesh used as pole */
  37482. poleTargetMesh: AbstractMesh;
  37483. /**
  37484. * Gets or sets the bone used as pole
  37485. */
  37486. poleTargetBone: Nullable<Bone>;
  37487. /**
  37488. * Gets or sets the target position
  37489. */
  37490. targetPosition: Vector3;
  37491. /**
  37492. * Gets or sets the pole target position
  37493. */
  37494. poleTargetPosition: Vector3;
  37495. /**
  37496. * Gets or sets the pole target local offset
  37497. */
  37498. poleTargetLocalOffset: Vector3;
  37499. /**
  37500. * Gets or sets the pole angle
  37501. */
  37502. poleAngle: number;
  37503. /**
  37504. * Gets or sets the mesh associated with the controller
  37505. */
  37506. mesh: AbstractMesh;
  37507. /**
  37508. * 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)
  37509. */
  37510. slerpAmount: number;
  37511. private _bone1Quat;
  37512. private _bone1Mat;
  37513. private _bone2Ang;
  37514. private _bone1;
  37515. private _bone2;
  37516. private _bone1Length;
  37517. private _bone2Length;
  37518. private _maxAngle;
  37519. private _maxReach;
  37520. private _rightHandedSystem;
  37521. private _bendAxis;
  37522. private _slerping;
  37523. private _adjustRoll;
  37524. /**
  37525. * Gets or sets maximum allowed angle
  37526. */
  37527. maxAngle: number;
  37528. /**
  37529. * Creates a new BoneIKController
  37530. * @param mesh defines the mesh to control
  37531. * @param bone defines the bone to control
  37532. * @param options defines options to set up the controller
  37533. */
  37534. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37535. targetMesh?: AbstractMesh;
  37536. poleTargetMesh?: AbstractMesh;
  37537. poleTargetBone?: Bone;
  37538. poleTargetLocalOffset?: Vector3;
  37539. poleAngle?: number;
  37540. bendAxis?: Vector3;
  37541. maxAngle?: number;
  37542. slerpAmount?: number;
  37543. });
  37544. private _setMaxAngle;
  37545. /**
  37546. * Force the controller to update the bones
  37547. */
  37548. update(): void;
  37549. }
  37550. }
  37551. declare module "babylonjs/Bones/boneLookController" {
  37552. import { Vector3, Space } from "babylonjs/Maths/math";
  37553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37554. import { Bone } from "babylonjs/Bones/bone";
  37555. /**
  37556. * Class used to make a bone look toward a point in space
  37557. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37558. */
  37559. export class BoneLookController {
  37560. private static _tmpVecs;
  37561. private static _tmpQuat;
  37562. private static _tmpMats;
  37563. /**
  37564. * The target Vector3 that the bone will look at
  37565. */
  37566. target: Vector3;
  37567. /**
  37568. * The mesh that the bone is attached to
  37569. */
  37570. mesh: AbstractMesh;
  37571. /**
  37572. * The bone that will be looking to the target
  37573. */
  37574. bone: Bone;
  37575. /**
  37576. * The up axis of the coordinate system that is used when the bone is rotated
  37577. */
  37578. upAxis: Vector3;
  37579. /**
  37580. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37581. */
  37582. upAxisSpace: Space;
  37583. /**
  37584. * Used to make an adjustment to the yaw of the bone
  37585. */
  37586. adjustYaw: number;
  37587. /**
  37588. * Used to make an adjustment to the pitch of the bone
  37589. */
  37590. adjustPitch: number;
  37591. /**
  37592. * Used to make an adjustment to the roll of the bone
  37593. */
  37594. adjustRoll: number;
  37595. /**
  37596. * 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)
  37597. */
  37598. slerpAmount: number;
  37599. private _minYaw;
  37600. private _maxYaw;
  37601. private _minPitch;
  37602. private _maxPitch;
  37603. private _minYawSin;
  37604. private _minYawCos;
  37605. private _maxYawSin;
  37606. private _maxYawCos;
  37607. private _midYawConstraint;
  37608. private _minPitchTan;
  37609. private _maxPitchTan;
  37610. private _boneQuat;
  37611. private _slerping;
  37612. private _transformYawPitch;
  37613. private _transformYawPitchInv;
  37614. private _firstFrameSkipped;
  37615. private _yawRange;
  37616. private _fowardAxis;
  37617. /**
  37618. * Gets or sets the minimum yaw angle that the bone can look to
  37619. */
  37620. minYaw: number;
  37621. /**
  37622. * Gets or sets the maximum yaw angle that the bone can look to
  37623. */
  37624. maxYaw: number;
  37625. /**
  37626. * Gets or sets the minimum pitch angle that the bone can look to
  37627. */
  37628. minPitch: number;
  37629. /**
  37630. * Gets or sets the maximum pitch angle that the bone can look to
  37631. */
  37632. maxPitch: number;
  37633. /**
  37634. * Create a BoneLookController
  37635. * @param mesh the mesh that the bone belongs to
  37636. * @param bone the bone that will be looking to the target
  37637. * @param target the target Vector3 to look at
  37638. * @param options optional settings:
  37639. * * maxYaw: the maximum angle the bone will yaw to
  37640. * * minYaw: the minimum angle the bone will yaw to
  37641. * * maxPitch: the maximum angle the bone will pitch to
  37642. * * minPitch: the minimum angle the bone will yaw to
  37643. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37644. * * upAxis: the up axis of the coordinate system
  37645. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37646. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37647. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37648. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37649. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37650. * * adjustRoll: used to make an adjustment to the roll of the bone
  37651. **/
  37652. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37653. maxYaw?: number;
  37654. minYaw?: number;
  37655. maxPitch?: number;
  37656. minPitch?: number;
  37657. slerpAmount?: number;
  37658. upAxis?: Vector3;
  37659. upAxisSpace?: Space;
  37660. yawAxis?: Vector3;
  37661. pitchAxis?: Vector3;
  37662. adjustYaw?: number;
  37663. adjustPitch?: number;
  37664. adjustRoll?: number;
  37665. });
  37666. /**
  37667. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37668. */
  37669. update(): void;
  37670. private _getAngleDiff;
  37671. private _getAngleBetween;
  37672. private _isAngleBetween;
  37673. }
  37674. }
  37675. declare module "babylonjs/Bones/index" {
  37676. export * from "babylonjs/Bones/bone";
  37677. export * from "babylonjs/Bones/boneIKController";
  37678. export * from "babylonjs/Bones/boneLookController";
  37679. export * from "babylonjs/Bones/skeleton";
  37680. }
  37681. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37682. import { Nullable } from "babylonjs/types";
  37683. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37684. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37685. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37686. /**
  37687. * Manage the gamepad inputs to control an arc rotate camera.
  37688. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37689. */
  37690. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37691. /**
  37692. * Defines the camera the input is attached to.
  37693. */
  37694. camera: ArcRotateCamera;
  37695. /**
  37696. * Defines the gamepad the input is gathering event from.
  37697. */
  37698. gamepad: Nullable<Gamepad>;
  37699. /**
  37700. * Defines the gamepad rotation sensiblity.
  37701. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37702. */
  37703. gamepadRotationSensibility: number;
  37704. /**
  37705. * Defines the gamepad move sensiblity.
  37706. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37707. */
  37708. gamepadMoveSensibility: number;
  37709. private _onGamepadConnectedObserver;
  37710. private _onGamepadDisconnectedObserver;
  37711. /**
  37712. * Attach the input controls to a specific dom element to get the input from.
  37713. * @param element Defines the element the controls should be listened from
  37714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37715. */
  37716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37717. /**
  37718. * Detach the current controls from the specified dom element.
  37719. * @param element Defines the element to stop listening the inputs from
  37720. */
  37721. detachControl(element: Nullable<HTMLElement>): void;
  37722. /**
  37723. * Update the current camera state depending on the inputs that have been used this frame.
  37724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37725. */
  37726. checkInputs(): void;
  37727. /**
  37728. * Gets the class name of the current intput.
  37729. * @returns the class name
  37730. */
  37731. getClassName(): string;
  37732. /**
  37733. * Get the friendly name associated with the input class.
  37734. * @returns the input friendly name
  37735. */
  37736. getSimpleName(): string;
  37737. }
  37738. }
  37739. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37740. import { Nullable } from "babylonjs/types";
  37741. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37742. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37743. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37744. interface ArcRotateCameraInputsManager {
  37745. /**
  37746. * Add orientation input support to the input manager.
  37747. * @returns the current input manager
  37748. */
  37749. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37750. }
  37751. }
  37752. /**
  37753. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37755. */
  37756. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37757. /**
  37758. * Defines the camera the input is attached to.
  37759. */
  37760. camera: ArcRotateCamera;
  37761. /**
  37762. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37763. */
  37764. alphaCorrection: number;
  37765. /**
  37766. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37767. */
  37768. gammaCorrection: number;
  37769. private _alpha;
  37770. private _gamma;
  37771. private _dirty;
  37772. private _deviceOrientationHandler;
  37773. /**
  37774. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37775. */
  37776. constructor();
  37777. /**
  37778. * Attach the input controls to a specific dom element to get the input from.
  37779. * @param element Defines the element the controls should be listened from
  37780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37781. */
  37782. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37783. /** @hidden */
  37784. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37785. /**
  37786. * Update the current camera state depending on the inputs that have been used this frame.
  37787. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37788. */
  37789. checkInputs(): void;
  37790. /**
  37791. * Detach the current controls from the specified dom element.
  37792. * @param element Defines the element to stop listening the inputs from
  37793. */
  37794. detachControl(element: Nullable<HTMLElement>): void;
  37795. /**
  37796. * Gets the class name of the current intput.
  37797. * @returns the class name
  37798. */
  37799. getClassName(): string;
  37800. /**
  37801. * Get the friendly name associated with the input class.
  37802. * @returns the input friendly name
  37803. */
  37804. getSimpleName(): string;
  37805. }
  37806. }
  37807. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37808. import { Nullable } from "babylonjs/types";
  37809. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37810. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37811. /**
  37812. * Listen to mouse events to control the camera.
  37813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37814. */
  37815. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37816. /**
  37817. * Defines the camera the input is attached to.
  37818. */
  37819. camera: FlyCamera;
  37820. /**
  37821. * Defines if touch is enabled. (Default is true.)
  37822. */
  37823. touchEnabled: boolean;
  37824. /**
  37825. * Defines the buttons associated with the input to handle camera rotation.
  37826. */
  37827. buttons: number[];
  37828. /**
  37829. * Assign buttons for Yaw control.
  37830. */
  37831. buttonsYaw: number[];
  37832. /**
  37833. * Assign buttons for Pitch control.
  37834. */
  37835. buttonsPitch: number[];
  37836. /**
  37837. * Assign buttons for Roll control.
  37838. */
  37839. buttonsRoll: number[];
  37840. /**
  37841. * Detect if any button is being pressed while mouse is moved.
  37842. * -1 = Mouse locked.
  37843. * 0 = Left button.
  37844. * 1 = Middle Button.
  37845. * 2 = Right Button.
  37846. */
  37847. activeButton: number;
  37848. /**
  37849. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37850. * Higher values reduce its sensitivity.
  37851. */
  37852. angularSensibility: number;
  37853. private _mousemoveCallback;
  37854. private _observer;
  37855. private _rollObserver;
  37856. private previousPosition;
  37857. private noPreventDefault;
  37858. private element;
  37859. /**
  37860. * Listen to mouse events to control the camera.
  37861. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37863. */
  37864. constructor(touchEnabled?: boolean);
  37865. /**
  37866. * Attach the mouse control to the HTML DOM element.
  37867. * @param element Defines the element that listens to the input events.
  37868. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37869. */
  37870. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37871. /**
  37872. * Detach the current controls from the specified dom element.
  37873. * @param element Defines the element to stop listening the inputs from
  37874. */
  37875. detachControl(element: Nullable<HTMLElement>): void;
  37876. /**
  37877. * Gets the class name of the current input.
  37878. * @returns the class name.
  37879. */
  37880. getClassName(): string;
  37881. /**
  37882. * Get the friendly name associated with the input class.
  37883. * @returns the input's friendly name.
  37884. */
  37885. getSimpleName(): string;
  37886. private _pointerInput;
  37887. private _onMouseMove;
  37888. /**
  37889. * Rotate camera by mouse offset.
  37890. */
  37891. private rotateCamera;
  37892. }
  37893. }
  37894. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37895. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37896. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37897. /**
  37898. * Default Inputs manager for the FlyCamera.
  37899. * It groups all the default supported inputs for ease of use.
  37900. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37901. */
  37902. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37903. /**
  37904. * Instantiates a new FlyCameraInputsManager.
  37905. * @param camera Defines the camera the inputs belong to.
  37906. */
  37907. constructor(camera: FlyCamera);
  37908. /**
  37909. * Add keyboard input support to the input manager.
  37910. * @returns the new FlyCameraKeyboardMoveInput().
  37911. */
  37912. addKeyboard(): FlyCameraInputsManager;
  37913. /**
  37914. * Add mouse input support to the input manager.
  37915. * @param touchEnabled Enable touch screen support.
  37916. * @returns the new FlyCameraMouseInput().
  37917. */
  37918. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37919. }
  37920. }
  37921. declare module "babylonjs/Cameras/flyCamera" {
  37922. import { Scene } from "babylonjs/scene";
  37923. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37925. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37926. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37927. /**
  37928. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37929. * such as in a 3D Space Shooter or a Flight Simulator.
  37930. */
  37931. export class FlyCamera extends TargetCamera {
  37932. /**
  37933. * Define the collision ellipsoid of the camera.
  37934. * This is helpful for simulating a camera body, like a player's body.
  37935. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37936. */
  37937. ellipsoid: Vector3;
  37938. /**
  37939. * Define an offset for the position of the ellipsoid around the camera.
  37940. * This can be helpful if the camera is attached away from the player's body center,
  37941. * such as at its head.
  37942. */
  37943. ellipsoidOffset: Vector3;
  37944. /**
  37945. * Enable or disable collisions of the camera with the rest of the scene objects.
  37946. */
  37947. checkCollisions: boolean;
  37948. /**
  37949. * Enable or disable gravity on the camera.
  37950. */
  37951. applyGravity: boolean;
  37952. /**
  37953. * Define the current direction the camera is moving to.
  37954. */
  37955. cameraDirection: Vector3;
  37956. /**
  37957. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37958. * This overrides and empties cameraRotation.
  37959. */
  37960. rotationQuaternion: Quaternion;
  37961. /**
  37962. * Track Roll to maintain the wanted Rolling when looking around.
  37963. */
  37964. _trackRoll: number;
  37965. /**
  37966. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37967. */
  37968. rollCorrect: number;
  37969. /**
  37970. * Mimic a banked turn, Rolling the camera when Yawing.
  37971. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37972. */
  37973. bankedTurn: boolean;
  37974. /**
  37975. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37976. */
  37977. bankedTurnLimit: number;
  37978. /**
  37979. * Value of 0 disables the banked Roll.
  37980. * Value of 1 is equal to the Yaw angle in radians.
  37981. */
  37982. bankedTurnMultiplier: number;
  37983. /**
  37984. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37985. */
  37986. inputs: FlyCameraInputsManager;
  37987. /**
  37988. * Gets the input sensibility for mouse input.
  37989. * Higher values reduce sensitivity.
  37990. */
  37991. /**
  37992. * Sets the input sensibility for a mouse input.
  37993. * Higher values reduce sensitivity.
  37994. */
  37995. angularSensibility: number;
  37996. /**
  37997. * Get the keys for camera movement forward.
  37998. */
  37999. /**
  38000. * Set the keys for camera movement forward.
  38001. */
  38002. keysForward: number[];
  38003. /**
  38004. * Get the keys for camera movement backward.
  38005. */
  38006. keysBackward: number[];
  38007. /**
  38008. * Get the keys for camera movement up.
  38009. */
  38010. /**
  38011. * Set the keys for camera movement up.
  38012. */
  38013. keysUp: number[];
  38014. /**
  38015. * Get the keys for camera movement down.
  38016. */
  38017. /**
  38018. * Set the keys for camera movement down.
  38019. */
  38020. keysDown: number[];
  38021. /**
  38022. * Get the keys for camera movement left.
  38023. */
  38024. /**
  38025. * Set the keys for camera movement left.
  38026. */
  38027. keysLeft: number[];
  38028. /**
  38029. * Set the keys for camera movement right.
  38030. */
  38031. /**
  38032. * Set the keys for camera movement right.
  38033. */
  38034. keysRight: number[];
  38035. /**
  38036. * Event raised when the camera collides with a mesh in the scene.
  38037. */
  38038. onCollide: (collidedMesh: AbstractMesh) => void;
  38039. private _collider;
  38040. private _needMoveForGravity;
  38041. private _oldPosition;
  38042. private _diffPosition;
  38043. private _newPosition;
  38044. /** @hidden */
  38045. _localDirection: Vector3;
  38046. /** @hidden */
  38047. _transformedDirection: Vector3;
  38048. /**
  38049. * Instantiates a FlyCamera.
  38050. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38051. * such as in a 3D Space Shooter or a Flight Simulator.
  38052. * @param name Define the name of the camera in the scene.
  38053. * @param position Define the starting position of the camera in the scene.
  38054. * @param scene Define the scene the camera belongs to.
  38055. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38056. */
  38057. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38058. /**
  38059. * Attach a control to the HTML DOM element.
  38060. * @param element Defines the element that listens to the input events.
  38061. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38062. */
  38063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38064. /**
  38065. * Detach a control from the HTML DOM element.
  38066. * The camera will stop reacting to that input.
  38067. * @param element Defines the element that listens to the input events.
  38068. */
  38069. detachControl(element: HTMLElement): void;
  38070. private _collisionMask;
  38071. /**
  38072. * Get the mask that the camera ignores in collision events.
  38073. */
  38074. /**
  38075. * Set the mask that the camera ignores in collision events.
  38076. */
  38077. collisionMask: number;
  38078. /** @hidden */
  38079. _collideWithWorld(displacement: Vector3): void;
  38080. /** @hidden */
  38081. private _onCollisionPositionChange;
  38082. /** @hidden */
  38083. _checkInputs(): void;
  38084. /** @hidden */
  38085. _decideIfNeedsToMove(): boolean;
  38086. /** @hidden */
  38087. _updatePosition(): void;
  38088. /**
  38089. * Restore the Roll to its target value at the rate specified.
  38090. * @param rate - Higher means slower restoring.
  38091. * @hidden
  38092. */
  38093. restoreRoll(rate: number): void;
  38094. /**
  38095. * Destroy the camera and release the current resources held by it.
  38096. */
  38097. dispose(): void;
  38098. /**
  38099. * Get the current object class name.
  38100. * @returns the class name.
  38101. */
  38102. getClassName(): string;
  38103. }
  38104. }
  38105. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38106. import { Nullable } from "babylonjs/types";
  38107. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38108. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38109. /**
  38110. * Listen to keyboard events to control the camera.
  38111. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38112. */
  38113. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38114. /**
  38115. * Defines the camera the input is attached to.
  38116. */
  38117. camera: FlyCamera;
  38118. /**
  38119. * The list of keyboard keys used to control the forward move of the camera.
  38120. */
  38121. keysForward: number[];
  38122. /**
  38123. * The list of keyboard keys used to control the backward move of the camera.
  38124. */
  38125. keysBackward: number[];
  38126. /**
  38127. * The list of keyboard keys used to control the forward move of the camera.
  38128. */
  38129. keysUp: number[];
  38130. /**
  38131. * The list of keyboard keys used to control the backward move of the camera.
  38132. */
  38133. keysDown: number[];
  38134. /**
  38135. * The list of keyboard keys used to control the right strafe move of the camera.
  38136. */
  38137. keysRight: number[];
  38138. /**
  38139. * The list of keyboard keys used to control the left strafe move of the camera.
  38140. */
  38141. keysLeft: number[];
  38142. private _keys;
  38143. private _onCanvasBlurObserver;
  38144. private _onKeyboardObserver;
  38145. private _engine;
  38146. private _scene;
  38147. /**
  38148. * Attach the input controls to a specific dom element to get the input from.
  38149. * @param element Defines the element the controls should be listened from
  38150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38151. */
  38152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38153. /**
  38154. * Detach the current controls from the specified dom element.
  38155. * @param element Defines the element to stop listening the inputs from
  38156. */
  38157. detachControl(element: Nullable<HTMLElement>): void;
  38158. /**
  38159. * Gets the class name of the current intput.
  38160. * @returns the class name
  38161. */
  38162. getClassName(): string;
  38163. /** @hidden */
  38164. _onLostFocus(e: FocusEvent): void;
  38165. /**
  38166. * Get the friendly name associated with the input class.
  38167. * @returns the input friendly name
  38168. */
  38169. getSimpleName(): string;
  38170. /**
  38171. * Update the current camera state depending on the inputs that have been used this frame.
  38172. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38173. */
  38174. checkInputs(): void;
  38175. }
  38176. }
  38177. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38178. import { Nullable } from "babylonjs/types";
  38179. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38180. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38181. /**
  38182. * Manage the mouse wheel inputs to control a follow camera.
  38183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38184. */
  38185. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38186. /**
  38187. * Defines the camera the input is attached to.
  38188. */
  38189. camera: FollowCamera;
  38190. /**
  38191. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38192. */
  38193. axisControlRadius: boolean;
  38194. /**
  38195. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38196. */
  38197. axisControlHeight: boolean;
  38198. /**
  38199. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38200. */
  38201. axisControlRotation: boolean;
  38202. /**
  38203. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38204. * relation to mouseWheel events.
  38205. */
  38206. wheelPrecision: number;
  38207. /**
  38208. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38209. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38210. */
  38211. wheelDeltaPercentage: number;
  38212. private _wheel;
  38213. private _observer;
  38214. /**
  38215. * Attach the input controls to a specific dom element to get the input from.
  38216. * @param element Defines the element the controls should be listened from
  38217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38218. */
  38219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38220. /**
  38221. * Detach the current controls from the specified dom element.
  38222. * @param element Defines the element to stop listening the inputs from
  38223. */
  38224. detachControl(element: Nullable<HTMLElement>): void;
  38225. /**
  38226. * Gets the class name of the current intput.
  38227. * @returns the class name
  38228. */
  38229. getClassName(): string;
  38230. /**
  38231. * Get the friendly name associated with the input class.
  38232. * @returns the input friendly name
  38233. */
  38234. getSimpleName(): string;
  38235. }
  38236. }
  38237. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38238. import { Nullable } from "babylonjs/types";
  38239. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38240. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38241. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38242. /**
  38243. * Manage the pointers inputs to control an follow camera.
  38244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38245. */
  38246. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38247. /**
  38248. * Defines the camera the input is attached to.
  38249. */
  38250. camera: FollowCamera;
  38251. /**
  38252. * Gets the class name of the current input.
  38253. * @returns the class name
  38254. */
  38255. getClassName(): string;
  38256. /**
  38257. * Defines the pointer angular sensibility along the X axis or how fast is
  38258. * the camera rotating.
  38259. * A negative number will reverse the axis direction.
  38260. */
  38261. angularSensibilityX: number;
  38262. /**
  38263. * Defines the pointer angular sensibility along the Y axis or how fast is
  38264. * the camera rotating.
  38265. * A negative number will reverse the axis direction.
  38266. */
  38267. angularSensibilityY: number;
  38268. /**
  38269. * Defines the pointer pinch precision or how fast is the camera zooming.
  38270. * A negative number will reverse the axis direction.
  38271. */
  38272. pinchPrecision: number;
  38273. /**
  38274. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38275. * from 0.
  38276. * It defines the percentage of current camera.radius to use as delta when
  38277. * pinch zoom is used.
  38278. */
  38279. pinchDeltaPercentage: number;
  38280. /**
  38281. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38282. */
  38283. axisXControlRadius: boolean;
  38284. /**
  38285. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38286. */
  38287. axisXControlHeight: boolean;
  38288. /**
  38289. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38290. */
  38291. axisXControlRotation: boolean;
  38292. /**
  38293. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38294. */
  38295. axisYControlRadius: boolean;
  38296. /**
  38297. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38298. */
  38299. axisYControlHeight: boolean;
  38300. /**
  38301. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38302. */
  38303. axisYControlRotation: boolean;
  38304. /**
  38305. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38306. */
  38307. axisPinchControlRadius: boolean;
  38308. /**
  38309. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38310. */
  38311. axisPinchControlHeight: boolean;
  38312. /**
  38313. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38314. */
  38315. axisPinchControlRotation: boolean;
  38316. /**
  38317. * Log error messages if basic misconfiguration has occurred.
  38318. */
  38319. warningEnable: boolean;
  38320. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38321. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38322. private _warningCounter;
  38323. private _warning;
  38324. }
  38325. }
  38326. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38327. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38328. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38329. /**
  38330. * Default Inputs manager for the FollowCamera.
  38331. * It groups all the default supported inputs for ease of use.
  38332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38333. */
  38334. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38335. /**
  38336. * Instantiates a new FollowCameraInputsManager.
  38337. * @param camera Defines the camera the inputs belong to
  38338. */
  38339. constructor(camera: FollowCamera);
  38340. /**
  38341. * Add keyboard input support to the input manager.
  38342. * @returns the current input manager
  38343. */
  38344. addKeyboard(): FollowCameraInputsManager;
  38345. /**
  38346. * Add mouse wheel input support to the input manager.
  38347. * @returns the current input manager
  38348. */
  38349. addMouseWheel(): FollowCameraInputsManager;
  38350. /**
  38351. * Add pointers input support to the input manager.
  38352. * @returns the current input manager
  38353. */
  38354. addPointers(): FollowCameraInputsManager;
  38355. /**
  38356. * Add orientation input support to the input manager.
  38357. * @returns the current input manager
  38358. */
  38359. addVRDeviceOrientation(): FollowCameraInputsManager;
  38360. }
  38361. }
  38362. declare module "babylonjs/Cameras/followCamera" {
  38363. import { Nullable } from "babylonjs/types";
  38364. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38365. import { Scene } from "babylonjs/scene";
  38366. import { Vector3 } from "babylonjs/Maths/math";
  38367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38368. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38369. /**
  38370. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38371. * an arc rotate version arcFollowCamera are available.
  38372. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38373. */
  38374. export class FollowCamera extends TargetCamera {
  38375. /**
  38376. * Distance the follow camera should follow an object at
  38377. */
  38378. radius: number;
  38379. /**
  38380. * Minimum allowed distance of the camera to the axis of rotation
  38381. * (The camera can not get closer).
  38382. * This can help limiting how the Camera is able to move in the scene.
  38383. */
  38384. lowerRadiusLimit: Nullable<number>;
  38385. /**
  38386. * Maximum allowed distance of the camera to the axis of rotation
  38387. * (The camera can not get further).
  38388. * This can help limiting how the Camera is able to move in the scene.
  38389. */
  38390. upperRadiusLimit: Nullable<number>;
  38391. /**
  38392. * Define a rotation offset between the camera and the object it follows
  38393. */
  38394. rotationOffset: number;
  38395. /**
  38396. * Minimum allowed angle to camera position relative to target object.
  38397. * This can help limiting how the Camera is able to move in the scene.
  38398. */
  38399. lowerRotationOffsetLimit: Nullable<number>;
  38400. /**
  38401. * Maximum allowed angle to camera position relative to target object.
  38402. * This can help limiting how the Camera is able to move in the scene.
  38403. */
  38404. upperRotationOffsetLimit: Nullable<number>;
  38405. /**
  38406. * Define a height offset between the camera and the object it follows.
  38407. * It can help following an object from the top (like a car chaing a plane)
  38408. */
  38409. heightOffset: number;
  38410. /**
  38411. * Minimum allowed height of camera position relative to target object.
  38412. * This can help limiting how the Camera is able to move in the scene.
  38413. */
  38414. lowerHeightOffsetLimit: Nullable<number>;
  38415. /**
  38416. * Maximum allowed height of camera position relative to target object.
  38417. * This can help limiting how the Camera is able to move in the scene.
  38418. */
  38419. upperHeightOffsetLimit: Nullable<number>;
  38420. /**
  38421. * Define how fast the camera can accelerate to follow it s target.
  38422. */
  38423. cameraAcceleration: number;
  38424. /**
  38425. * Define the speed limit of the camera following an object.
  38426. */
  38427. maxCameraSpeed: number;
  38428. /**
  38429. * Define the target of the camera.
  38430. */
  38431. lockedTarget: Nullable<AbstractMesh>;
  38432. /**
  38433. * Defines the input associated with the camera.
  38434. */
  38435. inputs: FollowCameraInputsManager;
  38436. /**
  38437. * Instantiates the follow camera.
  38438. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38439. * @param name Define the name of the camera in the scene
  38440. * @param position Define the position of the camera
  38441. * @param scene Define the scene the camera belong to
  38442. * @param lockedTarget Define the target of the camera
  38443. */
  38444. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38445. private _follow;
  38446. /**
  38447. * Attached controls to the current camera.
  38448. * @param element Defines the element the controls should be listened from
  38449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38450. */
  38451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38452. /**
  38453. * Detach the current controls from the camera.
  38454. * The camera will stop reacting to inputs.
  38455. * @param element Defines the element to stop listening the inputs from
  38456. */
  38457. detachControl(element: HTMLElement): void;
  38458. /** @hidden */
  38459. _checkInputs(): void;
  38460. private _checkLimits;
  38461. /**
  38462. * Gets the camera class name.
  38463. * @returns the class name
  38464. */
  38465. getClassName(): string;
  38466. }
  38467. /**
  38468. * Arc Rotate version of the follow camera.
  38469. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38470. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38471. */
  38472. export class ArcFollowCamera extends TargetCamera {
  38473. /** The longitudinal angle of the camera */
  38474. alpha: number;
  38475. /** The latitudinal angle of the camera */
  38476. beta: number;
  38477. /** The radius of the camera from its target */
  38478. radius: number;
  38479. /** Define the camera target (the messh it should follow) */
  38480. target: Nullable<AbstractMesh>;
  38481. private _cartesianCoordinates;
  38482. /**
  38483. * Instantiates a new ArcFollowCamera
  38484. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38485. * @param name Define the name of the camera
  38486. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38487. * @param beta Define the rotation angle of the camera around the elevation axis
  38488. * @param radius Define the radius of the camera from its target point
  38489. * @param target Define the target of the camera
  38490. * @param scene Define the scene the camera belongs to
  38491. */
  38492. constructor(name: string,
  38493. /** The longitudinal angle of the camera */
  38494. alpha: number,
  38495. /** The latitudinal angle of the camera */
  38496. beta: number,
  38497. /** The radius of the camera from its target */
  38498. radius: number,
  38499. /** Define the camera target (the messh it should follow) */
  38500. target: Nullable<AbstractMesh>, scene: Scene);
  38501. private _follow;
  38502. /** @hidden */
  38503. _checkInputs(): void;
  38504. /**
  38505. * Returns the class name of the object.
  38506. * It is mostly used internally for serialization purposes.
  38507. */
  38508. getClassName(): string;
  38509. }
  38510. }
  38511. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38512. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38513. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38514. import { Nullable } from "babylonjs/types";
  38515. /**
  38516. * Manage the keyboard inputs to control the movement of a follow camera.
  38517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38518. */
  38519. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38520. /**
  38521. * Defines the camera the input is attached to.
  38522. */
  38523. camera: FollowCamera;
  38524. /**
  38525. * Defines the list of key codes associated with the up action (increase heightOffset)
  38526. */
  38527. keysHeightOffsetIncr: number[];
  38528. /**
  38529. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38530. */
  38531. keysHeightOffsetDecr: number[];
  38532. /**
  38533. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38534. */
  38535. keysHeightOffsetModifierAlt: boolean;
  38536. /**
  38537. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38538. */
  38539. keysHeightOffsetModifierCtrl: boolean;
  38540. /**
  38541. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38542. */
  38543. keysHeightOffsetModifierShift: boolean;
  38544. /**
  38545. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38546. */
  38547. keysRotationOffsetIncr: number[];
  38548. /**
  38549. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38550. */
  38551. keysRotationOffsetDecr: number[];
  38552. /**
  38553. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38554. */
  38555. keysRotationOffsetModifierAlt: boolean;
  38556. /**
  38557. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38558. */
  38559. keysRotationOffsetModifierCtrl: boolean;
  38560. /**
  38561. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38562. */
  38563. keysRotationOffsetModifierShift: boolean;
  38564. /**
  38565. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38566. */
  38567. keysRadiusIncr: number[];
  38568. /**
  38569. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38570. */
  38571. keysRadiusDecr: number[];
  38572. /**
  38573. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38574. */
  38575. keysRadiusModifierAlt: boolean;
  38576. /**
  38577. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38578. */
  38579. keysRadiusModifierCtrl: boolean;
  38580. /**
  38581. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38582. */
  38583. keysRadiusModifierShift: boolean;
  38584. /**
  38585. * Defines the rate of change of heightOffset.
  38586. */
  38587. heightSensibility: number;
  38588. /**
  38589. * Defines the rate of change of rotationOffset.
  38590. */
  38591. rotationSensibility: number;
  38592. /**
  38593. * Defines the rate of change of radius.
  38594. */
  38595. radiusSensibility: number;
  38596. private _keys;
  38597. private _ctrlPressed;
  38598. private _altPressed;
  38599. private _shiftPressed;
  38600. private _onCanvasBlurObserver;
  38601. private _onKeyboardObserver;
  38602. private _engine;
  38603. private _scene;
  38604. /**
  38605. * Attach the input controls to a specific dom element to get the input from.
  38606. * @param element Defines the element the controls should be listened from
  38607. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38608. */
  38609. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38610. /**
  38611. * Detach the current controls from the specified dom element.
  38612. * @param element Defines the element to stop listening the inputs from
  38613. */
  38614. detachControl(element: Nullable<HTMLElement>): void;
  38615. /**
  38616. * Update the current camera state depending on the inputs that have been used this frame.
  38617. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38618. */
  38619. checkInputs(): void;
  38620. /**
  38621. * Gets the class name of the current input.
  38622. * @returns the class name
  38623. */
  38624. getClassName(): string;
  38625. /**
  38626. * Get the friendly name associated with the input class.
  38627. * @returns the input friendly name
  38628. */
  38629. getSimpleName(): string;
  38630. /**
  38631. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38632. * allow modification of the heightOffset value.
  38633. */
  38634. private _modifierHeightOffset;
  38635. /**
  38636. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38637. * allow modification of the rotationOffset value.
  38638. */
  38639. private _modifierRotationOffset;
  38640. /**
  38641. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38642. * allow modification of the radius value.
  38643. */
  38644. private _modifierRadius;
  38645. }
  38646. }
  38647. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38648. import { Nullable } from "babylonjs/types";
  38649. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38650. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38651. import { Observable } from "babylonjs/Misc/observable";
  38652. module "babylonjs/Cameras/freeCameraInputsManager" {
  38653. interface FreeCameraInputsManager {
  38654. /**
  38655. * @hidden
  38656. */
  38657. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38658. /**
  38659. * Add orientation input support to the input manager.
  38660. * @returns the current input manager
  38661. */
  38662. addDeviceOrientation(): FreeCameraInputsManager;
  38663. }
  38664. }
  38665. /**
  38666. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38667. * Screen rotation is taken into account.
  38668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38669. */
  38670. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38671. private _camera;
  38672. private _screenOrientationAngle;
  38673. private _constantTranform;
  38674. private _screenQuaternion;
  38675. private _alpha;
  38676. private _beta;
  38677. private _gamma;
  38678. /**
  38679. * Can be used to detect if a device orientation sensor is availible on a device
  38680. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38681. * @returns a promise that will resolve on orientation change
  38682. */
  38683. static WaitForOrientationChangeAsync(timeout?: number): Promise<{}>;
  38684. /**
  38685. * @hidden
  38686. */
  38687. _onDeviceOrientationChangedObservable: Observable<void>;
  38688. /**
  38689. * Instantiates a new input
  38690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38691. */
  38692. constructor();
  38693. /**
  38694. * Define the camera controlled by the input.
  38695. */
  38696. camera: FreeCamera;
  38697. /**
  38698. * Attach the input controls to a specific dom element to get the input from.
  38699. * @param element Defines the element the controls should be listened from
  38700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38701. */
  38702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38703. private _orientationChanged;
  38704. private _deviceOrientation;
  38705. /**
  38706. * Detach the current controls from the specified dom element.
  38707. * @param element Defines the element to stop listening the inputs from
  38708. */
  38709. detachControl(element: Nullable<HTMLElement>): void;
  38710. /**
  38711. * Update the current camera state depending on the inputs that have been used this frame.
  38712. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38713. */
  38714. checkInputs(): void;
  38715. /**
  38716. * Gets the class name of the current intput.
  38717. * @returns the class name
  38718. */
  38719. getClassName(): string;
  38720. /**
  38721. * Get the friendly name associated with the input class.
  38722. * @returns the input friendly name
  38723. */
  38724. getSimpleName(): string;
  38725. }
  38726. }
  38727. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38728. import { Nullable } from "babylonjs/types";
  38729. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38730. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38731. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38732. /**
  38733. * Manage the gamepad inputs to control a free camera.
  38734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38735. */
  38736. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38737. /**
  38738. * Define the camera the input is attached to.
  38739. */
  38740. camera: FreeCamera;
  38741. /**
  38742. * Define the Gamepad controlling the input
  38743. */
  38744. gamepad: Nullable<Gamepad>;
  38745. /**
  38746. * Defines the gamepad rotation sensiblity.
  38747. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38748. */
  38749. gamepadAngularSensibility: number;
  38750. /**
  38751. * Defines the gamepad move sensiblity.
  38752. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38753. */
  38754. gamepadMoveSensibility: number;
  38755. private _onGamepadConnectedObserver;
  38756. private _onGamepadDisconnectedObserver;
  38757. private _cameraTransform;
  38758. private _deltaTransform;
  38759. private _vector3;
  38760. private _vector2;
  38761. /**
  38762. * Attach the input controls to a specific dom element to get the input from.
  38763. * @param element Defines the element the controls should be listened from
  38764. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38765. */
  38766. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38767. /**
  38768. * Detach the current controls from the specified dom element.
  38769. * @param element Defines the element to stop listening the inputs from
  38770. */
  38771. detachControl(element: Nullable<HTMLElement>): void;
  38772. /**
  38773. * Update the current camera state depending on the inputs that have been used this frame.
  38774. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38775. */
  38776. checkInputs(): void;
  38777. /**
  38778. * Gets the class name of the current intput.
  38779. * @returns the class name
  38780. */
  38781. getClassName(): string;
  38782. /**
  38783. * Get the friendly name associated with the input class.
  38784. * @returns the input friendly name
  38785. */
  38786. getSimpleName(): string;
  38787. }
  38788. }
  38789. declare module "babylonjs/Misc/virtualJoystick" {
  38790. import { Nullable } from "babylonjs/types";
  38791. import { Vector3 } from "babylonjs/Maths/math";
  38792. /**
  38793. * Defines the potential axis of a Joystick
  38794. */
  38795. export enum JoystickAxis {
  38796. /** X axis */
  38797. X = 0,
  38798. /** Y axis */
  38799. Y = 1,
  38800. /** Z axis */
  38801. Z = 2
  38802. }
  38803. /**
  38804. * Class used to define virtual joystick (used in touch mode)
  38805. */
  38806. export class VirtualJoystick {
  38807. /**
  38808. * Gets or sets a boolean indicating that left and right values must be inverted
  38809. */
  38810. reverseLeftRight: boolean;
  38811. /**
  38812. * Gets or sets a boolean indicating that up and down values must be inverted
  38813. */
  38814. reverseUpDown: boolean;
  38815. /**
  38816. * Gets the offset value for the position (ie. the change of the position value)
  38817. */
  38818. deltaPosition: Vector3;
  38819. /**
  38820. * Gets a boolean indicating if the virtual joystick was pressed
  38821. */
  38822. pressed: boolean;
  38823. /**
  38824. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38825. */
  38826. static Canvas: Nullable<HTMLCanvasElement>;
  38827. private static _globalJoystickIndex;
  38828. private static vjCanvasContext;
  38829. private static vjCanvasWidth;
  38830. private static vjCanvasHeight;
  38831. private static halfWidth;
  38832. private _action;
  38833. private _axisTargetedByLeftAndRight;
  38834. private _axisTargetedByUpAndDown;
  38835. private _joystickSensibility;
  38836. private _inversedSensibility;
  38837. private _joystickPointerID;
  38838. private _joystickColor;
  38839. private _joystickPointerPos;
  38840. private _joystickPreviousPointerPos;
  38841. private _joystickPointerStartPos;
  38842. private _deltaJoystickVector;
  38843. private _leftJoystick;
  38844. private _touches;
  38845. private _onPointerDownHandlerRef;
  38846. private _onPointerMoveHandlerRef;
  38847. private _onPointerUpHandlerRef;
  38848. private _onResize;
  38849. /**
  38850. * Creates a new virtual joystick
  38851. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38852. */
  38853. constructor(leftJoystick?: boolean);
  38854. /**
  38855. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38856. * @param newJoystickSensibility defines the new sensibility
  38857. */
  38858. setJoystickSensibility(newJoystickSensibility: number): void;
  38859. private _onPointerDown;
  38860. private _onPointerMove;
  38861. private _onPointerUp;
  38862. /**
  38863. * Change the color of the virtual joystick
  38864. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38865. */
  38866. setJoystickColor(newColor: string): void;
  38867. /**
  38868. * Defines a callback to call when the joystick is touched
  38869. * @param action defines the callback
  38870. */
  38871. setActionOnTouch(action: () => any): void;
  38872. /**
  38873. * Defines which axis you'd like to control for left & right
  38874. * @param axis defines the axis to use
  38875. */
  38876. setAxisForLeftRight(axis: JoystickAxis): void;
  38877. /**
  38878. * Defines which axis you'd like to control for up & down
  38879. * @param axis defines the axis to use
  38880. */
  38881. setAxisForUpDown(axis: JoystickAxis): void;
  38882. private _drawVirtualJoystick;
  38883. /**
  38884. * Release internal HTML canvas
  38885. */
  38886. releaseCanvas(): void;
  38887. }
  38888. }
  38889. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38890. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38891. import { Nullable } from "babylonjs/types";
  38892. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38893. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38894. module "babylonjs/Cameras/freeCameraInputsManager" {
  38895. interface FreeCameraInputsManager {
  38896. /**
  38897. * Add virtual joystick input support to the input manager.
  38898. * @returns the current input manager
  38899. */
  38900. addVirtualJoystick(): FreeCameraInputsManager;
  38901. }
  38902. }
  38903. /**
  38904. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38906. */
  38907. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38908. /**
  38909. * Defines the camera the input is attached to.
  38910. */
  38911. camera: FreeCamera;
  38912. private _leftjoystick;
  38913. private _rightjoystick;
  38914. /**
  38915. * Gets the left stick of the virtual joystick.
  38916. * @returns The virtual Joystick
  38917. */
  38918. getLeftJoystick(): VirtualJoystick;
  38919. /**
  38920. * Gets the right stick of the virtual joystick.
  38921. * @returns The virtual Joystick
  38922. */
  38923. getRightJoystick(): VirtualJoystick;
  38924. /**
  38925. * Update the current camera state depending on the inputs that have been used this frame.
  38926. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38927. */
  38928. checkInputs(): void;
  38929. /**
  38930. * Attach the input controls to a specific dom element to get the input from.
  38931. * @param element Defines the element the controls should be listened from
  38932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38933. */
  38934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38935. /**
  38936. * Detach the current controls from the specified dom element.
  38937. * @param element Defines the element to stop listening the inputs from
  38938. */
  38939. detachControl(element: Nullable<HTMLElement>): void;
  38940. /**
  38941. * Gets the class name of the current intput.
  38942. * @returns the class name
  38943. */
  38944. getClassName(): string;
  38945. /**
  38946. * Get the friendly name associated with the input class.
  38947. * @returns the input friendly name
  38948. */
  38949. getSimpleName(): string;
  38950. }
  38951. }
  38952. declare module "babylonjs/Cameras/Inputs/index" {
  38953. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38954. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38955. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38956. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38957. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38958. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38959. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38960. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38961. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38962. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38963. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38964. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38965. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38966. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38967. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38968. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38969. }
  38970. declare module "babylonjs/Cameras/touchCamera" {
  38971. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38972. import { Scene } from "babylonjs/scene";
  38973. import { Vector3 } from "babylonjs/Maths/math";
  38974. /**
  38975. * This represents a FPS type of camera controlled by touch.
  38976. * This is like a universal camera minus the Gamepad controls.
  38977. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38978. */
  38979. export class TouchCamera extends FreeCamera {
  38980. /**
  38981. * Defines the touch sensibility for rotation.
  38982. * The higher the faster.
  38983. */
  38984. touchAngularSensibility: number;
  38985. /**
  38986. * Defines the touch sensibility for move.
  38987. * The higher the faster.
  38988. */
  38989. touchMoveSensibility: number;
  38990. /**
  38991. * Instantiates a new touch camera.
  38992. * This represents a FPS type of camera controlled by touch.
  38993. * This is like a universal camera minus the Gamepad controls.
  38994. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38995. * @param name Define the name of the camera in the scene
  38996. * @param position Define the start position of the camera in the scene
  38997. * @param scene Define the scene the camera belongs to
  38998. */
  38999. constructor(name: string, position: Vector3, scene: Scene);
  39000. /**
  39001. * Gets the current object class name.
  39002. * @return the class name
  39003. */
  39004. getClassName(): string;
  39005. /** @hidden */
  39006. _setupInputs(): void;
  39007. }
  39008. }
  39009. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39010. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39011. import { Scene } from "babylonjs/scene";
  39012. import { Vector3, Axis } from "babylonjs/Maths/math";
  39013. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39014. /**
  39015. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39016. * being tilted forward or back and left or right.
  39017. */
  39018. export class DeviceOrientationCamera extends FreeCamera {
  39019. private _initialQuaternion;
  39020. private _quaternionCache;
  39021. private _tmpDragQuaternion;
  39022. /**
  39023. * Creates a new device orientation camera
  39024. * @param name The name of the camera
  39025. * @param position The start position camera
  39026. * @param scene The scene the camera belongs to
  39027. */
  39028. constructor(name: string, position: Vector3, scene: Scene);
  39029. /**
  39030. * @hidden
  39031. * Disabled pointer input on first orientation sensor update (Default: true)
  39032. */
  39033. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39034. private _dragFactor;
  39035. /**
  39036. * Enabled turning on the y axis when the orientation sensor is active
  39037. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39038. */
  39039. enableHorizontalDragging(dragFactor?: number): void;
  39040. /**
  39041. * Gets the current instance class name ("DeviceOrientationCamera").
  39042. * This helps avoiding instanceof at run time.
  39043. * @returns the class name
  39044. */
  39045. getClassName(): string;
  39046. /**
  39047. * @hidden
  39048. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39049. */
  39050. _checkInputs(): void;
  39051. /**
  39052. * Reset the camera to its default orientation on the specified axis only.
  39053. * @param axis The axis to reset
  39054. */
  39055. resetToCurrentRotation(axis?: Axis): void;
  39056. }
  39057. }
  39058. declare module "babylonjs/Gamepads/xboxGamepad" {
  39059. import { Observable } from "babylonjs/Misc/observable";
  39060. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39061. /**
  39062. * Defines supported buttons for XBox360 compatible gamepads
  39063. */
  39064. export enum Xbox360Button {
  39065. /** A */
  39066. A = 0,
  39067. /** B */
  39068. B = 1,
  39069. /** X */
  39070. X = 2,
  39071. /** Y */
  39072. Y = 3,
  39073. /** Start */
  39074. Start = 4,
  39075. /** Back */
  39076. Back = 5,
  39077. /** Left button */
  39078. LB = 6,
  39079. /** Right button */
  39080. RB = 7,
  39081. /** Left stick */
  39082. LeftStick = 8,
  39083. /** Right stick */
  39084. RightStick = 9
  39085. }
  39086. /** Defines values for XBox360 DPad */
  39087. export enum Xbox360Dpad {
  39088. /** Up */
  39089. Up = 0,
  39090. /** Down */
  39091. Down = 1,
  39092. /** Left */
  39093. Left = 2,
  39094. /** Right */
  39095. Right = 3
  39096. }
  39097. /**
  39098. * Defines a XBox360 gamepad
  39099. */
  39100. export class Xbox360Pad extends Gamepad {
  39101. private _leftTrigger;
  39102. private _rightTrigger;
  39103. private _onlefttriggerchanged;
  39104. private _onrighttriggerchanged;
  39105. private _onbuttondown;
  39106. private _onbuttonup;
  39107. private _ondpaddown;
  39108. private _ondpadup;
  39109. /** Observable raised when a button is pressed */
  39110. onButtonDownObservable: Observable<Xbox360Button>;
  39111. /** Observable raised when a button is released */
  39112. onButtonUpObservable: Observable<Xbox360Button>;
  39113. /** Observable raised when a pad is pressed */
  39114. onPadDownObservable: Observable<Xbox360Dpad>;
  39115. /** Observable raised when a pad is released */
  39116. onPadUpObservable: Observable<Xbox360Dpad>;
  39117. private _buttonA;
  39118. private _buttonB;
  39119. private _buttonX;
  39120. private _buttonY;
  39121. private _buttonBack;
  39122. private _buttonStart;
  39123. private _buttonLB;
  39124. private _buttonRB;
  39125. private _buttonLeftStick;
  39126. private _buttonRightStick;
  39127. private _dPadUp;
  39128. private _dPadDown;
  39129. private _dPadLeft;
  39130. private _dPadRight;
  39131. private _isXboxOnePad;
  39132. /**
  39133. * Creates a new XBox360 gamepad object
  39134. * @param id defines the id of this gamepad
  39135. * @param index defines its index
  39136. * @param gamepad defines the internal HTML gamepad object
  39137. * @param xboxOne defines if it is a XBox One gamepad
  39138. */
  39139. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39140. /**
  39141. * Defines the callback to call when left trigger is pressed
  39142. * @param callback defines the callback to use
  39143. */
  39144. onlefttriggerchanged(callback: (value: number) => void): void;
  39145. /**
  39146. * Defines the callback to call when right trigger is pressed
  39147. * @param callback defines the callback to use
  39148. */
  39149. onrighttriggerchanged(callback: (value: number) => void): void;
  39150. /**
  39151. * Gets the left trigger value
  39152. */
  39153. /**
  39154. * Sets the left trigger value
  39155. */
  39156. leftTrigger: number;
  39157. /**
  39158. * Gets the right trigger value
  39159. */
  39160. /**
  39161. * Sets the right trigger value
  39162. */
  39163. rightTrigger: number;
  39164. /**
  39165. * Defines the callback to call when a button is pressed
  39166. * @param callback defines the callback to use
  39167. */
  39168. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39169. /**
  39170. * Defines the callback to call when a button is released
  39171. * @param callback defines the callback to use
  39172. */
  39173. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39174. /**
  39175. * Defines the callback to call when a pad is pressed
  39176. * @param callback defines the callback to use
  39177. */
  39178. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39179. /**
  39180. * Defines the callback to call when a pad is released
  39181. * @param callback defines the callback to use
  39182. */
  39183. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39184. private _setButtonValue;
  39185. private _setDPadValue;
  39186. /**
  39187. * Gets the value of the `A` button
  39188. */
  39189. /**
  39190. * Sets the value of the `A` button
  39191. */
  39192. buttonA: number;
  39193. /**
  39194. * Gets the value of the `B` button
  39195. */
  39196. /**
  39197. * Sets the value of the `B` button
  39198. */
  39199. buttonB: number;
  39200. /**
  39201. * Gets the value of the `X` button
  39202. */
  39203. /**
  39204. * Sets the value of the `X` button
  39205. */
  39206. buttonX: number;
  39207. /**
  39208. * Gets the value of the `Y` button
  39209. */
  39210. /**
  39211. * Sets the value of the `Y` button
  39212. */
  39213. buttonY: number;
  39214. /**
  39215. * Gets the value of the `Start` button
  39216. */
  39217. /**
  39218. * Sets the value of the `Start` button
  39219. */
  39220. buttonStart: number;
  39221. /**
  39222. * Gets the value of the `Back` button
  39223. */
  39224. /**
  39225. * Sets the value of the `Back` button
  39226. */
  39227. buttonBack: number;
  39228. /**
  39229. * Gets the value of the `Left` button
  39230. */
  39231. /**
  39232. * Sets the value of the `Left` button
  39233. */
  39234. buttonLB: number;
  39235. /**
  39236. * Gets the value of the `Right` button
  39237. */
  39238. /**
  39239. * Sets the value of the `Right` button
  39240. */
  39241. buttonRB: number;
  39242. /**
  39243. * Gets the value of the Left joystick
  39244. */
  39245. /**
  39246. * Sets the value of the Left joystick
  39247. */
  39248. buttonLeftStick: number;
  39249. /**
  39250. * Gets the value of the Right joystick
  39251. */
  39252. /**
  39253. * Sets the value of the Right joystick
  39254. */
  39255. buttonRightStick: number;
  39256. /**
  39257. * Gets the value of D-pad up
  39258. */
  39259. /**
  39260. * Sets the value of D-pad up
  39261. */
  39262. dPadUp: number;
  39263. /**
  39264. * Gets the value of D-pad down
  39265. */
  39266. /**
  39267. * Sets the value of D-pad down
  39268. */
  39269. dPadDown: number;
  39270. /**
  39271. * Gets the value of D-pad left
  39272. */
  39273. /**
  39274. * Sets the value of D-pad left
  39275. */
  39276. dPadLeft: number;
  39277. /**
  39278. * Gets the value of D-pad right
  39279. */
  39280. /**
  39281. * Sets the value of D-pad right
  39282. */
  39283. dPadRight: number;
  39284. /**
  39285. * Force the gamepad to synchronize with device values
  39286. */
  39287. update(): void;
  39288. /**
  39289. * Disposes the gamepad
  39290. */
  39291. dispose(): void;
  39292. }
  39293. }
  39294. declare module "babylonjs/Gamepads/gamepadManager" {
  39295. import { Observable } from "babylonjs/Misc/observable";
  39296. import { Nullable } from "babylonjs/types";
  39297. import { Scene } from "babylonjs/scene";
  39298. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39299. /**
  39300. * Manager for handling gamepads
  39301. */
  39302. export class GamepadManager {
  39303. private _scene?;
  39304. private _babylonGamepads;
  39305. private _oneGamepadConnected;
  39306. /** @hidden */
  39307. _isMonitoring: boolean;
  39308. private _gamepadEventSupported;
  39309. private _gamepadSupport;
  39310. /**
  39311. * observable to be triggered when the gamepad controller has been connected
  39312. */
  39313. onGamepadConnectedObservable: Observable<Gamepad>;
  39314. /**
  39315. * observable to be triggered when the gamepad controller has been disconnected
  39316. */
  39317. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39318. private _onGamepadConnectedEvent;
  39319. private _onGamepadDisconnectedEvent;
  39320. /**
  39321. * Initializes the gamepad manager
  39322. * @param _scene BabylonJS scene
  39323. */
  39324. constructor(_scene?: Scene | undefined);
  39325. /**
  39326. * The gamepads in the game pad manager
  39327. */
  39328. readonly gamepads: Gamepad[];
  39329. /**
  39330. * Get the gamepad controllers based on type
  39331. * @param type The type of gamepad controller
  39332. * @returns Nullable gamepad
  39333. */
  39334. getGamepadByType(type?: number): Nullable<Gamepad>;
  39335. /**
  39336. * Disposes the gamepad manager
  39337. */
  39338. dispose(): void;
  39339. private _addNewGamepad;
  39340. private _startMonitoringGamepads;
  39341. private _stopMonitoringGamepads;
  39342. /** @hidden */
  39343. _checkGamepadsStatus(): void;
  39344. private _updateGamepadObjects;
  39345. }
  39346. }
  39347. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39348. import { Nullable } from "babylonjs/types";
  39349. import { Scene } from "babylonjs/scene";
  39350. import { ISceneComponent } from "babylonjs/sceneComponent";
  39351. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39352. module "babylonjs/scene" {
  39353. interface Scene {
  39354. /** @hidden */
  39355. _gamepadManager: Nullable<GamepadManager>;
  39356. /**
  39357. * Gets the gamepad manager associated with the scene
  39358. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39359. */
  39360. gamepadManager: GamepadManager;
  39361. }
  39362. }
  39363. module "babylonjs/Cameras/freeCameraInputsManager" {
  39364. /**
  39365. * Interface representing a free camera inputs manager
  39366. */
  39367. interface FreeCameraInputsManager {
  39368. /**
  39369. * Adds gamepad input support to the FreeCameraInputsManager.
  39370. * @returns the FreeCameraInputsManager
  39371. */
  39372. addGamepad(): FreeCameraInputsManager;
  39373. }
  39374. }
  39375. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39376. /**
  39377. * Interface representing an arc rotate camera inputs manager
  39378. */
  39379. interface ArcRotateCameraInputsManager {
  39380. /**
  39381. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39382. * @returns the camera inputs manager
  39383. */
  39384. addGamepad(): ArcRotateCameraInputsManager;
  39385. }
  39386. }
  39387. /**
  39388. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39389. */
  39390. export class GamepadSystemSceneComponent implements ISceneComponent {
  39391. /**
  39392. * The component name helpfull to identify the component in the list of scene components.
  39393. */
  39394. readonly name: string;
  39395. /**
  39396. * The scene the component belongs to.
  39397. */
  39398. scene: Scene;
  39399. /**
  39400. * Creates a new instance of the component for the given scene
  39401. * @param scene Defines the scene to register the component in
  39402. */
  39403. constructor(scene: Scene);
  39404. /**
  39405. * Registers the component in a given scene
  39406. */
  39407. register(): void;
  39408. /**
  39409. * Rebuilds the elements related to this component in case of
  39410. * context lost for instance.
  39411. */
  39412. rebuild(): void;
  39413. /**
  39414. * Disposes the component and the associated ressources
  39415. */
  39416. dispose(): void;
  39417. private _beforeCameraUpdate;
  39418. }
  39419. }
  39420. declare module "babylonjs/Cameras/universalCamera" {
  39421. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39422. import { Scene } from "babylonjs/scene";
  39423. import { Vector3 } from "babylonjs/Maths/math";
  39424. import "babylonjs/Gamepads/gamepadSceneComponent";
  39425. /**
  39426. * 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,
  39427. * which still works and will still be found in many Playgrounds.
  39428. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39429. */
  39430. export class UniversalCamera extends TouchCamera {
  39431. /**
  39432. * Defines the gamepad rotation sensiblity.
  39433. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39434. */
  39435. gamepadAngularSensibility: number;
  39436. /**
  39437. * Defines the gamepad move sensiblity.
  39438. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39439. */
  39440. gamepadMoveSensibility: number;
  39441. /**
  39442. * 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,
  39443. * which still works and will still be found in many Playgrounds.
  39444. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39445. * @param name Define the name of the camera in the scene
  39446. * @param position Define the start position of the camera in the scene
  39447. * @param scene Define the scene the camera belongs to
  39448. */
  39449. constructor(name: string, position: Vector3, scene: Scene);
  39450. /**
  39451. * Gets the current object class name.
  39452. * @return the class name
  39453. */
  39454. getClassName(): string;
  39455. }
  39456. }
  39457. declare module "babylonjs/Cameras/gamepadCamera" {
  39458. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39459. import { Scene } from "babylonjs/scene";
  39460. import { Vector3 } from "babylonjs/Maths/math";
  39461. /**
  39462. * This represents a FPS type of camera. This is only here for back compat purpose.
  39463. * Please use the UniversalCamera instead as both are identical.
  39464. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39465. */
  39466. export class GamepadCamera extends UniversalCamera {
  39467. /**
  39468. * Instantiates a new Gamepad Camera
  39469. * This represents a FPS type of camera. This is only here for back compat purpose.
  39470. * Please use the UniversalCamera instead as both are identical.
  39471. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39472. * @param name Define the name of the camera in the scene
  39473. * @param position Define the start position of the camera in the scene
  39474. * @param scene Define the scene the camera belongs to
  39475. */
  39476. constructor(name: string, position: Vector3, scene: Scene);
  39477. /**
  39478. * Gets the current object class name.
  39479. * @return the class name
  39480. */
  39481. getClassName(): string;
  39482. }
  39483. }
  39484. declare module "babylonjs/Shaders/pass.fragment" {
  39485. /** @hidden */
  39486. export var passPixelShader: {
  39487. name: string;
  39488. shader: string;
  39489. };
  39490. }
  39491. declare module "babylonjs/Shaders/passCube.fragment" {
  39492. /** @hidden */
  39493. export var passCubePixelShader: {
  39494. name: string;
  39495. shader: string;
  39496. };
  39497. }
  39498. declare module "babylonjs/PostProcesses/passPostProcess" {
  39499. import { Nullable } from "babylonjs/types";
  39500. import { Camera } from "babylonjs/Cameras/camera";
  39501. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39502. import { Engine } from "babylonjs/Engines/engine";
  39503. import "babylonjs/Shaders/pass.fragment";
  39504. import "babylonjs/Shaders/passCube.fragment";
  39505. /**
  39506. * PassPostProcess which produces an output the same as it's input
  39507. */
  39508. export class PassPostProcess extends PostProcess {
  39509. /**
  39510. * Creates the PassPostProcess
  39511. * @param name The name of the effect.
  39512. * @param options The required width/height ratio to downsize to before computing the render pass.
  39513. * @param camera The camera to apply the render pass to.
  39514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39515. * @param engine The engine which the post process will be applied. (default: current engine)
  39516. * @param reusable If the post process can be reused on the same frame. (default: false)
  39517. * @param textureType The type of texture to be used when performing the post processing.
  39518. * @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)
  39519. */
  39520. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39521. }
  39522. /**
  39523. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39524. */
  39525. export class PassCubePostProcess extends PostProcess {
  39526. private _face;
  39527. /**
  39528. * Gets or sets the cube face to display.
  39529. * * 0 is +X
  39530. * * 1 is -X
  39531. * * 2 is +Y
  39532. * * 3 is -Y
  39533. * * 4 is +Z
  39534. * * 5 is -Z
  39535. */
  39536. face: number;
  39537. /**
  39538. * Creates the PassCubePostProcess
  39539. * @param name The name of the effect.
  39540. * @param options The required width/height ratio to downsize to before computing the render pass.
  39541. * @param camera The camera to apply the render pass to.
  39542. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39543. * @param engine The engine which the post process will be applied. (default: current engine)
  39544. * @param reusable If the post process can be reused on the same frame. (default: false)
  39545. * @param textureType The type of texture to be used when performing the post processing.
  39546. * @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)
  39547. */
  39548. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39549. }
  39550. }
  39551. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39552. /** @hidden */
  39553. export var anaglyphPixelShader: {
  39554. name: string;
  39555. shader: string;
  39556. };
  39557. }
  39558. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39559. import { Engine } from "babylonjs/Engines/engine";
  39560. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39561. import { Camera } from "babylonjs/Cameras/camera";
  39562. import "babylonjs/Shaders/anaglyph.fragment";
  39563. /**
  39564. * Postprocess used to generate anaglyphic rendering
  39565. */
  39566. export class AnaglyphPostProcess extends PostProcess {
  39567. private _passedProcess;
  39568. /**
  39569. * Creates a new AnaglyphPostProcess
  39570. * @param name defines postprocess name
  39571. * @param options defines creation options or target ratio scale
  39572. * @param rigCameras defines cameras using this postprocess
  39573. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39574. * @param engine defines hosting engine
  39575. * @param reusable defines if the postprocess will be reused multiple times per frame
  39576. */
  39577. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39578. }
  39579. }
  39580. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39581. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39582. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39583. import { Scene } from "babylonjs/scene";
  39584. import { Vector3 } from "babylonjs/Maths/math";
  39585. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39586. /**
  39587. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39588. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39589. */
  39590. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39591. /**
  39592. * Creates a new AnaglyphArcRotateCamera
  39593. * @param name defines camera name
  39594. * @param alpha defines alpha angle (in radians)
  39595. * @param beta defines beta angle (in radians)
  39596. * @param radius defines radius
  39597. * @param target defines camera target
  39598. * @param interaxialDistance defines distance between each color axis
  39599. * @param scene defines the hosting scene
  39600. */
  39601. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39602. /**
  39603. * Gets camera class name
  39604. * @returns AnaglyphArcRotateCamera
  39605. */
  39606. getClassName(): string;
  39607. }
  39608. }
  39609. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39610. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39611. import { Scene } from "babylonjs/scene";
  39612. import { Vector3 } from "babylonjs/Maths/math";
  39613. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39614. /**
  39615. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39616. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39617. */
  39618. export class AnaglyphFreeCamera extends FreeCamera {
  39619. /**
  39620. * Creates a new AnaglyphFreeCamera
  39621. * @param name defines camera name
  39622. * @param position defines initial position
  39623. * @param interaxialDistance defines distance between each color axis
  39624. * @param scene defines the hosting scene
  39625. */
  39626. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39627. /**
  39628. * Gets camera class name
  39629. * @returns AnaglyphFreeCamera
  39630. */
  39631. getClassName(): string;
  39632. }
  39633. }
  39634. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39635. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39636. import { Scene } from "babylonjs/scene";
  39637. import { Vector3 } from "babylonjs/Maths/math";
  39638. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39639. /**
  39640. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39641. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39642. */
  39643. export class AnaglyphGamepadCamera extends GamepadCamera {
  39644. /**
  39645. * Creates a new AnaglyphGamepadCamera
  39646. * @param name defines camera name
  39647. * @param position defines initial position
  39648. * @param interaxialDistance defines distance between each color axis
  39649. * @param scene defines the hosting scene
  39650. */
  39651. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39652. /**
  39653. * Gets camera class name
  39654. * @returns AnaglyphGamepadCamera
  39655. */
  39656. getClassName(): string;
  39657. }
  39658. }
  39659. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39660. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39661. import { Scene } from "babylonjs/scene";
  39662. import { Vector3 } from "babylonjs/Maths/math";
  39663. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39664. /**
  39665. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39666. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39667. */
  39668. export class AnaglyphUniversalCamera extends UniversalCamera {
  39669. /**
  39670. * Creates a new AnaglyphUniversalCamera
  39671. * @param name defines camera name
  39672. * @param position defines initial position
  39673. * @param interaxialDistance defines distance between each color axis
  39674. * @param scene defines the hosting scene
  39675. */
  39676. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39677. /**
  39678. * Gets camera class name
  39679. * @returns AnaglyphUniversalCamera
  39680. */
  39681. getClassName(): string;
  39682. }
  39683. }
  39684. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39685. /** @hidden */
  39686. export var stereoscopicInterlacePixelShader: {
  39687. name: string;
  39688. shader: string;
  39689. };
  39690. }
  39691. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39692. import { Camera } from "babylonjs/Cameras/camera";
  39693. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39694. import { Engine } from "babylonjs/Engines/engine";
  39695. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39696. /**
  39697. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39698. */
  39699. export class StereoscopicInterlacePostProcess extends PostProcess {
  39700. private _stepSize;
  39701. private _passedProcess;
  39702. /**
  39703. * Initializes a StereoscopicInterlacePostProcess
  39704. * @param name The name of the effect.
  39705. * @param rigCameras The rig cameras to be appled to the post process
  39706. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39708. * @param engine The engine which the post process will be applied. (default: current engine)
  39709. * @param reusable If the post process can be reused on the same frame. (default: false)
  39710. */
  39711. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39712. }
  39713. }
  39714. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39715. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39716. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39717. import { Scene } from "babylonjs/scene";
  39718. import { Vector3 } from "babylonjs/Maths/math";
  39719. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39720. /**
  39721. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39722. * @see http://doc.babylonjs.com/features/cameras
  39723. */
  39724. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39725. /**
  39726. * Creates a new StereoscopicArcRotateCamera
  39727. * @param name defines camera name
  39728. * @param alpha defines alpha angle (in radians)
  39729. * @param beta defines beta angle (in radians)
  39730. * @param radius defines radius
  39731. * @param target defines camera target
  39732. * @param interaxialDistance defines distance between each color axis
  39733. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39734. * @param scene defines the hosting scene
  39735. */
  39736. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39737. /**
  39738. * Gets camera class name
  39739. * @returns StereoscopicArcRotateCamera
  39740. */
  39741. getClassName(): string;
  39742. }
  39743. }
  39744. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39745. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39746. import { Scene } from "babylonjs/scene";
  39747. import { Vector3 } from "babylonjs/Maths/math";
  39748. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39749. /**
  39750. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39751. * @see http://doc.babylonjs.com/features/cameras
  39752. */
  39753. export class StereoscopicFreeCamera extends FreeCamera {
  39754. /**
  39755. * Creates a new StereoscopicFreeCamera
  39756. * @param name defines camera name
  39757. * @param position defines initial position
  39758. * @param interaxialDistance defines distance between each color axis
  39759. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39760. * @param scene defines the hosting scene
  39761. */
  39762. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39763. /**
  39764. * Gets camera class name
  39765. * @returns StereoscopicFreeCamera
  39766. */
  39767. getClassName(): string;
  39768. }
  39769. }
  39770. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39771. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39772. import { Scene } from "babylonjs/scene";
  39773. import { Vector3 } from "babylonjs/Maths/math";
  39774. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39775. /**
  39776. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39777. * @see http://doc.babylonjs.com/features/cameras
  39778. */
  39779. export class StereoscopicGamepadCamera extends GamepadCamera {
  39780. /**
  39781. * Creates a new StereoscopicGamepadCamera
  39782. * @param name defines camera name
  39783. * @param position defines initial position
  39784. * @param interaxialDistance defines distance between each color axis
  39785. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39786. * @param scene defines the hosting scene
  39787. */
  39788. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39789. /**
  39790. * Gets camera class name
  39791. * @returns StereoscopicGamepadCamera
  39792. */
  39793. getClassName(): string;
  39794. }
  39795. }
  39796. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39797. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39798. import { Scene } from "babylonjs/scene";
  39799. import { Vector3 } from "babylonjs/Maths/math";
  39800. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39801. /**
  39802. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39803. * @see http://doc.babylonjs.com/features/cameras
  39804. */
  39805. export class StereoscopicUniversalCamera extends UniversalCamera {
  39806. /**
  39807. * Creates a new StereoscopicUniversalCamera
  39808. * @param name defines camera name
  39809. * @param position defines initial position
  39810. * @param interaxialDistance defines distance between each color axis
  39811. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39812. * @param scene defines the hosting scene
  39813. */
  39814. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39815. /**
  39816. * Gets camera class name
  39817. * @returns StereoscopicUniversalCamera
  39818. */
  39819. getClassName(): string;
  39820. }
  39821. }
  39822. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39823. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39824. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39825. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39826. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39827. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39828. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39829. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39830. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39831. }
  39832. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39833. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39834. import { Scene } from "babylonjs/scene";
  39835. import { Vector3 } from "babylonjs/Maths/math";
  39836. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39837. /**
  39838. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39839. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39840. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39841. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39842. */
  39843. export class VirtualJoysticksCamera extends FreeCamera {
  39844. /**
  39845. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39846. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39847. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39848. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39849. * @param name Define the name of the camera in the scene
  39850. * @param position Define the start position of the camera in the scene
  39851. * @param scene Define the scene the camera belongs to
  39852. */
  39853. constructor(name: string, position: Vector3, scene: Scene);
  39854. /**
  39855. * Gets the current object class name.
  39856. * @return the class name
  39857. */
  39858. getClassName(): string;
  39859. }
  39860. }
  39861. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39862. import { Matrix } from "babylonjs/Maths/math";
  39863. /**
  39864. * This represents all the required metrics to create a VR camera.
  39865. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39866. */
  39867. export class VRCameraMetrics {
  39868. /**
  39869. * Define the horizontal resolution off the screen.
  39870. */
  39871. hResolution: number;
  39872. /**
  39873. * Define the vertical resolution off the screen.
  39874. */
  39875. vResolution: number;
  39876. /**
  39877. * Define the horizontal screen size.
  39878. */
  39879. hScreenSize: number;
  39880. /**
  39881. * Define the vertical screen size.
  39882. */
  39883. vScreenSize: number;
  39884. /**
  39885. * Define the vertical screen center position.
  39886. */
  39887. vScreenCenter: number;
  39888. /**
  39889. * Define the distance of the eyes to the screen.
  39890. */
  39891. eyeToScreenDistance: number;
  39892. /**
  39893. * Define the distance between both lenses
  39894. */
  39895. lensSeparationDistance: number;
  39896. /**
  39897. * Define the distance between both viewer's eyes.
  39898. */
  39899. interpupillaryDistance: number;
  39900. /**
  39901. * Define the distortion factor of the VR postprocess.
  39902. * Please, touch with care.
  39903. */
  39904. distortionK: number[];
  39905. /**
  39906. * Define the chromatic aberration correction factors for the VR post process.
  39907. */
  39908. chromaAbCorrection: number[];
  39909. /**
  39910. * Define the scale factor of the post process.
  39911. * The smaller the better but the slower.
  39912. */
  39913. postProcessScaleFactor: number;
  39914. /**
  39915. * Define an offset for the lens center.
  39916. */
  39917. lensCenterOffset: number;
  39918. /**
  39919. * Define if the current vr camera should compensate the distortion of the lense or not.
  39920. */
  39921. compensateDistortion: boolean;
  39922. /**
  39923. * Defines if multiview should be enabled when rendering (Default: false)
  39924. */
  39925. multiviewEnabled: boolean;
  39926. /**
  39927. * Gets the rendering aspect ratio based on the provided resolutions.
  39928. */
  39929. readonly aspectRatio: number;
  39930. /**
  39931. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39932. */
  39933. readonly aspectRatioFov: number;
  39934. /**
  39935. * @hidden
  39936. */
  39937. readonly leftHMatrix: Matrix;
  39938. /**
  39939. * @hidden
  39940. */
  39941. readonly rightHMatrix: Matrix;
  39942. /**
  39943. * @hidden
  39944. */
  39945. readonly leftPreViewMatrix: Matrix;
  39946. /**
  39947. * @hidden
  39948. */
  39949. readonly rightPreViewMatrix: Matrix;
  39950. /**
  39951. * Get the default VRMetrics based on the most generic setup.
  39952. * @returns the default vr metrics
  39953. */
  39954. static GetDefault(): VRCameraMetrics;
  39955. }
  39956. }
  39957. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39958. /** @hidden */
  39959. export var vrDistortionCorrectionPixelShader: {
  39960. name: string;
  39961. shader: string;
  39962. };
  39963. }
  39964. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39965. import { Camera } from "babylonjs/Cameras/camera";
  39966. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39967. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39968. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39969. /**
  39970. * VRDistortionCorrectionPostProcess used for mobile VR
  39971. */
  39972. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39973. private _isRightEye;
  39974. private _distortionFactors;
  39975. private _postProcessScaleFactor;
  39976. private _lensCenterOffset;
  39977. private _scaleIn;
  39978. private _scaleFactor;
  39979. private _lensCenter;
  39980. /**
  39981. * Initializes the VRDistortionCorrectionPostProcess
  39982. * @param name The name of the effect.
  39983. * @param camera The camera to apply the render pass to.
  39984. * @param isRightEye If this is for the right eye distortion
  39985. * @param vrMetrics All the required metrics for the VR camera
  39986. */
  39987. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39988. }
  39989. }
  39990. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39991. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39992. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39993. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39994. import { Scene } from "babylonjs/scene";
  39995. import { Vector3 } from "babylonjs/Maths/math";
  39996. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39997. import "babylonjs/Cameras/RigModes/vrRigMode";
  39998. /**
  39999. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40000. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40001. */
  40002. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40003. /**
  40004. * Creates a new VRDeviceOrientationArcRotateCamera
  40005. * @param name defines camera name
  40006. * @param alpha defines the camera rotation along the logitudinal axis
  40007. * @param beta defines the camera rotation along the latitudinal axis
  40008. * @param radius defines the camera distance from its target
  40009. * @param target defines the camera target
  40010. * @param scene defines the scene the camera belongs to
  40011. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40012. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40013. */
  40014. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40015. /**
  40016. * Gets camera class name
  40017. * @returns VRDeviceOrientationArcRotateCamera
  40018. */
  40019. getClassName(): string;
  40020. }
  40021. }
  40022. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40023. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40024. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40025. import { Scene } from "babylonjs/scene";
  40026. import { Vector3 } from "babylonjs/Maths/math";
  40027. import "babylonjs/Cameras/RigModes/vrRigMode";
  40028. /**
  40029. * Camera used to simulate VR rendering (based on FreeCamera)
  40030. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40031. */
  40032. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40033. /**
  40034. * Creates a new VRDeviceOrientationFreeCamera
  40035. * @param name defines camera name
  40036. * @param position defines the start position of the camera
  40037. * @param scene defines the scene the camera belongs to
  40038. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40039. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40040. */
  40041. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40042. /**
  40043. * Gets camera class name
  40044. * @returns VRDeviceOrientationFreeCamera
  40045. */
  40046. getClassName(): string;
  40047. }
  40048. }
  40049. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40050. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40051. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40052. import { Scene } from "babylonjs/scene";
  40053. import { Vector3 } from "babylonjs/Maths/math";
  40054. import "babylonjs/Gamepads/gamepadSceneComponent";
  40055. /**
  40056. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40057. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40058. */
  40059. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40060. /**
  40061. * Creates a new VRDeviceOrientationGamepadCamera
  40062. * @param name defines camera name
  40063. * @param position defines the start position of the camera
  40064. * @param scene defines the scene the camera belongs to
  40065. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40066. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40067. */
  40068. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40069. /**
  40070. * Gets camera class name
  40071. * @returns VRDeviceOrientationGamepadCamera
  40072. */
  40073. getClassName(): string;
  40074. }
  40075. }
  40076. declare module "babylonjs/Materials/pushMaterial" {
  40077. import { Nullable } from "babylonjs/types";
  40078. import { Scene } from "babylonjs/scene";
  40079. import { Matrix } from "babylonjs/Maths/math";
  40080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40081. import { Mesh } from "babylonjs/Meshes/mesh";
  40082. import { Material } from "babylonjs/Materials/material";
  40083. import { Effect } from "babylonjs/Materials/effect";
  40084. /**
  40085. * Base class of materials working in push mode in babylon JS
  40086. * @hidden
  40087. */
  40088. export class PushMaterial extends Material {
  40089. protected _activeEffect: Effect;
  40090. protected _normalMatrix: Matrix;
  40091. /**
  40092. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40093. * This means that the material can keep using a previous shader while a new one is being compiled.
  40094. * This is mostly used when shader parallel compilation is supported (true by default)
  40095. */
  40096. allowShaderHotSwapping: boolean;
  40097. constructor(name: string, scene: Scene);
  40098. getEffect(): Effect;
  40099. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40100. /**
  40101. * Binds the given world matrix to the active effect
  40102. *
  40103. * @param world the matrix to bind
  40104. */
  40105. bindOnlyWorldMatrix(world: Matrix): void;
  40106. /**
  40107. * Binds the given normal matrix to the active effect
  40108. *
  40109. * @param normalMatrix the matrix to bind
  40110. */
  40111. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40112. bind(world: Matrix, mesh?: Mesh): void;
  40113. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40114. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40115. }
  40116. }
  40117. declare module "babylonjs/Materials/materialFlags" {
  40118. /**
  40119. * This groups all the flags used to control the materials channel.
  40120. */
  40121. export class MaterialFlags {
  40122. private static _DiffuseTextureEnabled;
  40123. /**
  40124. * Are diffuse textures enabled in the application.
  40125. */
  40126. static DiffuseTextureEnabled: boolean;
  40127. private static _AmbientTextureEnabled;
  40128. /**
  40129. * Are ambient textures enabled in the application.
  40130. */
  40131. static AmbientTextureEnabled: boolean;
  40132. private static _OpacityTextureEnabled;
  40133. /**
  40134. * Are opacity textures enabled in the application.
  40135. */
  40136. static OpacityTextureEnabled: boolean;
  40137. private static _ReflectionTextureEnabled;
  40138. /**
  40139. * Are reflection textures enabled in the application.
  40140. */
  40141. static ReflectionTextureEnabled: boolean;
  40142. private static _EmissiveTextureEnabled;
  40143. /**
  40144. * Are emissive textures enabled in the application.
  40145. */
  40146. static EmissiveTextureEnabled: boolean;
  40147. private static _SpecularTextureEnabled;
  40148. /**
  40149. * Are specular textures enabled in the application.
  40150. */
  40151. static SpecularTextureEnabled: boolean;
  40152. private static _BumpTextureEnabled;
  40153. /**
  40154. * Are bump textures enabled in the application.
  40155. */
  40156. static BumpTextureEnabled: boolean;
  40157. private static _LightmapTextureEnabled;
  40158. /**
  40159. * Are lightmap textures enabled in the application.
  40160. */
  40161. static LightmapTextureEnabled: boolean;
  40162. private static _RefractionTextureEnabled;
  40163. /**
  40164. * Are refraction textures enabled in the application.
  40165. */
  40166. static RefractionTextureEnabled: boolean;
  40167. private static _ColorGradingTextureEnabled;
  40168. /**
  40169. * Are color grading textures enabled in the application.
  40170. */
  40171. static ColorGradingTextureEnabled: boolean;
  40172. private static _FresnelEnabled;
  40173. /**
  40174. * Are fresnels enabled in the application.
  40175. */
  40176. static FresnelEnabled: boolean;
  40177. private static _ClearCoatTextureEnabled;
  40178. /**
  40179. * Are clear coat textures enabled in the application.
  40180. */
  40181. static ClearCoatTextureEnabled: boolean;
  40182. private static _ClearCoatBumpTextureEnabled;
  40183. /**
  40184. * Are clear coat bump textures enabled in the application.
  40185. */
  40186. static ClearCoatBumpTextureEnabled: boolean;
  40187. private static _ClearCoatTintTextureEnabled;
  40188. /**
  40189. * Are clear coat tint textures enabled in the application.
  40190. */
  40191. static ClearCoatTintTextureEnabled: boolean;
  40192. private static _SheenTextureEnabled;
  40193. /**
  40194. * Are sheen textures enabled in the application.
  40195. */
  40196. static SheenTextureEnabled: boolean;
  40197. private static _AnisotropicTextureEnabled;
  40198. /**
  40199. * Are anisotropic textures enabled in the application.
  40200. */
  40201. static AnisotropicTextureEnabled: boolean;
  40202. private static _ThicknessTextureEnabled;
  40203. /**
  40204. * Are thickness textures enabled in the application.
  40205. */
  40206. static ThicknessTextureEnabled: boolean;
  40207. }
  40208. }
  40209. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40210. /** @hidden */
  40211. export var defaultFragmentDeclaration: {
  40212. name: string;
  40213. shader: string;
  40214. };
  40215. }
  40216. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40217. /** @hidden */
  40218. export var defaultUboDeclaration: {
  40219. name: string;
  40220. shader: string;
  40221. };
  40222. }
  40223. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40224. /** @hidden */
  40225. export var lightFragmentDeclaration: {
  40226. name: string;
  40227. shader: string;
  40228. };
  40229. }
  40230. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40231. /** @hidden */
  40232. export var lightUboDeclaration: {
  40233. name: string;
  40234. shader: string;
  40235. };
  40236. }
  40237. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40238. /** @hidden */
  40239. export var lightsFragmentFunctions: {
  40240. name: string;
  40241. shader: string;
  40242. };
  40243. }
  40244. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40245. /** @hidden */
  40246. export var shadowsFragmentFunctions: {
  40247. name: string;
  40248. shader: string;
  40249. };
  40250. }
  40251. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40252. /** @hidden */
  40253. export var fresnelFunction: {
  40254. name: string;
  40255. shader: string;
  40256. };
  40257. }
  40258. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40259. /** @hidden */
  40260. export var reflectionFunction: {
  40261. name: string;
  40262. shader: string;
  40263. };
  40264. }
  40265. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40266. /** @hidden */
  40267. export var bumpFragmentFunctions: {
  40268. name: string;
  40269. shader: string;
  40270. };
  40271. }
  40272. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40273. /** @hidden */
  40274. export var logDepthDeclaration: {
  40275. name: string;
  40276. shader: string;
  40277. };
  40278. }
  40279. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40280. /** @hidden */
  40281. export var bumpFragment: {
  40282. name: string;
  40283. shader: string;
  40284. };
  40285. }
  40286. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40287. /** @hidden */
  40288. export var depthPrePass: {
  40289. name: string;
  40290. shader: string;
  40291. };
  40292. }
  40293. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40294. /** @hidden */
  40295. export var lightFragment: {
  40296. name: string;
  40297. shader: string;
  40298. };
  40299. }
  40300. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40301. /** @hidden */
  40302. export var logDepthFragment: {
  40303. name: string;
  40304. shader: string;
  40305. };
  40306. }
  40307. declare module "babylonjs/Shaders/default.fragment" {
  40308. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40309. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40310. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40311. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40312. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40313. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40314. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40315. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40316. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40317. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40318. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40319. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40320. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40321. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40322. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40323. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40324. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40325. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40326. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40327. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40328. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40329. /** @hidden */
  40330. export var defaultPixelShader: {
  40331. name: string;
  40332. shader: string;
  40333. };
  40334. }
  40335. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40336. /** @hidden */
  40337. export var defaultVertexDeclaration: {
  40338. name: string;
  40339. shader: string;
  40340. };
  40341. }
  40342. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40343. /** @hidden */
  40344. export var bumpVertexDeclaration: {
  40345. name: string;
  40346. shader: string;
  40347. };
  40348. }
  40349. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40350. /** @hidden */
  40351. export var bumpVertex: {
  40352. name: string;
  40353. shader: string;
  40354. };
  40355. }
  40356. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40357. /** @hidden */
  40358. export var fogVertex: {
  40359. name: string;
  40360. shader: string;
  40361. };
  40362. }
  40363. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40364. /** @hidden */
  40365. export var shadowsVertex: {
  40366. name: string;
  40367. shader: string;
  40368. };
  40369. }
  40370. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40371. /** @hidden */
  40372. export var pointCloudVertex: {
  40373. name: string;
  40374. shader: string;
  40375. };
  40376. }
  40377. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40378. /** @hidden */
  40379. export var logDepthVertex: {
  40380. name: string;
  40381. shader: string;
  40382. };
  40383. }
  40384. declare module "babylonjs/Shaders/default.vertex" {
  40385. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40386. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40387. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40388. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40389. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40390. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40391. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40392. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40393. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40394. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40395. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40396. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40397. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40398. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40399. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40400. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40401. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40402. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40403. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40404. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40405. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40406. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40407. /** @hidden */
  40408. export var defaultVertexShader: {
  40409. name: string;
  40410. shader: string;
  40411. };
  40412. }
  40413. declare module "babylonjs/Materials/standardMaterial" {
  40414. import { SmartArray } from "babylonjs/Misc/smartArray";
  40415. import { IAnimatable } from "babylonjs/Misc/tools";
  40416. import { Nullable } from "babylonjs/types";
  40417. import { Scene } from "babylonjs/scene";
  40418. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40421. import { Mesh } from "babylonjs/Meshes/mesh";
  40422. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40423. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40424. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40425. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40426. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40428. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40429. import "babylonjs/Shaders/default.fragment";
  40430. import "babylonjs/Shaders/default.vertex";
  40431. /** @hidden */
  40432. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40433. MAINUV1: boolean;
  40434. MAINUV2: boolean;
  40435. DIFFUSE: boolean;
  40436. DIFFUSEDIRECTUV: number;
  40437. AMBIENT: boolean;
  40438. AMBIENTDIRECTUV: number;
  40439. OPACITY: boolean;
  40440. OPACITYDIRECTUV: number;
  40441. OPACITYRGB: boolean;
  40442. REFLECTION: boolean;
  40443. EMISSIVE: boolean;
  40444. EMISSIVEDIRECTUV: number;
  40445. SPECULAR: boolean;
  40446. SPECULARDIRECTUV: number;
  40447. BUMP: boolean;
  40448. BUMPDIRECTUV: number;
  40449. PARALLAX: boolean;
  40450. PARALLAXOCCLUSION: boolean;
  40451. SPECULAROVERALPHA: boolean;
  40452. CLIPPLANE: boolean;
  40453. CLIPPLANE2: boolean;
  40454. CLIPPLANE3: boolean;
  40455. CLIPPLANE4: boolean;
  40456. ALPHATEST: boolean;
  40457. DEPTHPREPASS: boolean;
  40458. ALPHAFROMDIFFUSE: boolean;
  40459. POINTSIZE: boolean;
  40460. FOG: boolean;
  40461. SPECULARTERM: boolean;
  40462. DIFFUSEFRESNEL: boolean;
  40463. OPACITYFRESNEL: boolean;
  40464. REFLECTIONFRESNEL: boolean;
  40465. REFRACTIONFRESNEL: boolean;
  40466. EMISSIVEFRESNEL: boolean;
  40467. FRESNEL: boolean;
  40468. NORMAL: boolean;
  40469. UV1: boolean;
  40470. UV2: boolean;
  40471. VERTEXCOLOR: boolean;
  40472. VERTEXALPHA: boolean;
  40473. NUM_BONE_INFLUENCERS: number;
  40474. BonesPerMesh: number;
  40475. BONETEXTURE: boolean;
  40476. INSTANCES: boolean;
  40477. GLOSSINESS: boolean;
  40478. ROUGHNESS: boolean;
  40479. EMISSIVEASILLUMINATION: boolean;
  40480. LINKEMISSIVEWITHDIFFUSE: boolean;
  40481. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40482. LIGHTMAP: boolean;
  40483. LIGHTMAPDIRECTUV: number;
  40484. OBJECTSPACE_NORMALMAP: boolean;
  40485. USELIGHTMAPASSHADOWMAP: boolean;
  40486. REFLECTIONMAP_3D: boolean;
  40487. REFLECTIONMAP_SPHERICAL: boolean;
  40488. REFLECTIONMAP_PLANAR: boolean;
  40489. REFLECTIONMAP_CUBIC: boolean;
  40490. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40491. REFLECTIONMAP_PROJECTION: boolean;
  40492. REFLECTIONMAP_SKYBOX: boolean;
  40493. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40494. REFLECTIONMAP_EXPLICIT: boolean;
  40495. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40496. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40497. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40498. INVERTCUBICMAP: boolean;
  40499. LOGARITHMICDEPTH: boolean;
  40500. REFRACTION: boolean;
  40501. REFRACTIONMAP_3D: boolean;
  40502. REFLECTIONOVERALPHA: boolean;
  40503. TWOSIDEDLIGHTING: boolean;
  40504. SHADOWFLOAT: boolean;
  40505. MORPHTARGETS: boolean;
  40506. MORPHTARGETS_NORMAL: boolean;
  40507. MORPHTARGETS_TANGENT: boolean;
  40508. MORPHTARGETS_UV: boolean;
  40509. NUM_MORPH_INFLUENCERS: number;
  40510. NONUNIFORMSCALING: boolean;
  40511. PREMULTIPLYALPHA: boolean;
  40512. IMAGEPROCESSING: boolean;
  40513. VIGNETTE: boolean;
  40514. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40515. VIGNETTEBLENDMODEOPAQUE: boolean;
  40516. TONEMAPPING: boolean;
  40517. TONEMAPPING_ACES: boolean;
  40518. CONTRAST: boolean;
  40519. COLORCURVES: boolean;
  40520. COLORGRADING: boolean;
  40521. COLORGRADING3D: boolean;
  40522. SAMPLER3DGREENDEPTH: boolean;
  40523. SAMPLER3DBGRMAP: boolean;
  40524. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40525. MULTIVIEW: boolean;
  40526. /**
  40527. * If the reflection texture on this material is in linear color space
  40528. * @hidden
  40529. */
  40530. IS_REFLECTION_LINEAR: boolean;
  40531. /**
  40532. * If the refraction texture on this material is in linear color space
  40533. * @hidden
  40534. */
  40535. IS_REFRACTION_LINEAR: boolean;
  40536. EXPOSURE: boolean;
  40537. constructor();
  40538. setReflectionMode(modeToEnable: string): void;
  40539. }
  40540. /**
  40541. * This is the default material used in Babylon. It is the best trade off between quality
  40542. * and performances.
  40543. * @see http://doc.babylonjs.com/babylon101/materials
  40544. */
  40545. export class StandardMaterial extends PushMaterial {
  40546. private _diffuseTexture;
  40547. /**
  40548. * The basic texture of the material as viewed under a light.
  40549. */
  40550. diffuseTexture: Nullable<BaseTexture>;
  40551. private _ambientTexture;
  40552. /**
  40553. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40554. */
  40555. ambientTexture: Nullable<BaseTexture>;
  40556. private _opacityTexture;
  40557. /**
  40558. * Define the transparency of the material from a texture.
  40559. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40560. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40561. */
  40562. opacityTexture: Nullable<BaseTexture>;
  40563. private _reflectionTexture;
  40564. /**
  40565. * Define the texture used to display the reflection.
  40566. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40567. */
  40568. reflectionTexture: Nullable<BaseTexture>;
  40569. private _emissiveTexture;
  40570. /**
  40571. * Define texture of the material as if self lit.
  40572. * This will be mixed in the final result even in the absence of light.
  40573. */
  40574. emissiveTexture: Nullable<BaseTexture>;
  40575. private _specularTexture;
  40576. /**
  40577. * Define how the color and intensity of the highlight given by the light in the material.
  40578. */
  40579. specularTexture: Nullable<BaseTexture>;
  40580. private _bumpTexture;
  40581. /**
  40582. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40583. * 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.
  40584. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40585. */
  40586. bumpTexture: Nullable<BaseTexture>;
  40587. private _lightmapTexture;
  40588. /**
  40589. * Complex lighting can be computationally expensive to compute at runtime.
  40590. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40591. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40592. */
  40593. lightmapTexture: Nullable<BaseTexture>;
  40594. private _refractionTexture;
  40595. /**
  40596. * Define the texture used to display the refraction.
  40597. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40598. */
  40599. refractionTexture: Nullable<BaseTexture>;
  40600. /**
  40601. * The color of the material lit by the environmental background lighting.
  40602. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40603. */
  40604. ambientColor: Color3;
  40605. /**
  40606. * The basic color of the material as viewed under a light.
  40607. */
  40608. diffuseColor: Color3;
  40609. /**
  40610. * Define how the color and intensity of the highlight given by the light in the material.
  40611. */
  40612. specularColor: Color3;
  40613. /**
  40614. * Define the color of the material as if self lit.
  40615. * This will be mixed in the final result even in the absence of light.
  40616. */
  40617. emissiveColor: Color3;
  40618. /**
  40619. * Defines how sharp are the highlights in the material.
  40620. * The bigger the value the sharper giving a more glossy feeling to the result.
  40621. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40622. */
  40623. specularPower: number;
  40624. private _useAlphaFromDiffuseTexture;
  40625. /**
  40626. * Does the transparency come from the diffuse texture alpha channel.
  40627. */
  40628. useAlphaFromDiffuseTexture: boolean;
  40629. private _useEmissiveAsIllumination;
  40630. /**
  40631. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40632. */
  40633. useEmissiveAsIllumination: boolean;
  40634. private _linkEmissiveWithDiffuse;
  40635. /**
  40636. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40637. * the emissive level when the final color is close to one.
  40638. */
  40639. linkEmissiveWithDiffuse: boolean;
  40640. private _useSpecularOverAlpha;
  40641. /**
  40642. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40643. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40644. */
  40645. useSpecularOverAlpha: boolean;
  40646. private _useReflectionOverAlpha;
  40647. /**
  40648. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40649. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40650. */
  40651. useReflectionOverAlpha: boolean;
  40652. private _disableLighting;
  40653. /**
  40654. * Does lights from the scene impacts this material.
  40655. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40656. */
  40657. disableLighting: boolean;
  40658. private _useObjectSpaceNormalMap;
  40659. /**
  40660. * Allows using an object space normal map (instead of tangent space).
  40661. */
  40662. useObjectSpaceNormalMap: boolean;
  40663. private _useParallax;
  40664. /**
  40665. * Is parallax enabled or not.
  40666. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40667. */
  40668. useParallax: boolean;
  40669. private _useParallaxOcclusion;
  40670. /**
  40671. * Is parallax occlusion enabled or not.
  40672. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40673. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40674. */
  40675. useParallaxOcclusion: boolean;
  40676. /**
  40677. * 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.
  40678. */
  40679. parallaxScaleBias: number;
  40680. private _roughness;
  40681. /**
  40682. * Helps to define how blurry the reflections should appears in the material.
  40683. */
  40684. roughness: number;
  40685. /**
  40686. * In case of refraction, define the value of the index of refraction.
  40687. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40688. */
  40689. indexOfRefraction: number;
  40690. /**
  40691. * Invert the refraction texture alongside the y axis.
  40692. * It can be useful with procedural textures or probe for instance.
  40693. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40694. */
  40695. invertRefractionY: boolean;
  40696. /**
  40697. * Defines the alpha limits in alpha test mode.
  40698. */
  40699. alphaCutOff: number;
  40700. private _useLightmapAsShadowmap;
  40701. /**
  40702. * In case of light mapping, define whether the map contains light or shadow informations.
  40703. */
  40704. useLightmapAsShadowmap: boolean;
  40705. private _diffuseFresnelParameters;
  40706. /**
  40707. * Define the diffuse fresnel parameters of the material.
  40708. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40709. */
  40710. diffuseFresnelParameters: FresnelParameters;
  40711. private _opacityFresnelParameters;
  40712. /**
  40713. * Define the opacity fresnel parameters of the material.
  40714. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40715. */
  40716. opacityFresnelParameters: FresnelParameters;
  40717. private _reflectionFresnelParameters;
  40718. /**
  40719. * Define the reflection fresnel parameters of the material.
  40720. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40721. */
  40722. reflectionFresnelParameters: FresnelParameters;
  40723. private _refractionFresnelParameters;
  40724. /**
  40725. * Define the refraction fresnel parameters of the material.
  40726. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40727. */
  40728. refractionFresnelParameters: FresnelParameters;
  40729. private _emissiveFresnelParameters;
  40730. /**
  40731. * Define the emissive fresnel parameters of the material.
  40732. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40733. */
  40734. emissiveFresnelParameters: FresnelParameters;
  40735. private _useReflectionFresnelFromSpecular;
  40736. /**
  40737. * If true automatically deducts the fresnels values from the material specularity.
  40738. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40739. */
  40740. useReflectionFresnelFromSpecular: boolean;
  40741. private _useGlossinessFromSpecularMapAlpha;
  40742. /**
  40743. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40744. */
  40745. useGlossinessFromSpecularMapAlpha: boolean;
  40746. private _maxSimultaneousLights;
  40747. /**
  40748. * Defines the maximum number of lights that can be used in the material
  40749. */
  40750. maxSimultaneousLights: number;
  40751. private _invertNormalMapX;
  40752. /**
  40753. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40754. */
  40755. invertNormalMapX: boolean;
  40756. private _invertNormalMapY;
  40757. /**
  40758. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40759. */
  40760. invertNormalMapY: boolean;
  40761. private _twoSidedLighting;
  40762. /**
  40763. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40764. */
  40765. twoSidedLighting: boolean;
  40766. /**
  40767. * Default configuration related to image processing available in the standard Material.
  40768. */
  40769. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40770. /**
  40771. * Gets the image processing configuration used either in this material.
  40772. */
  40773. /**
  40774. * Sets the Default image processing configuration used either in the this material.
  40775. *
  40776. * If sets to null, the scene one is in use.
  40777. */
  40778. imageProcessingConfiguration: ImageProcessingConfiguration;
  40779. /**
  40780. * Keep track of the image processing observer to allow dispose and replace.
  40781. */
  40782. private _imageProcessingObserver;
  40783. /**
  40784. * Attaches a new image processing configuration to the Standard Material.
  40785. * @param configuration
  40786. */
  40787. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40788. /**
  40789. * Gets wether the color curves effect is enabled.
  40790. */
  40791. /**
  40792. * Sets wether the color curves effect is enabled.
  40793. */
  40794. cameraColorCurvesEnabled: boolean;
  40795. /**
  40796. * Gets wether the color grading effect is enabled.
  40797. */
  40798. /**
  40799. * Gets wether the color grading effect is enabled.
  40800. */
  40801. cameraColorGradingEnabled: boolean;
  40802. /**
  40803. * Gets wether tonemapping is enabled or not.
  40804. */
  40805. /**
  40806. * Sets wether tonemapping is enabled or not
  40807. */
  40808. cameraToneMappingEnabled: boolean;
  40809. /**
  40810. * The camera exposure used on this material.
  40811. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40812. * This corresponds to a photographic exposure.
  40813. */
  40814. /**
  40815. * The camera exposure used on this material.
  40816. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40817. * This corresponds to a photographic exposure.
  40818. */
  40819. cameraExposure: number;
  40820. /**
  40821. * Gets The camera contrast used on this material.
  40822. */
  40823. /**
  40824. * Sets The camera contrast used on this material.
  40825. */
  40826. cameraContrast: number;
  40827. /**
  40828. * Gets the Color Grading 2D Lookup Texture.
  40829. */
  40830. /**
  40831. * Sets the Color Grading 2D Lookup Texture.
  40832. */
  40833. cameraColorGradingTexture: Nullable<BaseTexture>;
  40834. /**
  40835. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40836. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40837. * 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;
  40838. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40839. */
  40840. /**
  40841. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40842. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40843. * 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;
  40844. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40845. */
  40846. cameraColorCurves: Nullable<ColorCurves>;
  40847. /**
  40848. * Custom callback helping to override the default shader used in the material.
  40849. */
  40850. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40851. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40852. protected _worldViewProjectionMatrix: Matrix;
  40853. protected _globalAmbientColor: Color3;
  40854. protected _useLogarithmicDepth: boolean;
  40855. /**
  40856. * Instantiates a new standard material.
  40857. * This is the default material used in Babylon. It is the best trade off between quality
  40858. * and performances.
  40859. * @see http://doc.babylonjs.com/babylon101/materials
  40860. * @param name Define the name of the material in the scene
  40861. * @param scene Define the scene the material belong to
  40862. */
  40863. constructor(name: string, scene: Scene);
  40864. /**
  40865. * Gets a boolean indicating that current material needs to register RTT
  40866. */
  40867. readonly hasRenderTargetTextures: boolean;
  40868. /**
  40869. * Gets the current class name of the material e.g. "StandardMaterial"
  40870. * Mainly use in serialization.
  40871. * @returns the class name
  40872. */
  40873. getClassName(): string;
  40874. /**
  40875. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40876. * You can try switching to logarithmic depth.
  40877. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40878. */
  40879. useLogarithmicDepth: boolean;
  40880. /**
  40881. * Specifies if the material will require alpha blending
  40882. * @returns a boolean specifying if alpha blending is needed
  40883. */
  40884. needAlphaBlending(): boolean;
  40885. /**
  40886. * Specifies if this material should be rendered in alpha test mode
  40887. * @returns a boolean specifying if an alpha test is needed.
  40888. */
  40889. needAlphaTesting(): boolean;
  40890. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40891. /**
  40892. * Get the texture used for alpha test purpose.
  40893. * @returns the diffuse texture in case of the standard material.
  40894. */
  40895. getAlphaTestTexture(): Nullable<BaseTexture>;
  40896. /**
  40897. * Get if the submesh is ready to be used and all its information available.
  40898. * Child classes can use it to update shaders
  40899. * @param mesh defines the mesh to check
  40900. * @param subMesh defines which submesh to check
  40901. * @param useInstances specifies that instances should be used
  40902. * @returns a boolean indicating that the submesh is ready or not
  40903. */
  40904. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40905. /**
  40906. * Builds the material UBO layouts.
  40907. * Used internally during the effect preparation.
  40908. */
  40909. buildUniformLayout(): void;
  40910. /**
  40911. * Unbinds the material from the mesh
  40912. */
  40913. unbind(): void;
  40914. /**
  40915. * Binds the submesh to this material by preparing the effect and shader to draw
  40916. * @param world defines the world transformation matrix
  40917. * @param mesh defines the mesh containing the submesh
  40918. * @param subMesh defines the submesh to bind the material to
  40919. */
  40920. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40921. /**
  40922. * Get the list of animatables in the material.
  40923. * @returns the list of animatables object used in the material
  40924. */
  40925. getAnimatables(): IAnimatable[];
  40926. /**
  40927. * Gets the active textures from the material
  40928. * @returns an array of textures
  40929. */
  40930. getActiveTextures(): BaseTexture[];
  40931. /**
  40932. * Specifies if the material uses a texture
  40933. * @param texture defines the texture to check against the material
  40934. * @returns a boolean specifying if the material uses the texture
  40935. */
  40936. hasTexture(texture: BaseTexture): boolean;
  40937. /**
  40938. * Disposes the material
  40939. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40940. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40941. */
  40942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40943. /**
  40944. * Makes a duplicate of the material, and gives it a new name
  40945. * @param name defines the new name for the duplicated material
  40946. * @returns the cloned material
  40947. */
  40948. clone(name: string): StandardMaterial;
  40949. /**
  40950. * Serializes this material in a JSON representation
  40951. * @returns the serialized material object
  40952. */
  40953. serialize(): any;
  40954. /**
  40955. * Creates a standard material from parsed material data
  40956. * @param source defines the JSON representation of the material
  40957. * @param scene defines the hosting scene
  40958. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40959. * @returns a new standard material
  40960. */
  40961. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40962. /**
  40963. * Are diffuse textures enabled in the application.
  40964. */
  40965. static DiffuseTextureEnabled: boolean;
  40966. /**
  40967. * Are ambient textures enabled in the application.
  40968. */
  40969. static AmbientTextureEnabled: boolean;
  40970. /**
  40971. * Are opacity textures enabled in the application.
  40972. */
  40973. static OpacityTextureEnabled: boolean;
  40974. /**
  40975. * Are reflection textures enabled in the application.
  40976. */
  40977. static ReflectionTextureEnabled: boolean;
  40978. /**
  40979. * Are emissive textures enabled in the application.
  40980. */
  40981. static EmissiveTextureEnabled: boolean;
  40982. /**
  40983. * Are specular textures enabled in the application.
  40984. */
  40985. static SpecularTextureEnabled: boolean;
  40986. /**
  40987. * Are bump textures enabled in the application.
  40988. */
  40989. static BumpTextureEnabled: boolean;
  40990. /**
  40991. * Are lightmap textures enabled in the application.
  40992. */
  40993. static LightmapTextureEnabled: boolean;
  40994. /**
  40995. * Are refraction textures enabled in the application.
  40996. */
  40997. static RefractionTextureEnabled: boolean;
  40998. /**
  40999. * Are color grading textures enabled in the application.
  41000. */
  41001. static ColorGradingTextureEnabled: boolean;
  41002. /**
  41003. * Are fresnels enabled in the application.
  41004. */
  41005. static FresnelEnabled: boolean;
  41006. }
  41007. }
  41008. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41009. import { Scene } from "babylonjs/scene";
  41010. import { Texture } from "babylonjs/Materials/Textures/texture";
  41011. /**
  41012. * A class extending Texture allowing drawing on a texture
  41013. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41014. */
  41015. export class DynamicTexture extends Texture {
  41016. private _generateMipMaps;
  41017. private _canvas;
  41018. private _context;
  41019. private _engine;
  41020. /**
  41021. * Creates a DynamicTexture
  41022. * @param name defines the name of the texture
  41023. * @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
  41024. * @param scene defines the scene where you want the texture
  41025. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41026. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41027. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41028. */
  41029. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41030. /**
  41031. * Get the current class name of the texture useful for serialization or dynamic coding.
  41032. * @returns "DynamicTexture"
  41033. */
  41034. getClassName(): string;
  41035. /**
  41036. * Gets the current state of canRescale
  41037. */
  41038. readonly canRescale: boolean;
  41039. private _recreate;
  41040. /**
  41041. * Scales the texture
  41042. * @param ratio the scale factor to apply to both width and height
  41043. */
  41044. scale(ratio: number): void;
  41045. /**
  41046. * Resizes the texture
  41047. * @param width the new width
  41048. * @param height the new height
  41049. */
  41050. scaleTo(width: number, height: number): void;
  41051. /**
  41052. * Gets the context of the canvas used by the texture
  41053. * @returns the canvas context of the dynamic texture
  41054. */
  41055. getContext(): CanvasRenderingContext2D;
  41056. /**
  41057. * Clears the texture
  41058. */
  41059. clear(): void;
  41060. /**
  41061. * Updates the texture
  41062. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41063. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41064. */
  41065. update(invertY?: boolean, premulAlpha?: boolean): void;
  41066. /**
  41067. * Draws text onto the texture
  41068. * @param text defines the text to be drawn
  41069. * @param x defines the placement of the text from the left
  41070. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41071. * @param font defines the font to be used with font-style, font-size, font-name
  41072. * @param color defines the color used for the text
  41073. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41074. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41075. * @param update defines whether texture is immediately update (default is true)
  41076. */
  41077. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41078. /**
  41079. * Clones the texture
  41080. * @returns the clone of the texture.
  41081. */
  41082. clone(): DynamicTexture;
  41083. /**
  41084. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41085. * @returns a serialized dynamic texture object
  41086. */
  41087. serialize(): any;
  41088. /** @hidden */
  41089. _rebuild(): void;
  41090. }
  41091. }
  41092. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41093. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41094. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41095. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41096. /** @hidden */
  41097. export var imageProcessingPixelShader: {
  41098. name: string;
  41099. shader: string;
  41100. };
  41101. }
  41102. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41103. import { Nullable } from "babylonjs/types";
  41104. import { Color4 } from "babylonjs/Maths/math";
  41105. import { Camera } from "babylonjs/Cameras/camera";
  41106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41107. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41108. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41109. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41110. import { Engine } from "babylonjs/Engines/engine";
  41111. import "babylonjs/Shaders/imageProcessing.fragment";
  41112. import "babylonjs/Shaders/postprocess.vertex";
  41113. /**
  41114. * ImageProcessingPostProcess
  41115. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41116. */
  41117. export class ImageProcessingPostProcess extends PostProcess {
  41118. /**
  41119. * Default configuration related to image processing available in the PBR Material.
  41120. */
  41121. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41122. /**
  41123. * Gets the image processing configuration used either in this material.
  41124. */
  41125. /**
  41126. * Sets the Default image processing configuration used either in the this material.
  41127. *
  41128. * If sets to null, the scene one is in use.
  41129. */
  41130. imageProcessingConfiguration: ImageProcessingConfiguration;
  41131. /**
  41132. * Keep track of the image processing observer to allow dispose and replace.
  41133. */
  41134. private _imageProcessingObserver;
  41135. /**
  41136. * Attaches a new image processing configuration to the PBR Material.
  41137. * @param configuration
  41138. */
  41139. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41140. /**
  41141. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41142. */
  41143. /**
  41144. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41145. */
  41146. colorCurves: Nullable<ColorCurves>;
  41147. /**
  41148. * Gets wether the color curves effect is enabled.
  41149. */
  41150. /**
  41151. * Sets wether the color curves effect is enabled.
  41152. */
  41153. colorCurvesEnabled: boolean;
  41154. /**
  41155. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41156. */
  41157. /**
  41158. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41159. */
  41160. colorGradingTexture: Nullable<BaseTexture>;
  41161. /**
  41162. * Gets wether the color grading effect is enabled.
  41163. */
  41164. /**
  41165. * Gets wether the color grading effect is enabled.
  41166. */
  41167. colorGradingEnabled: boolean;
  41168. /**
  41169. * Gets exposure used in the effect.
  41170. */
  41171. /**
  41172. * Sets exposure used in the effect.
  41173. */
  41174. exposure: number;
  41175. /**
  41176. * Gets wether tonemapping is enabled or not.
  41177. */
  41178. /**
  41179. * Sets wether tonemapping is enabled or not
  41180. */
  41181. toneMappingEnabled: boolean;
  41182. /**
  41183. * Gets the type of tone mapping effect.
  41184. */
  41185. /**
  41186. * Sets the type of tone mapping effect.
  41187. */
  41188. toneMappingType: number;
  41189. /**
  41190. * Gets contrast used in the effect.
  41191. */
  41192. /**
  41193. * Sets contrast used in the effect.
  41194. */
  41195. contrast: number;
  41196. /**
  41197. * Gets Vignette stretch size.
  41198. */
  41199. /**
  41200. * Sets Vignette stretch size.
  41201. */
  41202. vignetteStretch: number;
  41203. /**
  41204. * Gets Vignette centre X Offset.
  41205. */
  41206. /**
  41207. * Sets Vignette centre X Offset.
  41208. */
  41209. vignetteCentreX: number;
  41210. /**
  41211. * Gets Vignette centre Y Offset.
  41212. */
  41213. /**
  41214. * Sets Vignette centre Y Offset.
  41215. */
  41216. vignetteCentreY: number;
  41217. /**
  41218. * Gets Vignette weight or intensity of the vignette effect.
  41219. */
  41220. /**
  41221. * Sets Vignette weight or intensity of the vignette effect.
  41222. */
  41223. vignetteWeight: number;
  41224. /**
  41225. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41226. * if vignetteEnabled is set to true.
  41227. */
  41228. /**
  41229. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41230. * if vignetteEnabled is set to true.
  41231. */
  41232. vignetteColor: Color4;
  41233. /**
  41234. * Gets Camera field of view used by the Vignette effect.
  41235. */
  41236. /**
  41237. * Sets Camera field of view used by the Vignette effect.
  41238. */
  41239. vignetteCameraFov: number;
  41240. /**
  41241. * Gets the vignette blend mode allowing different kind of effect.
  41242. */
  41243. /**
  41244. * Sets the vignette blend mode allowing different kind of effect.
  41245. */
  41246. vignetteBlendMode: number;
  41247. /**
  41248. * Gets wether the vignette effect is enabled.
  41249. */
  41250. /**
  41251. * Sets wether the vignette effect is enabled.
  41252. */
  41253. vignetteEnabled: boolean;
  41254. private _fromLinearSpace;
  41255. /**
  41256. * Gets wether the input of the processing is in Gamma or Linear Space.
  41257. */
  41258. /**
  41259. * Sets wether the input of the processing is in Gamma or Linear Space.
  41260. */
  41261. fromLinearSpace: boolean;
  41262. /**
  41263. * Defines cache preventing GC.
  41264. */
  41265. private _defines;
  41266. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41267. /**
  41268. * "ImageProcessingPostProcess"
  41269. * @returns "ImageProcessingPostProcess"
  41270. */
  41271. getClassName(): string;
  41272. protected _updateParameters(): void;
  41273. dispose(camera?: Camera): void;
  41274. }
  41275. }
  41276. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41277. import { Scene } from "babylonjs/scene";
  41278. import { Color3 } from "babylonjs/Maths/math";
  41279. import { Mesh } from "babylonjs/Meshes/mesh";
  41280. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41281. import { Nullable } from "babylonjs/types";
  41282. /**
  41283. * Class containing static functions to help procedurally build meshes
  41284. */
  41285. export class GroundBuilder {
  41286. /**
  41287. * Creates a ground mesh
  41288. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41289. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41291. * @param name defines the name of the mesh
  41292. * @param options defines the options used to create the mesh
  41293. * @param scene defines the hosting scene
  41294. * @returns the ground mesh
  41295. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41296. */
  41297. static CreateGround(name: string, options: {
  41298. width?: number;
  41299. height?: number;
  41300. subdivisions?: number;
  41301. subdivisionsX?: number;
  41302. subdivisionsY?: number;
  41303. updatable?: boolean;
  41304. }, scene: any): Mesh;
  41305. /**
  41306. * Creates a tiled ground mesh
  41307. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41308. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41309. * * 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
  41310. * * 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
  41311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41312. * @param name defines the name of the mesh
  41313. * @param options defines the options used to create the mesh
  41314. * @param scene defines the hosting scene
  41315. * @returns the tiled ground mesh
  41316. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41317. */
  41318. static CreateTiledGround(name: string, options: {
  41319. xmin: number;
  41320. zmin: number;
  41321. xmax: number;
  41322. zmax: number;
  41323. subdivisions?: {
  41324. w: number;
  41325. h: number;
  41326. };
  41327. precision?: {
  41328. w: number;
  41329. h: number;
  41330. };
  41331. updatable?: boolean;
  41332. }, scene?: Nullable<Scene>): Mesh;
  41333. /**
  41334. * Creates a ground mesh from a height map
  41335. * * The parameter `url` sets the URL of the height map image resource.
  41336. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41337. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41338. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41339. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41340. * * 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.
  41341. * * 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).
  41342. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41344. * @param name defines the name of the mesh
  41345. * @param url defines the url to the height map
  41346. * @param options defines the options used to create the mesh
  41347. * @param scene defines the hosting scene
  41348. * @returns the ground mesh
  41349. * @see https://doc.babylonjs.com/babylon101/height_map
  41350. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41351. */
  41352. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41353. width?: number;
  41354. height?: number;
  41355. subdivisions?: number;
  41356. minHeight?: number;
  41357. maxHeight?: number;
  41358. colorFilter?: Color3;
  41359. alphaFilter?: number;
  41360. updatable?: boolean;
  41361. onReady?: (mesh: GroundMesh) => void;
  41362. }, scene?: Nullable<Scene>): GroundMesh;
  41363. }
  41364. }
  41365. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41366. import { Vector4 } from "babylonjs/Maths/math";
  41367. import { Mesh } from "babylonjs/Meshes/mesh";
  41368. /**
  41369. * Class containing static functions to help procedurally build meshes
  41370. */
  41371. export class TorusBuilder {
  41372. /**
  41373. * Creates a torus mesh
  41374. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41375. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41376. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41380. * @param name defines the name of the mesh
  41381. * @param options defines the options used to create the mesh
  41382. * @param scene defines the hosting scene
  41383. * @returns the torus mesh
  41384. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41385. */
  41386. static CreateTorus(name: string, options: {
  41387. diameter?: number;
  41388. thickness?: number;
  41389. tessellation?: number;
  41390. updatable?: boolean;
  41391. sideOrientation?: number;
  41392. frontUVs?: Vector4;
  41393. backUVs?: Vector4;
  41394. }, scene: any): Mesh;
  41395. }
  41396. }
  41397. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41398. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41399. import { Mesh } from "babylonjs/Meshes/mesh";
  41400. /**
  41401. * Class containing static functions to help procedurally build meshes
  41402. */
  41403. export class CylinderBuilder {
  41404. /**
  41405. * Creates a cylinder or a cone mesh
  41406. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41407. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41408. * * 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.
  41409. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41410. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41411. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41412. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41413. * * 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).
  41414. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41415. * * 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).
  41416. * * 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
  41417. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41418. * * 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
  41419. * * 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.
  41420. * * If `enclose` is false, a ring surface is one element.
  41421. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41422. * * 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
  41423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41426. * @param name defines the name of the mesh
  41427. * @param options defines the options used to create the mesh
  41428. * @param scene defines the hosting scene
  41429. * @returns the cylinder mesh
  41430. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41431. */
  41432. static CreateCylinder(name: string, options: {
  41433. height?: number;
  41434. diameterTop?: number;
  41435. diameterBottom?: number;
  41436. diameter?: number;
  41437. tessellation?: number;
  41438. subdivisions?: number;
  41439. arc?: number;
  41440. faceColors?: Color4[];
  41441. faceUV?: Vector4[];
  41442. updatable?: boolean;
  41443. hasRings?: boolean;
  41444. enclose?: boolean;
  41445. cap?: number;
  41446. sideOrientation?: number;
  41447. frontUVs?: Vector4;
  41448. backUVs?: Vector4;
  41449. }, scene: any): Mesh;
  41450. }
  41451. }
  41452. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41453. import { Observable } from "babylonjs/Misc/observable";
  41454. import { Nullable } from "babylonjs/types";
  41455. import { Camera } from "babylonjs/Cameras/camera";
  41456. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41457. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41458. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41459. import { Scene } from "babylonjs/scene";
  41460. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41461. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41463. import { Mesh } from "babylonjs/Meshes/mesh";
  41464. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41465. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41466. import "babylonjs/Meshes/Builders/groundBuilder";
  41467. import "babylonjs/Meshes/Builders/torusBuilder";
  41468. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41469. import "babylonjs/Gamepads/gamepadSceneComponent";
  41470. import "babylonjs/Animations/animatable";
  41471. /**
  41472. * Options to modify the vr teleportation behavior.
  41473. */
  41474. export interface VRTeleportationOptions {
  41475. /**
  41476. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41477. */
  41478. floorMeshName?: string;
  41479. /**
  41480. * A list of meshes to be used as the teleportation floor. (default: empty)
  41481. */
  41482. floorMeshes?: Mesh[];
  41483. }
  41484. /**
  41485. * Options to modify the vr experience helper's behavior.
  41486. */
  41487. export interface VRExperienceHelperOptions extends WebVROptions {
  41488. /**
  41489. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41490. */
  41491. createDeviceOrientationCamera?: boolean;
  41492. /**
  41493. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41494. */
  41495. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41496. /**
  41497. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41498. */
  41499. laserToggle?: boolean;
  41500. /**
  41501. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41502. */
  41503. floorMeshes?: Mesh[];
  41504. /**
  41505. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41506. */
  41507. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41508. }
  41509. /**
  41510. * Event containing information after VR has been entered
  41511. */
  41512. export class OnAfterEnteringVRObservableEvent {
  41513. /**
  41514. * If entering vr was successful
  41515. */
  41516. success: boolean;
  41517. }
  41518. /**
  41519. * Helps to quickly add VR support to an existing scene.
  41520. * See http://doc.babylonjs.com/how_to/webvr_helper
  41521. */
  41522. export class VRExperienceHelper {
  41523. /** Options to modify the vr experience helper's behavior. */
  41524. webVROptions: VRExperienceHelperOptions;
  41525. private _scene;
  41526. private _position;
  41527. private _btnVR;
  41528. private _btnVRDisplayed;
  41529. private _webVRsupported;
  41530. private _webVRready;
  41531. private _webVRrequesting;
  41532. private _webVRpresenting;
  41533. private _hasEnteredVR;
  41534. private _fullscreenVRpresenting;
  41535. private _canvas;
  41536. private _webVRCamera;
  41537. private _vrDeviceOrientationCamera;
  41538. private _deviceOrientationCamera;
  41539. private _existingCamera;
  41540. private _onKeyDown;
  41541. private _onVrDisplayPresentChange;
  41542. private _onVRDisplayChanged;
  41543. private _onVRRequestPresentStart;
  41544. private _onVRRequestPresentComplete;
  41545. /**
  41546. * Observable raised right before entering VR.
  41547. */
  41548. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41549. /**
  41550. * Observable raised when entering VR has completed.
  41551. */
  41552. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41553. /**
  41554. * Observable raised when exiting VR.
  41555. */
  41556. onExitingVRObservable: Observable<VRExperienceHelper>;
  41557. /**
  41558. * Observable raised when controller mesh is loaded.
  41559. */
  41560. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41561. /** Return this.onEnteringVRObservable
  41562. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41563. */
  41564. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41565. /** Return this.onExitingVRObservable
  41566. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41567. */
  41568. readonly onExitingVR: Observable<VRExperienceHelper>;
  41569. /** Return this.onControllerMeshLoadedObservable
  41570. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41571. */
  41572. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41573. private _rayLength;
  41574. private _useCustomVRButton;
  41575. private _teleportationRequested;
  41576. private _teleportActive;
  41577. private _floorMeshName;
  41578. private _floorMeshesCollection;
  41579. private _rotationAllowed;
  41580. private _teleportBackwardsVector;
  41581. private _teleportationTarget;
  41582. private _isDefaultTeleportationTarget;
  41583. private _postProcessMove;
  41584. private _teleportationFillColor;
  41585. private _teleportationBorderColor;
  41586. private _rotationAngle;
  41587. private _haloCenter;
  41588. private _cameraGazer;
  41589. private _padSensibilityUp;
  41590. private _padSensibilityDown;
  41591. private _leftController;
  41592. private _rightController;
  41593. /**
  41594. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41595. */
  41596. onNewMeshSelected: Observable<AbstractMesh>;
  41597. /**
  41598. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41599. */
  41600. onNewMeshPicked: Observable<PickingInfo>;
  41601. private _circleEase;
  41602. /**
  41603. * Observable raised before camera teleportation
  41604. */
  41605. onBeforeCameraTeleport: Observable<Vector3>;
  41606. /**
  41607. * Observable raised after camera teleportation
  41608. */
  41609. onAfterCameraTeleport: Observable<Vector3>;
  41610. /**
  41611. * Observable raised when current selected mesh gets unselected
  41612. */
  41613. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41614. private _raySelectionPredicate;
  41615. /**
  41616. * To be optionaly changed by user to define custom ray selection
  41617. */
  41618. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41619. /**
  41620. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41621. */
  41622. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41623. /**
  41624. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41625. */
  41626. teleportationEnabled: boolean;
  41627. private _defaultHeight;
  41628. private _teleportationInitialized;
  41629. private _interactionsEnabled;
  41630. private _interactionsRequested;
  41631. private _displayGaze;
  41632. private _displayLaserPointer;
  41633. /**
  41634. * The mesh used to display where the user is going to teleport.
  41635. */
  41636. /**
  41637. * Sets the mesh to be used to display where the user is going to teleport.
  41638. */
  41639. teleportationTarget: Mesh;
  41640. /**
  41641. * 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
  41642. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41643. * See http://doc.babylonjs.com/resources/baking_transformations
  41644. */
  41645. gazeTrackerMesh: Mesh;
  41646. /**
  41647. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41648. */
  41649. updateGazeTrackerScale: boolean;
  41650. /**
  41651. * If the gaze trackers color should be updated when selecting meshes
  41652. */
  41653. updateGazeTrackerColor: boolean;
  41654. /**
  41655. * The gaze tracking mesh corresponding to the left controller
  41656. */
  41657. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41658. /**
  41659. * The gaze tracking mesh corresponding to the right controller
  41660. */
  41661. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41662. /**
  41663. * If the ray of the gaze should be displayed.
  41664. */
  41665. /**
  41666. * Sets if the ray of the gaze should be displayed.
  41667. */
  41668. displayGaze: boolean;
  41669. /**
  41670. * If the ray of the LaserPointer should be displayed.
  41671. */
  41672. /**
  41673. * Sets if the ray of the LaserPointer should be displayed.
  41674. */
  41675. displayLaserPointer: boolean;
  41676. /**
  41677. * The deviceOrientationCamera used as the camera when not in VR.
  41678. */
  41679. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41680. /**
  41681. * Based on the current WebVR support, returns the current VR camera used.
  41682. */
  41683. readonly currentVRCamera: Nullable<Camera>;
  41684. /**
  41685. * The webVRCamera which is used when in VR.
  41686. */
  41687. readonly webVRCamera: WebVRFreeCamera;
  41688. /**
  41689. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41690. */
  41691. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41692. private readonly _teleportationRequestInitiated;
  41693. /**
  41694. * Defines wether or not Pointer lock should be requested when switching to
  41695. * full screen.
  41696. */
  41697. requestPointerLockOnFullScreen: boolean;
  41698. /**
  41699. * Instantiates a VRExperienceHelper.
  41700. * Helps to quickly add VR support to an existing scene.
  41701. * @param scene The scene the VRExperienceHelper belongs to.
  41702. * @param webVROptions Options to modify the vr experience helper's behavior.
  41703. */
  41704. constructor(scene: Scene,
  41705. /** Options to modify the vr experience helper's behavior. */
  41706. webVROptions?: VRExperienceHelperOptions);
  41707. private _onDefaultMeshLoaded;
  41708. private _onResize;
  41709. private _onFullscreenChange;
  41710. /**
  41711. * Gets a value indicating if we are currently in VR mode.
  41712. */
  41713. readonly isInVRMode: boolean;
  41714. private onVrDisplayPresentChange;
  41715. private onVRDisplayChanged;
  41716. private moveButtonToBottomRight;
  41717. private displayVRButton;
  41718. private updateButtonVisibility;
  41719. private _cachedAngularSensibility;
  41720. /**
  41721. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41722. * Otherwise, will use the fullscreen API.
  41723. */
  41724. enterVR(): void;
  41725. /**
  41726. * Attempt to exit VR, or fullscreen.
  41727. */
  41728. exitVR(): void;
  41729. /**
  41730. * The position of the vr experience helper.
  41731. */
  41732. /**
  41733. * Sets the position of the vr experience helper.
  41734. */
  41735. position: Vector3;
  41736. /**
  41737. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41738. */
  41739. enableInteractions(): void;
  41740. private readonly _noControllerIsActive;
  41741. private beforeRender;
  41742. private _isTeleportationFloor;
  41743. /**
  41744. * Adds a floor mesh to be used for teleportation.
  41745. * @param floorMesh the mesh to be used for teleportation.
  41746. */
  41747. addFloorMesh(floorMesh: Mesh): void;
  41748. /**
  41749. * Removes a floor mesh from being used for teleportation.
  41750. * @param floorMesh the mesh to be removed.
  41751. */
  41752. removeFloorMesh(floorMesh: Mesh): void;
  41753. /**
  41754. * Enables interactions and teleportation using the VR controllers and gaze.
  41755. * @param vrTeleportationOptions options to modify teleportation behavior.
  41756. */
  41757. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41758. private _onNewGamepadConnected;
  41759. private _tryEnableInteractionOnController;
  41760. private _onNewGamepadDisconnected;
  41761. private _enableInteractionOnController;
  41762. private _checkTeleportWithRay;
  41763. private _checkRotate;
  41764. private _checkTeleportBackwards;
  41765. private _enableTeleportationOnController;
  41766. private _createTeleportationCircles;
  41767. private _displayTeleportationTarget;
  41768. private _hideTeleportationTarget;
  41769. private _rotateCamera;
  41770. private _moveTeleportationSelectorTo;
  41771. private _workingVector;
  41772. private _workingQuaternion;
  41773. private _workingMatrix;
  41774. /**
  41775. * Teleports the users feet to the desired location
  41776. * @param location The location where the user's feet should be placed
  41777. */
  41778. teleportCamera(location: Vector3): void;
  41779. private _convertNormalToDirectionOfRay;
  41780. private _castRayAndSelectObject;
  41781. private _notifySelectedMeshUnselected;
  41782. /**
  41783. * Sets the color of the laser ray from the vr controllers.
  41784. * @param color new color for the ray.
  41785. */
  41786. changeLaserColor(color: Color3): void;
  41787. /**
  41788. * Sets the color of the ray from the vr headsets gaze.
  41789. * @param color new color for the ray.
  41790. */
  41791. changeGazeColor(color: Color3): void;
  41792. /**
  41793. * Exits VR and disposes of the vr experience helper
  41794. */
  41795. dispose(): void;
  41796. /**
  41797. * Gets the name of the VRExperienceHelper class
  41798. * @returns "VRExperienceHelper"
  41799. */
  41800. getClassName(): string;
  41801. }
  41802. }
  41803. declare module "babylonjs/Cameras/VR/index" {
  41804. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41805. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41806. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41807. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41808. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41809. export * from "babylonjs/Cameras/VR/webVRCamera";
  41810. }
  41811. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41812. import { Observable } from "babylonjs/Misc/observable";
  41813. import { Nullable } from "babylonjs/types";
  41814. import { IDisposable, Scene } from "babylonjs/scene";
  41815. import { Vector3 } from "babylonjs/Maths/math";
  41816. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41817. import { Ray } from "babylonjs/Culling/ray";
  41818. /**
  41819. * Manages an XRSession
  41820. * @see https://doc.babylonjs.com/how_to/webxr
  41821. */
  41822. export class WebXRSessionManager implements IDisposable {
  41823. private scene;
  41824. /**
  41825. * Fires every time a new xrFrame arrives which can be used to update the camera
  41826. */
  41827. onXRFrameObservable: Observable<any>;
  41828. /**
  41829. * Fires when the xr session is ended either by the device or manually done
  41830. */
  41831. onXRSessionEnded: Observable<any>;
  41832. /** @hidden */
  41833. _xrSession: XRSession;
  41834. /** @hidden */
  41835. _frameOfReference: XRFrameOfReference;
  41836. /** @hidden */
  41837. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41838. /** @hidden */
  41839. _currentXRFrame: Nullable<XRFrame>;
  41840. private _xrNavigator;
  41841. private _xrDevice;
  41842. private _tmpMatrix;
  41843. /**
  41844. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41845. * @param scene The scene which the session should be created for
  41846. */
  41847. constructor(scene: Scene);
  41848. /**
  41849. * Initializes the manager
  41850. * After initialization enterXR can be called to start an XR session
  41851. * @returns Promise which resolves after it is initialized
  41852. */
  41853. initializeAsync(): Promise<void>;
  41854. /**
  41855. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41856. * @param sessionCreationOptions xr options to create the session with
  41857. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41858. * @returns Promise which resolves after it enters XR
  41859. */
  41860. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41861. /**
  41862. * Stops the xrSession and restores the renderloop
  41863. * @returns Promise which resolves after it exits XR
  41864. */
  41865. exitXRAsync(): Promise<void>;
  41866. /**
  41867. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41868. * @param ray ray to cast into the environment
  41869. * @returns Promise which resolves with a collision point in the environment if it exists
  41870. */
  41871. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41872. /**
  41873. * Checks if a session would be supported for the creation options specified
  41874. * @param options creation options to check if they are supported
  41875. * @returns true if supported
  41876. */
  41877. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41878. /**
  41879. * @hidden
  41880. * Converts the render layer of xrSession to a render target
  41881. * @param session session to create render target for
  41882. * @param scene scene the new render target should be created for
  41883. */
  41884. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41885. /**
  41886. * Disposes of the session manager
  41887. */
  41888. dispose(): void;
  41889. }
  41890. }
  41891. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41892. import { Scene } from "babylonjs/scene";
  41893. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41894. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41895. /**
  41896. * WebXR Camera which holds the views for the xrSession
  41897. * @see https://doc.babylonjs.com/how_to/webxr
  41898. */
  41899. export class WebXRCamera extends FreeCamera {
  41900. private static _TmpMatrix;
  41901. /**
  41902. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41903. * @param name the name of the camera
  41904. * @param scene the scene to add the camera to
  41905. */
  41906. constructor(name: string, scene: Scene);
  41907. private _updateNumberOfRigCameras;
  41908. /** @hidden */
  41909. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41910. /**
  41911. * Updates the cameras position from the current pose information of the XR session
  41912. * @param xrSessionManager the session containing pose information
  41913. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41914. */
  41915. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41916. }
  41917. }
  41918. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41919. import { Nullable } from "babylonjs/types";
  41920. import { Observable } from "babylonjs/Misc/observable";
  41921. import { IDisposable, Scene } from "babylonjs/scene";
  41922. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41924. import { Ray } from "babylonjs/Culling/ray";
  41925. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41926. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41927. /**
  41928. * States of the webXR experience
  41929. */
  41930. export enum WebXRState {
  41931. /**
  41932. * Transitioning to being in XR mode
  41933. */
  41934. ENTERING_XR = 0,
  41935. /**
  41936. * Transitioning to non XR mode
  41937. */
  41938. EXITING_XR = 1,
  41939. /**
  41940. * In XR mode and presenting
  41941. */
  41942. IN_XR = 2,
  41943. /**
  41944. * Not entered XR mode
  41945. */
  41946. NOT_IN_XR = 3
  41947. }
  41948. /**
  41949. * Helper class used to enable XR
  41950. * @see https://doc.babylonjs.com/how_to/webxr
  41951. */
  41952. export class WebXRExperienceHelper implements IDisposable {
  41953. private scene;
  41954. /**
  41955. * 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
  41956. */
  41957. container: AbstractMesh;
  41958. /**
  41959. * Camera used to render xr content
  41960. */
  41961. camera: WebXRCamera;
  41962. /**
  41963. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41964. */
  41965. state: WebXRState;
  41966. private _setState;
  41967. private static _TmpVector;
  41968. /**
  41969. * Fires when the state of the experience helper has changed
  41970. */
  41971. onStateChangedObservable: Observable<WebXRState>;
  41972. /** @hidden */
  41973. _sessionManager: WebXRSessionManager;
  41974. private _nonVRCamera;
  41975. private _originalSceneAutoClear;
  41976. private _supported;
  41977. /**
  41978. * Creates the experience helper
  41979. * @param scene the scene to attach the experience helper to
  41980. * @returns a promise for the experience helper
  41981. */
  41982. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41983. /**
  41984. * Creates a WebXRExperienceHelper
  41985. * @param scene The scene the helper should be created in
  41986. */
  41987. private constructor();
  41988. /**
  41989. * Exits XR mode and returns the scene to its original state
  41990. * @returns promise that resolves after xr mode has exited
  41991. */
  41992. exitXRAsync(): Promise<void>;
  41993. /**
  41994. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41995. * @param sessionCreationOptions options for the XR session
  41996. * @param frameOfReference frame of reference of the XR session
  41997. * @returns promise that resolves after xr mode has entered
  41998. */
  41999. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  42000. /**
  42001. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  42002. * @param ray ray to cast into the environment
  42003. * @returns Promise which resolves with a collision point in the environment if it exists
  42004. */
  42005. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  42006. /**
  42007. * Updates the global position of the camera by moving the camera's container
  42008. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42009. * @param position The desired global position of the camera
  42010. */
  42011. setPositionOfCameraUsingContainer(position: Vector3): void;
  42012. /**
  42013. * Rotates the xr camera by rotating the camera's container around the camera's position
  42014. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42015. * @param rotation the desired quaternion rotation to apply to the camera
  42016. */
  42017. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42018. /**
  42019. * Checks if the creation options are supported by the xr session
  42020. * @param options creation options
  42021. * @returns true if supported
  42022. */
  42023. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  42024. /**
  42025. * Disposes of the experience helper
  42026. */
  42027. dispose(): void;
  42028. }
  42029. }
  42030. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42031. import { Nullable } from "babylonjs/types";
  42032. import { Observable } from "babylonjs/Misc/observable";
  42033. import { IDisposable, Scene } from "babylonjs/scene";
  42034. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42035. /**
  42036. * Button which can be used to enter a different mode of XR
  42037. */
  42038. export class WebXREnterExitUIButton {
  42039. /** button element */
  42040. element: HTMLElement;
  42041. /** XR initialization options for the button */
  42042. initializationOptions: XRSessionCreationOptions;
  42043. /**
  42044. * Creates a WebXREnterExitUIButton
  42045. * @param element button element
  42046. * @param initializationOptions XR initialization options for the button
  42047. */
  42048. constructor(
  42049. /** button element */
  42050. element: HTMLElement,
  42051. /** XR initialization options for the button */
  42052. initializationOptions: XRSessionCreationOptions);
  42053. /**
  42054. * Overwritable function which can be used to update the button's visuals when the state changes
  42055. * @param activeButton the current active button in the UI
  42056. */
  42057. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42058. }
  42059. /**
  42060. * Options to create the webXR UI
  42061. */
  42062. export class WebXREnterExitUIOptions {
  42063. /**
  42064. * Context to enter xr with
  42065. */
  42066. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  42067. /**
  42068. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42069. */
  42070. customButtons?: Array<WebXREnterExitUIButton>;
  42071. }
  42072. /**
  42073. * UI to allow the user to enter/exit XR mode
  42074. */
  42075. export class WebXREnterExitUI implements IDisposable {
  42076. private scene;
  42077. private _overlay;
  42078. private _buttons;
  42079. private _activeButton;
  42080. /**
  42081. * Fired every time the active button is changed.
  42082. *
  42083. * When xr is entered via a button that launches xr that button will be the callback parameter
  42084. *
  42085. * When exiting xr the callback parameter will be null)
  42086. */
  42087. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42088. /**
  42089. * Creates UI to allow the user to enter/exit XR mode
  42090. * @param scene the scene to add the ui to
  42091. * @param helper the xr experience helper to enter/exit xr with
  42092. * @param options options to configure the UI
  42093. * @returns the created ui
  42094. */
  42095. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42096. private constructor();
  42097. private _updateButtons;
  42098. /**
  42099. * Disposes of the object
  42100. */
  42101. dispose(): void;
  42102. }
  42103. }
  42104. declare module "babylonjs/Cameras/XR/webXRInput" {
  42105. import { IDisposable, Scene } from "babylonjs/scene";
  42106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42107. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42108. /**
  42109. * Represents an XR input
  42110. */
  42111. export class WebXRController {
  42112. /**
  42113. * 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
  42114. */
  42115. grip?: AbstractMesh;
  42116. /**
  42117. * Pointer which can be used to select objects or attach a visible laser to
  42118. */
  42119. pointer: AbstractMesh;
  42120. /**
  42121. * Creates the controller
  42122. * @see https://doc.babylonjs.com/how_to/webxr
  42123. * @param scene the scene which the controller should be associated to
  42124. */
  42125. constructor(scene: Scene);
  42126. /**
  42127. * Disposes of the object
  42128. */
  42129. dispose(): void;
  42130. }
  42131. /**
  42132. * XR input used to track XR inputs such as controllers/rays
  42133. */
  42134. export class WebXRInput implements IDisposable {
  42135. private helper;
  42136. /**
  42137. * XR controllers being tracked
  42138. */
  42139. controllers: Array<WebXRController>;
  42140. private _tmpMatrix;
  42141. private _frameObserver;
  42142. /**
  42143. * Initializes the WebXRInput
  42144. * @param helper experience helper which the input should be created for
  42145. */
  42146. constructor(helper: WebXRExperienceHelper);
  42147. /**
  42148. * Disposes of the object
  42149. */
  42150. dispose(): void;
  42151. }
  42152. }
  42153. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42154. import { Nullable } from "babylonjs/types";
  42155. import { IDisposable } from "babylonjs/scene";
  42156. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42157. /**
  42158. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42159. */
  42160. export class WebXRManagedOutputCanvas implements IDisposable {
  42161. private _canvas;
  42162. /**
  42163. * xrpresent context of the canvas which can be used to display/mirror xr content
  42164. */
  42165. canvasContext: Nullable<WebGLRenderingContext>;
  42166. /**
  42167. * Initializes the canvas to be added/removed upon entering/exiting xr
  42168. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42169. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42170. */
  42171. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42172. /**
  42173. * Disposes of the object
  42174. */
  42175. dispose(): void;
  42176. private _setManagedOutputCanvas;
  42177. private _addCanvas;
  42178. private _removeCanvas;
  42179. }
  42180. }
  42181. declare module "babylonjs/Cameras/XR/index" {
  42182. export * from "babylonjs/Cameras/XR/webXRCamera";
  42183. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  42184. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42185. export * from "babylonjs/Cameras/XR/webXRInput";
  42186. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42187. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  42188. }
  42189. declare module "babylonjs/Cameras/RigModes/index" {
  42190. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42191. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42192. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  42193. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  42194. }
  42195. declare module "babylonjs/Cameras/index" {
  42196. export * from "babylonjs/Cameras/Inputs/index";
  42197. export * from "babylonjs/Cameras/cameraInputsManager";
  42198. export * from "babylonjs/Cameras/camera";
  42199. export * from "babylonjs/Cameras/targetCamera";
  42200. export * from "babylonjs/Cameras/freeCamera";
  42201. export * from "babylonjs/Cameras/freeCameraInputsManager";
  42202. export * from "babylonjs/Cameras/touchCamera";
  42203. export * from "babylonjs/Cameras/arcRotateCamera";
  42204. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  42205. export * from "babylonjs/Cameras/deviceOrientationCamera";
  42206. export * from "babylonjs/Cameras/flyCamera";
  42207. export * from "babylonjs/Cameras/flyCameraInputsManager";
  42208. export * from "babylonjs/Cameras/followCamera";
  42209. export * from "babylonjs/Cameras/gamepadCamera";
  42210. export * from "babylonjs/Cameras/Stereoscopic/index";
  42211. export * from "babylonjs/Cameras/universalCamera";
  42212. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  42213. export * from "babylonjs/Cameras/VR/index";
  42214. export * from "babylonjs/Cameras/XR/index";
  42215. export * from "babylonjs/Cameras/RigModes/index";
  42216. }
  42217. declare module "babylonjs/Collisions/index" {
  42218. export * from "babylonjs/Collisions/collider";
  42219. export * from "babylonjs/Collisions/collisionCoordinator";
  42220. export * from "babylonjs/Collisions/pickingInfo";
  42221. export * from "babylonjs/Collisions/intersectionInfo";
  42222. export * from "babylonjs/Collisions/meshCollisionData";
  42223. }
  42224. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  42225. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  42226. import { Vector3, Plane } from "babylonjs/Maths/math";
  42227. import { Ray } from "babylonjs/Culling/ray";
  42228. /**
  42229. * Contains an array of blocks representing the octree
  42230. */
  42231. export interface IOctreeContainer<T> {
  42232. /**
  42233. * Blocks within the octree
  42234. */
  42235. blocks: Array<OctreeBlock<T>>;
  42236. }
  42237. /**
  42238. * Class used to store a cell in an octree
  42239. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42240. */
  42241. export class OctreeBlock<T> {
  42242. /**
  42243. * Gets the content of the current block
  42244. */
  42245. entries: T[];
  42246. /**
  42247. * Gets the list of block children
  42248. */
  42249. blocks: Array<OctreeBlock<T>>;
  42250. private _depth;
  42251. private _maxDepth;
  42252. private _capacity;
  42253. private _minPoint;
  42254. private _maxPoint;
  42255. private _boundingVectors;
  42256. private _creationFunc;
  42257. /**
  42258. * Creates a new block
  42259. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42260. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42261. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42262. * @param depth defines the current depth of this block in the octree
  42263. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42264. * @param creationFunc defines a callback to call when an element is added to the block
  42265. */
  42266. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42267. /**
  42268. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42269. */
  42270. readonly capacity: number;
  42271. /**
  42272. * Gets the minimum vector (in world space) of the block's bounding box
  42273. */
  42274. readonly minPoint: Vector3;
  42275. /**
  42276. * Gets the maximum vector (in world space) of the block's bounding box
  42277. */
  42278. readonly maxPoint: Vector3;
  42279. /**
  42280. * Add a new element to this block
  42281. * @param entry defines the element to add
  42282. */
  42283. addEntry(entry: T): void;
  42284. /**
  42285. * Remove an element from this block
  42286. * @param entry defines the element to remove
  42287. */
  42288. removeEntry(entry: T): void;
  42289. /**
  42290. * Add an array of elements to this block
  42291. * @param entries defines the array of elements to add
  42292. */
  42293. addEntries(entries: T[]): void;
  42294. /**
  42295. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42296. * @param frustumPlanes defines the frustum planes to test
  42297. * @param selection defines the array to store current content if selection is positive
  42298. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42299. */
  42300. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42301. /**
  42302. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42303. * @param sphereCenter defines the bounding sphere center
  42304. * @param sphereRadius defines the bounding sphere radius
  42305. * @param selection defines the array to store current content if selection is positive
  42306. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42307. */
  42308. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42309. /**
  42310. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42311. * @param ray defines the ray to test with
  42312. * @param selection defines the array to store current content if selection is positive
  42313. */
  42314. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42315. /**
  42316. * Subdivide the content into child blocks (this block will then be empty)
  42317. */
  42318. createInnerBlocks(): void;
  42319. /**
  42320. * @hidden
  42321. */
  42322. 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;
  42323. }
  42324. }
  42325. declare module "babylonjs/Culling/Octrees/octree" {
  42326. import { SmartArray } from "babylonjs/Misc/smartArray";
  42327. import { Vector3, Plane } from "babylonjs/Maths/math";
  42328. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42330. import { Ray } from "babylonjs/Culling/ray";
  42331. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42332. /**
  42333. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42334. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42335. */
  42336. export class Octree<T> {
  42337. /** 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.) */
  42338. maxDepth: number;
  42339. /**
  42340. * Blocks within the octree containing objects
  42341. */
  42342. blocks: Array<OctreeBlock<T>>;
  42343. /**
  42344. * Content stored in the octree
  42345. */
  42346. dynamicContent: T[];
  42347. private _maxBlockCapacity;
  42348. private _selectionContent;
  42349. private _creationFunc;
  42350. /**
  42351. * Creates a octree
  42352. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42353. * @param creationFunc function to be used to instatiate the octree
  42354. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42355. * @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.)
  42356. */
  42357. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42358. /** 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.) */
  42359. maxDepth?: number);
  42360. /**
  42361. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42362. * @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);
  42363. * @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);
  42364. * @param entries meshes to be added to the octree blocks
  42365. */
  42366. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42367. /**
  42368. * Adds a mesh to the octree
  42369. * @param entry Mesh to add to the octree
  42370. */
  42371. addMesh(entry: T): void;
  42372. /**
  42373. * Remove an element from the octree
  42374. * @param entry defines the element to remove
  42375. */
  42376. removeMesh(entry: T): void;
  42377. /**
  42378. * Selects an array of meshes within the frustum
  42379. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42380. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42381. * @returns array of meshes within the frustum
  42382. */
  42383. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42384. /**
  42385. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42386. * @param sphereCenter defines the bounding sphere center
  42387. * @param sphereRadius defines the bounding sphere radius
  42388. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42389. * @returns an array of objects that intersect the sphere
  42390. */
  42391. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42392. /**
  42393. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42394. * @param ray defines the ray to test with
  42395. * @returns array of intersected objects
  42396. */
  42397. intersectsRay(ray: Ray): SmartArray<T>;
  42398. /**
  42399. * Adds a mesh into the octree block if it intersects the block
  42400. */
  42401. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42402. /**
  42403. * Adds a submesh into the octree block if it intersects the block
  42404. */
  42405. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42406. }
  42407. }
  42408. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42409. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42410. import { Scene } from "babylonjs/scene";
  42411. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42413. import { Ray } from "babylonjs/Culling/ray";
  42414. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42415. import { Collider } from "babylonjs/Collisions/collider";
  42416. module "babylonjs/scene" {
  42417. interface Scene {
  42418. /**
  42419. * @hidden
  42420. * Backing Filed
  42421. */
  42422. _selectionOctree: Octree<AbstractMesh>;
  42423. /**
  42424. * Gets the octree used to boost mesh selection (picking)
  42425. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42426. */
  42427. selectionOctree: Octree<AbstractMesh>;
  42428. /**
  42429. * Creates or updates the octree used to boost selection (picking)
  42430. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42431. * @param maxCapacity defines the maximum capacity per leaf
  42432. * @param maxDepth defines the maximum depth of the octree
  42433. * @returns an octree of AbstractMesh
  42434. */
  42435. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42436. }
  42437. }
  42438. module "babylonjs/Meshes/abstractMesh" {
  42439. interface AbstractMesh {
  42440. /**
  42441. * @hidden
  42442. * Backing Field
  42443. */
  42444. _submeshesOctree: Octree<SubMesh>;
  42445. /**
  42446. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42447. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42448. * @param maxCapacity defines the maximum size of each block (64 by default)
  42449. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42450. * @returns the new octree
  42451. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42452. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42453. */
  42454. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42455. }
  42456. }
  42457. /**
  42458. * Defines the octree scene component responsible to manage any octrees
  42459. * in a given scene.
  42460. */
  42461. export class OctreeSceneComponent {
  42462. /**
  42463. * The component name help to identify the component in the list of scene components.
  42464. */
  42465. readonly name: string;
  42466. /**
  42467. * The scene the component belongs to.
  42468. */
  42469. scene: Scene;
  42470. /**
  42471. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42472. */
  42473. readonly checksIsEnabled: boolean;
  42474. /**
  42475. * Creates a new instance of the component for the given scene
  42476. * @param scene Defines the scene to register the component in
  42477. */
  42478. constructor(scene: Scene);
  42479. /**
  42480. * Registers the component in a given scene
  42481. */
  42482. register(): void;
  42483. /**
  42484. * Return the list of active meshes
  42485. * @returns the list of active meshes
  42486. */
  42487. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42488. /**
  42489. * Return the list of active sub meshes
  42490. * @param mesh The mesh to get the candidates sub meshes from
  42491. * @returns the list of active sub meshes
  42492. */
  42493. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42494. private _tempRay;
  42495. /**
  42496. * Return the list of sub meshes intersecting with a given local ray
  42497. * @param mesh defines the mesh to find the submesh for
  42498. * @param localRay defines the ray in local space
  42499. * @returns the list of intersecting sub meshes
  42500. */
  42501. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42502. /**
  42503. * Return the list of sub meshes colliding with a collider
  42504. * @param mesh defines the mesh to find the submesh for
  42505. * @param collider defines the collider to evaluate the collision against
  42506. * @returns the list of colliding sub meshes
  42507. */
  42508. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42509. /**
  42510. * Rebuilds the elements related to this component in case of
  42511. * context lost for instance.
  42512. */
  42513. rebuild(): void;
  42514. /**
  42515. * Disposes the component and the associated ressources.
  42516. */
  42517. dispose(): void;
  42518. }
  42519. }
  42520. declare module "babylonjs/Culling/Octrees/index" {
  42521. export * from "babylonjs/Culling/Octrees/octree";
  42522. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42523. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42524. }
  42525. declare module "babylonjs/Culling/index" {
  42526. export * from "babylonjs/Culling/boundingBox";
  42527. export * from "babylonjs/Culling/boundingInfo";
  42528. export * from "babylonjs/Culling/boundingSphere";
  42529. export * from "babylonjs/Culling/Octrees/index";
  42530. export * from "babylonjs/Culling/ray";
  42531. }
  42532. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42533. import { IDisposable, Scene } from "babylonjs/scene";
  42534. import { Nullable } from "babylonjs/types";
  42535. import { Observable } from "babylonjs/Misc/observable";
  42536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42537. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42538. import { Camera } from "babylonjs/Cameras/camera";
  42539. /**
  42540. * Renders a layer on top of an existing scene
  42541. */
  42542. export class UtilityLayerRenderer implements IDisposable {
  42543. /** the original scene that will be rendered on top of */
  42544. originalScene: Scene;
  42545. private _pointerCaptures;
  42546. private _lastPointerEvents;
  42547. private static _DefaultUtilityLayer;
  42548. private static _DefaultKeepDepthUtilityLayer;
  42549. private _sharedGizmoLight;
  42550. private _renderCamera;
  42551. /**
  42552. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42553. * @returns the camera that is used when rendering the utility layer
  42554. */
  42555. getRenderCamera(): Nullable<Camera>;
  42556. /**
  42557. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42558. * @param cam the camera that should be used when rendering the utility layer
  42559. */
  42560. setRenderCamera(cam: Nullable<Camera>): void;
  42561. /**
  42562. * @hidden
  42563. * Light which used by gizmos to get light shading
  42564. */
  42565. _getSharedGizmoLight(): HemisphericLight;
  42566. /**
  42567. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42568. */
  42569. pickUtilitySceneFirst: boolean;
  42570. /**
  42571. * 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)
  42572. */
  42573. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42574. /**
  42575. * 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)
  42576. */
  42577. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42578. /**
  42579. * The scene that is rendered on top of the original scene
  42580. */
  42581. utilityLayerScene: Scene;
  42582. /**
  42583. * If the utility layer should automatically be rendered on top of existing scene
  42584. */
  42585. shouldRender: boolean;
  42586. /**
  42587. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42588. */
  42589. onlyCheckPointerDownEvents: boolean;
  42590. /**
  42591. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42592. */
  42593. processAllEvents: boolean;
  42594. /**
  42595. * Observable raised when the pointer move from the utility layer scene to the main scene
  42596. */
  42597. onPointerOutObservable: Observable<number>;
  42598. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42599. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42600. private _afterRenderObserver;
  42601. private _sceneDisposeObserver;
  42602. private _originalPointerObserver;
  42603. /**
  42604. * Instantiates a UtilityLayerRenderer
  42605. * @param originalScene the original scene that will be rendered on top of
  42606. * @param handleEvents boolean indicating if the utility layer should handle events
  42607. */
  42608. constructor(
  42609. /** the original scene that will be rendered on top of */
  42610. originalScene: Scene, handleEvents?: boolean);
  42611. private _notifyObservers;
  42612. /**
  42613. * Renders the utility layers scene on top of the original scene
  42614. */
  42615. render(): void;
  42616. /**
  42617. * Disposes of the renderer
  42618. */
  42619. dispose(): void;
  42620. private _updateCamera;
  42621. }
  42622. }
  42623. declare module "babylonjs/Gizmos/gizmo" {
  42624. import { Nullable } from "babylonjs/types";
  42625. import { IDisposable } from "babylonjs/scene";
  42626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42627. import { Mesh } from "babylonjs/Meshes/mesh";
  42628. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42629. /**
  42630. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42631. */
  42632. export class Gizmo implements IDisposable {
  42633. /** The utility layer the gizmo will be added to */
  42634. gizmoLayer: UtilityLayerRenderer;
  42635. /**
  42636. * The root mesh of the gizmo
  42637. */
  42638. _rootMesh: Mesh;
  42639. private _attachedMesh;
  42640. /**
  42641. * Ratio for the scale of the gizmo (Default: 1)
  42642. */
  42643. scaleRatio: number;
  42644. /**
  42645. * If a custom mesh has been set (Default: false)
  42646. */
  42647. protected _customMeshSet: boolean;
  42648. /**
  42649. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42650. * * When set, interactions will be enabled
  42651. */
  42652. attachedMesh: Nullable<AbstractMesh>;
  42653. /**
  42654. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42655. * @param mesh The mesh to replace the default mesh of the gizmo
  42656. */
  42657. setCustomMesh(mesh: Mesh): void;
  42658. /**
  42659. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42660. */
  42661. updateGizmoRotationToMatchAttachedMesh: boolean;
  42662. /**
  42663. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42664. */
  42665. updateGizmoPositionToMatchAttachedMesh: boolean;
  42666. /**
  42667. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42668. */
  42669. protected _updateScale: boolean;
  42670. protected _interactionsEnabled: boolean;
  42671. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42672. private _beforeRenderObserver;
  42673. private _tempVector;
  42674. /**
  42675. * Creates a gizmo
  42676. * @param gizmoLayer The utility layer the gizmo will be added to
  42677. */
  42678. constructor(
  42679. /** The utility layer the gizmo will be added to */
  42680. gizmoLayer?: UtilityLayerRenderer);
  42681. /**
  42682. * Updates the gizmo to match the attached mesh's position/rotation
  42683. */
  42684. protected _update(): void;
  42685. /**
  42686. * Disposes of the gizmo
  42687. */
  42688. dispose(): void;
  42689. }
  42690. }
  42691. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42692. import { Observable } from "babylonjs/Misc/observable";
  42693. import { Nullable } from "babylonjs/types";
  42694. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42695. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42697. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42698. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42699. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42700. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42701. import { Scene } from "babylonjs/scene";
  42702. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42703. /**
  42704. * Single plane drag gizmo
  42705. */
  42706. export class PlaneDragGizmo extends Gizmo {
  42707. /**
  42708. * Drag behavior responsible for the gizmos dragging interactions
  42709. */
  42710. dragBehavior: PointerDragBehavior;
  42711. private _pointerObserver;
  42712. /**
  42713. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42714. */
  42715. snapDistance: number;
  42716. /**
  42717. * Event that fires each time the gizmo snaps to a new location.
  42718. * * snapDistance is the the change in distance
  42719. */
  42720. onSnapObservable: Observable<{
  42721. snapDistance: number;
  42722. }>;
  42723. private _plane;
  42724. private _coloredMaterial;
  42725. private _hoverMaterial;
  42726. private _isEnabled;
  42727. private _parent;
  42728. /** @hidden */
  42729. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42730. /** @hidden */
  42731. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42732. /**
  42733. * Creates a PlaneDragGizmo
  42734. * @param gizmoLayer The utility layer the gizmo will be added to
  42735. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42736. * @param color The color of the gizmo
  42737. */
  42738. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42739. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42740. /**
  42741. * If the gizmo is enabled
  42742. */
  42743. isEnabled: boolean;
  42744. /**
  42745. * Disposes of the gizmo
  42746. */
  42747. dispose(): void;
  42748. }
  42749. }
  42750. declare module "babylonjs/Gizmos/positionGizmo" {
  42751. import { Observable } from "babylonjs/Misc/observable";
  42752. import { Nullable } from "babylonjs/types";
  42753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42754. import { Mesh } from "babylonjs/Meshes/mesh";
  42755. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42756. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42757. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42758. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42759. /**
  42760. * Gizmo that enables dragging a mesh along 3 axis
  42761. */
  42762. export class PositionGizmo extends Gizmo {
  42763. /**
  42764. * Internal gizmo used for interactions on the x axis
  42765. */
  42766. xGizmo: AxisDragGizmo;
  42767. /**
  42768. * Internal gizmo used for interactions on the y axis
  42769. */
  42770. yGizmo: AxisDragGizmo;
  42771. /**
  42772. * Internal gizmo used for interactions on the z axis
  42773. */
  42774. zGizmo: AxisDragGizmo;
  42775. /**
  42776. * Internal gizmo used for interactions on the yz plane
  42777. */
  42778. xPlaneGizmo: PlaneDragGizmo;
  42779. /**
  42780. * Internal gizmo used for interactions on the xz plane
  42781. */
  42782. yPlaneGizmo: PlaneDragGizmo;
  42783. /**
  42784. * Internal gizmo used for interactions on the xy plane
  42785. */
  42786. zPlaneGizmo: PlaneDragGizmo;
  42787. /**
  42788. * private variables
  42789. */
  42790. private _meshAttached;
  42791. private _updateGizmoRotationToMatchAttachedMesh;
  42792. private _snapDistance;
  42793. private _scaleRatio;
  42794. /** Fires an event when any of it's sub gizmos are dragged */
  42795. onDragStartObservable: Observable<{}>;
  42796. /** Fires an event when any of it's sub gizmos are released from dragging */
  42797. onDragEndObservable: Observable<{}>;
  42798. /**
  42799. * If set to true, planar drag is enabled
  42800. */
  42801. private _planarGizmoEnabled;
  42802. attachedMesh: Nullable<AbstractMesh>;
  42803. /**
  42804. * Creates a PositionGizmo
  42805. * @param gizmoLayer The utility layer the gizmo will be added to
  42806. */
  42807. constructor(gizmoLayer?: UtilityLayerRenderer);
  42808. /**
  42809. * If the planar drag gizmo is enabled
  42810. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42811. */
  42812. planarGizmoEnabled: boolean;
  42813. updateGizmoRotationToMatchAttachedMesh: boolean;
  42814. /**
  42815. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42816. */
  42817. snapDistance: number;
  42818. /**
  42819. * Ratio for the scale of the gizmo (Default: 1)
  42820. */
  42821. scaleRatio: number;
  42822. /**
  42823. * Disposes of the gizmo
  42824. */
  42825. dispose(): void;
  42826. /**
  42827. * CustomMeshes are not supported by this gizmo
  42828. * @param mesh The mesh to replace the default mesh of the gizmo
  42829. */
  42830. setCustomMesh(mesh: Mesh): void;
  42831. }
  42832. }
  42833. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42834. import { Observable } from "babylonjs/Misc/observable";
  42835. import { Nullable } from "babylonjs/types";
  42836. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42837. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42839. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42840. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42841. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42842. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42843. import { Scene } from "babylonjs/scene";
  42844. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42845. /**
  42846. * Single axis drag gizmo
  42847. */
  42848. export class AxisDragGizmo extends Gizmo {
  42849. /**
  42850. * Drag behavior responsible for the gizmos dragging interactions
  42851. */
  42852. dragBehavior: PointerDragBehavior;
  42853. private _pointerObserver;
  42854. /**
  42855. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42856. */
  42857. snapDistance: number;
  42858. /**
  42859. * Event that fires each time the gizmo snaps to a new location.
  42860. * * snapDistance is the the change in distance
  42861. */
  42862. onSnapObservable: Observable<{
  42863. snapDistance: number;
  42864. }>;
  42865. private _isEnabled;
  42866. private _parent;
  42867. private _arrow;
  42868. private _coloredMaterial;
  42869. private _hoverMaterial;
  42870. /** @hidden */
  42871. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42872. /** @hidden */
  42873. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42874. /**
  42875. * Creates an AxisDragGizmo
  42876. * @param gizmoLayer The utility layer the gizmo will be added to
  42877. * @param dragAxis The axis which the gizmo will be able to drag on
  42878. * @param color The color of the gizmo
  42879. */
  42880. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42881. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42882. /**
  42883. * If the gizmo is enabled
  42884. */
  42885. isEnabled: boolean;
  42886. /**
  42887. * Disposes of the gizmo
  42888. */
  42889. dispose(): void;
  42890. }
  42891. }
  42892. declare module "babylonjs/Debug/axesViewer" {
  42893. import { Vector3 } from "babylonjs/Maths/math";
  42894. import { Nullable } from "babylonjs/types";
  42895. import { Scene } from "babylonjs/scene";
  42896. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42897. /**
  42898. * The Axes viewer will show 3 axes in a specific point in space
  42899. */
  42900. export class AxesViewer {
  42901. private _xAxis;
  42902. private _yAxis;
  42903. private _zAxis;
  42904. private _scaleLinesFactor;
  42905. private _instanced;
  42906. /**
  42907. * Gets the hosting scene
  42908. */
  42909. scene: Scene;
  42910. /**
  42911. * Gets or sets a number used to scale line length
  42912. */
  42913. scaleLines: number;
  42914. /** Gets the node hierarchy used to render x-axis */
  42915. readonly xAxis: TransformNode;
  42916. /** Gets the node hierarchy used to render y-axis */
  42917. readonly yAxis: TransformNode;
  42918. /** Gets the node hierarchy used to render z-axis */
  42919. readonly zAxis: TransformNode;
  42920. /**
  42921. * Creates a new AxesViewer
  42922. * @param scene defines the hosting scene
  42923. * @param scaleLines defines a number used to scale line length (1 by default)
  42924. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42925. * @param xAxis defines the node hierarchy used to render the x-axis
  42926. * @param yAxis defines the node hierarchy used to render the y-axis
  42927. * @param zAxis defines the node hierarchy used to render the z-axis
  42928. */
  42929. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42930. /**
  42931. * Force the viewer to update
  42932. * @param position defines the position of the viewer
  42933. * @param xaxis defines the x axis of the viewer
  42934. * @param yaxis defines the y axis of the viewer
  42935. * @param zaxis defines the z axis of the viewer
  42936. */
  42937. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42938. /**
  42939. * Creates an instance of this axes viewer.
  42940. * @returns a new axes viewer with instanced meshes
  42941. */
  42942. createInstance(): AxesViewer;
  42943. /** Releases resources */
  42944. dispose(): void;
  42945. private static _SetRenderingGroupId;
  42946. }
  42947. }
  42948. declare module "babylonjs/Debug/boneAxesViewer" {
  42949. import { Nullable } from "babylonjs/types";
  42950. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42951. import { Vector3 } from "babylonjs/Maths/math";
  42952. import { Mesh } from "babylonjs/Meshes/mesh";
  42953. import { Bone } from "babylonjs/Bones/bone";
  42954. import { Scene } from "babylonjs/scene";
  42955. /**
  42956. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42957. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42958. */
  42959. export class BoneAxesViewer extends AxesViewer {
  42960. /**
  42961. * Gets or sets the target mesh where to display the axes viewer
  42962. */
  42963. mesh: Nullable<Mesh>;
  42964. /**
  42965. * Gets or sets the target bone where to display the axes viewer
  42966. */
  42967. bone: Nullable<Bone>;
  42968. /** Gets current position */
  42969. pos: Vector3;
  42970. /** Gets direction of X axis */
  42971. xaxis: Vector3;
  42972. /** Gets direction of Y axis */
  42973. yaxis: Vector3;
  42974. /** Gets direction of Z axis */
  42975. zaxis: Vector3;
  42976. /**
  42977. * Creates a new BoneAxesViewer
  42978. * @param scene defines the hosting scene
  42979. * @param bone defines the target bone
  42980. * @param mesh defines the target mesh
  42981. * @param scaleLines defines a scaling factor for line length (1 by default)
  42982. */
  42983. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42984. /**
  42985. * Force the viewer to update
  42986. */
  42987. update(): void;
  42988. /** Releases resources */
  42989. dispose(): void;
  42990. }
  42991. }
  42992. declare module "babylonjs/Debug/debugLayer" {
  42993. import { Scene } from "babylonjs/scene";
  42994. /**
  42995. * Interface used to define scene explorer extensibility option
  42996. */
  42997. export interface IExplorerExtensibilityOption {
  42998. /**
  42999. * Define the option label
  43000. */
  43001. label: string;
  43002. /**
  43003. * Defines the action to execute on click
  43004. */
  43005. action: (entity: any) => void;
  43006. }
  43007. /**
  43008. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43009. */
  43010. export interface IExplorerExtensibilityGroup {
  43011. /**
  43012. * Defines a predicate to test if a given type mut be extended
  43013. */
  43014. predicate: (entity: any) => boolean;
  43015. /**
  43016. * Gets the list of options added to a type
  43017. */
  43018. entries: IExplorerExtensibilityOption[];
  43019. }
  43020. /**
  43021. * Interface used to define the options to use to create the Inspector
  43022. */
  43023. export interface IInspectorOptions {
  43024. /**
  43025. * Display in overlay mode (default: false)
  43026. */
  43027. overlay?: boolean;
  43028. /**
  43029. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43030. */
  43031. globalRoot?: HTMLElement;
  43032. /**
  43033. * Display the Scene explorer
  43034. */
  43035. showExplorer?: boolean;
  43036. /**
  43037. * Display the property inspector
  43038. */
  43039. showInspector?: boolean;
  43040. /**
  43041. * Display in embed mode (both panes on the right)
  43042. */
  43043. embedMode?: boolean;
  43044. /**
  43045. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43046. */
  43047. handleResize?: boolean;
  43048. /**
  43049. * Allow the panes to popup (default: true)
  43050. */
  43051. enablePopup?: boolean;
  43052. /**
  43053. * Allow the panes to be closed by users (default: true)
  43054. */
  43055. enableClose?: boolean;
  43056. /**
  43057. * Optional list of extensibility entries
  43058. */
  43059. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43060. /**
  43061. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43062. */
  43063. inspectorURL?: string;
  43064. }
  43065. module "babylonjs/scene" {
  43066. interface Scene {
  43067. /**
  43068. * @hidden
  43069. * Backing field
  43070. */
  43071. _debugLayer: DebugLayer;
  43072. /**
  43073. * Gets the debug layer (aka Inspector) associated with the scene
  43074. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43075. */
  43076. debugLayer: DebugLayer;
  43077. }
  43078. }
  43079. /**
  43080. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43081. * what is happening in your scene
  43082. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43083. */
  43084. export class DebugLayer {
  43085. /**
  43086. * Define the url to get the inspector script from.
  43087. * By default it uses the babylonjs CDN.
  43088. * @ignoreNaming
  43089. */
  43090. static InspectorURL: string;
  43091. private _scene;
  43092. private BJSINSPECTOR;
  43093. private _onPropertyChangedObservable?;
  43094. /**
  43095. * Observable triggered when a property is changed through the inspector.
  43096. */
  43097. readonly onPropertyChangedObservable: any;
  43098. /**
  43099. * Instantiates a new debug layer.
  43100. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43101. * what is happening in your scene
  43102. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43103. * @param scene Defines the scene to inspect
  43104. */
  43105. constructor(scene: Scene);
  43106. /** Creates the inspector window. */
  43107. private _createInspector;
  43108. /**
  43109. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43110. * @param entity defines the entity to select
  43111. * @param lineContainerTitle defines the specific block to highlight
  43112. */
  43113. select(entity: any, lineContainerTitle?: string): void;
  43114. /** Get the inspector from bundle or global */
  43115. private _getGlobalInspector;
  43116. /**
  43117. * Get if the inspector is visible or not.
  43118. * @returns true if visible otherwise, false
  43119. */
  43120. isVisible(): boolean;
  43121. /**
  43122. * Hide the inspector and close its window.
  43123. */
  43124. hide(): void;
  43125. /**
  43126. * Launch the debugLayer.
  43127. * @param config Define the configuration of the inspector
  43128. * @return a promise fulfilled when the debug layer is visible
  43129. */
  43130. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43131. }
  43132. }
  43133. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  43134. import { Nullable } from "babylonjs/types";
  43135. import { Scene } from "babylonjs/scene";
  43136. import { Vector4, Color4 } from "babylonjs/Maths/math";
  43137. import { Mesh } from "babylonjs/Meshes/mesh";
  43138. /**
  43139. * Class containing static functions to help procedurally build meshes
  43140. */
  43141. export class BoxBuilder {
  43142. /**
  43143. * Creates a box mesh
  43144. * * The parameter `size` sets the size (float) of each box side (default 1)
  43145. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43146. * * 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)
  43147. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43151. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43152. * @param name defines the name of the mesh
  43153. * @param options defines the options used to create the mesh
  43154. * @param scene defines the hosting scene
  43155. * @returns the box mesh
  43156. */
  43157. static CreateBox(name: string, options: {
  43158. size?: number;
  43159. width?: number;
  43160. height?: number;
  43161. depth?: number;
  43162. faceUV?: Vector4[];
  43163. faceColors?: Color4[];
  43164. sideOrientation?: number;
  43165. frontUVs?: Vector4;
  43166. backUVs?: Vector4;
  43167. wrap?: boolean;
  43168. topBaseAt?: number;
  43169. bottomBaseAt?: number;
  43170. updatable?: boolean;
  43171. }, scene?: Nullable<Scene>): Mesh;
  43172. }
  43173. }
  43174. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  43175. import { Vector4 } from "babylonjs/Maths/math";
  43176. import { Mesh } from "babylonjs/Meshes/mesh";
  43177. /**
  43178. * Class containing static functions to help procedurally build meshes
  43179. */
  43180. export class SphereBuilder {
  43181. /**
  43182. * Creates a sphere mesh
  43183. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43184. * * 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`)
  43185. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43186. * * 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
  43187. * * 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)
  43188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43191. * @param name defines the name of the mesh
  43192. * @param options defines the options used to create the mesh
  43193. * @param scene defines the hosting scene
  43194. * @returns the sphere mesh
  43195. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43196. */
  43197. static CreateSphere(name: string, options: {
  43198. segments?: number;
  43199. diameter?: number;
  43200. diameterX?: number;
  43201. diameterY?: number;
  43202. diameterZ?: number;
  43203. arc?: number;
  43204. slice?: number;
  43205. sideOrientation?: number;
  43206. frontUVs?: Vector4;
  43207. backUVs?: Vector4;
  43208. updatable?: boolean;
  43209. }, scene: any): Mesh;
  43210. }
  43211. }
  43212. declare module "babylonjs/Debug/physicsViewer" {
  43213. import { Nullable } from "babylonjs/types";
  43214. import { Scene } from "babylonjs/scene";
  43215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43216. import { Mesh } from "babylonjs/Meshes/mesh";
  43217. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  43218. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  43219. /**
  43220. * Used to show the physics impostor around the specific mesh
  43221. */
  43222. export class PhysicsViewer {
  43223. /** @hidden */
  43224. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43225. /** @hidden */
  43226. protected _meshes: Array<Nullable<AbstractMesh>>;
  43227. /** @hidden */
  43228. protected _scene: Nullable<Scene>;
  43229. /** @hidden */
  43230. protected _numMeshes: number;
  43231. /** @hidden */
  43232. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43233. private _renderFunction;
  43234. private _utilityLayer;
  43235. private _debugBoxMesh;
  43236. private _debugSphereMesh;
  43237. private _debugCylinderMesh;
  43238. private _debugMaterial;
  43239. private _debugMeshMeshes;
  43240. /**
  43241. * Creates a new PhysicsViewer
  43242. * @param scene defines the hosting scene
  43243. */
  43244. constructor(scene: Scene);
  43245. /** @hidden */
  43246. protected _updateDebugMeshes(): void;
  43247. /**
  43248. * Renders a specified physic impostor
  43249. * @param impostor defines the impostor to render
  43250. * @param targetMesh defines the mesh represented by the impostor
  43251. * @returns the new debug mesh used to render the impostor
  43252. */
  43253. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43254. /**
  43255. * Hides a specified physic impostor
  43256. * @param impostor defines the impostor to hide
  43257. */
  43258. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43259. private _getDebugMaterial;
  43260. private _getDebugBoxMesh;
  43261. private _getDebugSphereMesh;
  43262. private _getDebugCylinderMesh;
  43263. private _getDebugMeshMesh;
  43264. private _getDebugMesh;
  43265. /** Releases all resources */
  43266. dispose(): void;
  43267. }
  43268. }
  43269. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43270. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43271. import { Nullable } from "babylonjs/types";
  43272. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43273. import { Scene } from "babylonjs/scene";
  43274. /**
  43275. * Class containing static functions to help procedurally build meshes
  43276. */
  43277. export class LinesBuilder {
  43278. /**
  43279. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43280. * * 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
  43281. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43282. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43283. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43284. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43285. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43286. * * 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
  43287. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43290. * @param name defines the name of the new line system
  43291. * @param options defines the options used to create the line system
  43292. * @param scene defines the hosting scene
  43293. * @returns a new line system mesh
  43294. */
  43295. static CreateLineSystem(name: string, options: {
  43296. lines: Vector3[][];
  43297. updatable?: boolean;
  43298. instance?: Nullable<LinesMesh>;
  43299. colors?: Nullable<Color4[][]>;
  43300. useVertexAlpha?: boolean;
  43301. }, scene: Nullable<Scene>): LinesMesh;
  43302. /**
  43303. * Creates a line mesh
  43304. * 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
  43305. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43306. * * The parameter `points` is an array successive Vector3
  43307. * * 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
  43308. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43309. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43310. * * When updating an instance, remember that only point positions can change, not the number of points
  43311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43313. * @param name defines the name of the new line system
  43314. * @param options defines the options used to create the line system
  43315. * @param scene defines the hosting scene
  43316. * @returns a new line mesh
  43317. */
  43318. static CreateLines(name: string, options: {
  43319. points: Vector3[];
  43320. updatable?: boolean;
  43321. instance?: Nullable<LinesMesh>;
  43322. colors?: Color4[];
  43323. useVertexAlpha?: boolean;
  43324. }, scene?: Nullable<Scene>): LinesMesh;
  43325. /**
  43326. * Creates a dashed line mesh
  43327. * * 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
  43328. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43329. * * The parameter `points` is an array successive Vector3
  43330. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43331. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43332. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43333. * * 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
  43334. * * When updating an instance, remember that only point positions can change, not the number of points
  43335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43336. * @param name defines the name of the mesh
  43337. * @param options defines the options used to create the mesh
  43338. * @param scene defines the hosting scene
  43339. * @returns the dashed line mesh
  43340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43341. */
  43342. static CreateDashedLines(name: string, options: {
  43343. points: Vector3[];
  43344. dashSize?: number;
  43345. gapSize?: number;
  43346. dashNb?: number;
  43347. updatable?: boolean;
  43348. instance?: LinesMesh;
  43349. }, scene?: Nullable<Scene>): LinesMesh;
  43350. }
  43351. }
  43352. declare module "babylonjs/Debug/rayHelper" {
  43353. import { Nullable } from "babylonjs/types";
  43354. import { Ray } from "babylonjs/Culling/ray";
  43355. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43356. import { Scene } from "babylonjs/scene";
  43357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43358. import "babylonjs/Meshes/Builders/linesBuilder";
  43359. /**
  43360. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43361. * in order to better appreciate the issue one might have.
  43362. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43363. */
  43364. export class RayHelper {
  43365. /**
  43366. * Defines the ray we are currently tryin to visualize.
  43367. */
  43368. ray: Nullable<Ray>;
  43369. private _renderPoints;
  43370. private _renderLine;
  43371. private _renderFunction;
  43372. private _scene;
  43373. private _updateToMeshFunction;
  43374. private _attachedToMesh;
  43375. private _meshSpaceDirection;
  43376. private _meshSpaceOrigin;
  43377. /**
  43378. * Helper function to create a colored helper in a scene in one line.
  43379. * @param ray Defines the ray we are currently tryin to visualize
  43380. * @param scene Defines the scene the ray is used in
  43381. * @param color Defines the color we want to see the ray in
  43382. * @returns The newly created ray helper.
  43383. */
  43384. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43385. /**
  43386. * Instantiate a new ray helper.
  43387. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43388. * in order to better appreciate the issue one might have.
  43389. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43390. * @param ray Defines the ray we are currently tryin to visualize
  43391. */
  43392. constructor(ray: Ray);
  43393. /**
  43394. * Shows the ray we are willing to debug.
  43395. * @param scene Defines the scene the ray needs to be rendered in
  43396. * @param color Defines the color the ray needs to be rendered in
  43397. */
  43398. show(scene: Scene, color?: Color3): void;
  43399. /**
  43400. * Hides the ray we are debugging.
  43401. */
  43402. hide(): void;
  43403. private _render;
  43404. /**
  43405. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43406. * @param mesh Defines the mesh we want the helper attached to
  43407. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43408. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43409. * @param length Defines the length of the ray
  43410. */
  43411. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43412. /**
  43413. * Detach the ray helper from the mesh it has previously been attached to.
  43414. */
  43415. detachFromMesh(): void;
  43416. private _updateToMesh;
  43417. /**
  43418. * Dispose the helper and release its associated resources.
  43419. */
  43420. dispose(): void;
  43421. }
  43422. }
  43423. declare module "babylonjs/Debug/skeletonViewer" {
  43424. import { Color3 } from "babylonjs/Maths/math";
  43425. import { Scene } from "babylonjs/scene";
  43426. import { Nullable } from "babylonjs/types";
  43427. import { Skeleton } from "babylonjs/Bones/skeleton";
  43428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43429. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43430. /**
  43431. * Class used to render a debug view of a given skeleton
  43432. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43433. */
  43434. export class SkeletonViewer {
  43435. /** defines the skeleton to render */
  43436. skeleton: Skeleton;
  43437. /** defines the mesh attached to the skeleton */
  43438. mesh: AbstractMesh;
  43439. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43440. autoUpdateBonesMatrices: boolean;
  43441. /** defines the rendering group id to use with the viewer */
  43442. renderingGroupId: number;
  43443. /** Gets or sets the color used to render the skeleton */
  43444. color: Color3;
  43445. private _scene;
  43446. private _debugLines;
  43447. private _debugMesh;
  43448. private _isEnabled;
  43449. private _renderFunction;
  43450. private _utilityLayer;
  43451. /**
  43452. * Returns the mesh used to render the bones
  43453. */
  43454. readonly debugMesh: Nullable<LinesMesh>;
  43455. /**
  43456. * Creates a new SkeletonViewer
  43457. * @param skeleton defines the skeleton to render
  43458. * @param mesh defines the mesh attached to the skeleton
  43459. * @param scene defines the hosting scene
  43460. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43461. * @param renderingGroupId defines the rendering group id to use with the viewer
  43462. */
  43463. constructor(
  43464. /** defines the skeleton to render */
  43465. skeleton: Skeleton,
  43466. /** defines the mesh attached to the skeleton */
  43467. mesh: AbstractMesh, scene: Scene,
  43468. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43469. autoUpdateBonesMatrices?: boolean,
  43470. /** defines the rendering group id to use with the viewer */
  43471. renderingGroupId?: number);
  43472. /** Gets or sets a boolean indicating if the viewer is enabled */
  43473. isEnabled: boolean;
  43474. private _getBonePosition;
  43475. private _getLinesForBonesWithLength;
  43476. private _getLinesForBonesNoLength;
  43477. /** Update the viewer to sync with current skeleton state */
  43478. update(): void;
  43479. /** Release associated resources */
  43480. dispose(): void;
  43481. }
  43482. }
  43483. declare module "babylonjs/Debug/index" {
  43484. export * from "babylonjs/Debug/axesViewer";
  43485. export * from "babylonjs/Debug/boneAxesViewer";
  43486. export * from "babylonjs/Debug/debugLayer";
  43487. export * from "babylonjs/Debug/physicsViewer";
  43488. export * from "babylonjs/Debug/rayHelper";
  43489. export * from "babylonjs/Debug/skeletonViewer";
  43490. }
  43491. declare module "babylonjs/Engines/nullEngine" {
  43492. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43493. import { Scene } from "babylonjs/scene";
  43494. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43495. import { Engine } from "babylonjs/Engines/engine";
  43496. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43497. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43498. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43499. import { Effect } from "babylonjs/Materials/effect";
  43500. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43501. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43502. /**
  43503. * Options to create the null engine
  43504. */
  43505. export class NullEngineOptions {
  43506. /**
  43507. * Render width (Default: 512)
  43508. */
  43509. renderWidth: number;
  43510. /**
  43511. * Render height (Default: 256)
  43512. */
  43513. renderHeight: number;
  43514. /**
  43515. * Texture size (Default: 512)
  43516. */
  43517. textureSize: number;
  43518. /**
  43519. * If delta time between frames should be constant
  43520. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43521. */
  43522. deterministicLockstep: boolean;
  43523. /**
  43524. * Maximum about of steps between frames (Default: 4)
  43525. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43526. */
  43527. lockstepMaxSteps: number;
  43528. }
  43529. /**
  43530. * The null engine class provides support for headless version of babylon.js.
  43531. * This can be used in server side scenario or for testing purposes
  43532. */
  43533. export class NullEngine extends Engine {
  43534. private _options;
  43535. /**
  43536. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43537. */
  43538. isDeterministicLockStep(): boolean;
  43539. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43540. getLockstepMaxSteps(): number;
  43541. /**
  43542. * Sets hardware scaling, used to save performance if needed
  43543. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43544. */
  43545. getHardwareScalingLevel(): number;
  43546. constructor(options?: NullEngineOptions);
  43547. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43548. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43549. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43550. getRenderWidth(useScreen?: boolean): number;
  43551. getRenderHeight(useScreen?: boolean): number;
  43552. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43553. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43554. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43555. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43556. bindSamplers(effect: Effect): void;
  43557. enableEffect(effect: Effect): void;
  43558. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43559. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43560. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43561. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43562. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43563. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43564. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43565. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43566. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43567. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43568. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43569. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43570. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43571. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43572. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43573. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43574. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43575. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43576. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43577. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43578. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43579. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43580. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43581. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43582. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43583. bindBuffers(vertexBuffers: {
  43584. [key: string]: VertexBuffer;
  43585. }, indexBuffer: DataBuffer, effect: Effect): void;
  43586. wipeCaches(bruteForce?: boolean): void;
  43587. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43588. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43589. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43590. /** @hidden */
  43591. _createTexture(): WebGLTexture;
  43592. /** @hidden */
  43593. _releaseTexture(texture: InternalTexture): void;
  43594. 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;
  43595. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43596. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43597. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43598. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43599. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43600. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43601. areAllEffectsReady(): boolean;
  43602. /**
  43603. * @hidden
  43604. * Get the current error code of the webGL context
  43605. * @returns the error code
  43606. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43607. */
  43608. getError(): number;
  43609. /** @hidden */
  43610. _getUnpackAlignement(): number;
  43611. /** @hidden */
  43612. _unpackFlipY(value: boolean): void;
  43613. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43614. /**
  43615. * Updates a dynamic vertex buffer.
  43616. * @param vertexBuffer the vertex buffer to update
  43617. * @param data the data used to update the vertex buffer
  43618. * @param byteOffset the byte offset of the data (optional)
  43619. * @param byteLength the byte length of the data (optional)
  43620. */
  43621. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43622. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43623. /** @hidden */
  43624. _bindTexture(channel: number, texture: InternalTexture): void;
  43625. /** @hidden */
  43626. _releaseBuffer(buffer: DataBuffer): boolean;
  43627. releaseEffects(): void;
  43628. displayLoadingUI(): void;
  43629. hideLoadingUI(): void;
  43630. /** @hidden */
  43631. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43632. /** @hidden */
  43633. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43634. /** @hidden */
  43635. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43636. /** @hidden */
  43637. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43638. }
  43639. }
  43640. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43641. import { Nullable, int } from "babylonjs/types";
  43642. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43643. /** @hidden */
  43644. export class _OcclusionDataStorage {
  43645. /** @hidden */
  43646. occlusionInternalRetryCounter: number;
  43647. /** @hidden */
  43648. isOcclusionQueryInProgress: boolean;
  43649. /** @hidden */
  43650. isOccluded: boolean;
  43651. /** @hidden */
  43652. occlusionRetryCount: number;
  43653. /** @hidden */
  43654. occlusionType: number;
  43655. /** @hidden */
  43656. occlusionQueryAlgorithmType: number;
  43657. }
  43658. module "babylonjs/Engines/engine" {
  43659. interface Engine {
  43660. /**
  43661. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43662. * @return the new query
  43663. */
  43664. createQuery(): WebGLQuery;
  43665. /**
  43666. * Delete and release a webGL query
  43667. * @param query defines the query to delete
  43668. * @return the current engine
  43669. */
  43670. deleteQuery(query: WebGLQuery): Engine;
  43671. /**
  43672. * Check if a given query has resolved and got its value
  43673. * @param query defines the query to check
  43674. * @returns true if the query got its value
  43675. */
  43676. isQueryResultAvailable(query: WebGLQuery): boolean;
  43677. /**
  43678. * Gets the value of a given query
  43679. * @param query defines the query to check
  43680. * @returns the value of the query
  43681. */
  43682. getQueryResult(query: WebGLQuery): number;
  43683. /**
  43684. * Initiates an occlusion query
  43685. * @param algorithmType defines the algorithm to use
  43686. * @param query defines the query to use
  43687. * @returns the current engine
  43688. * @see http://doc.babylonjs.com/features/occlusionquery
  43689. */
  43690. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43691. /**
  43692. * Ends an occlusion query
  43693. * @see http://doc.babylonjs.com/features/occlusionquery
  43694. * @param algorithmType defines the algorithm to use
  43695. * @returns the current engine
  43696. */
  43697. endOcclusionQuery(algorithmType: number): Engine;
  43698. /**
  43699. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43700. * Please note that only one query can be issued at a time
  43701. * @returns a time token used to track the time span
  43702. */
  43703. startTimeQuery(): Nullable<_TimeToken>;
  43704. /**
  43705. * Ends a time query
  43706. * @param token defines the token used to measure the time span
  43707. * @returns the time spent (in ns)
  43708. */
  43709. endTimeQuery(token: _TimeToken): int;
  43710. /** @hidden */
  43711. _currentNonTimestampToken: Nullable<_TimeToken>;
  43712. /** @hidden */
  43713. _createTimeQuery(): WebGLQuery;
  43714. /** @hidden */
  43715. _deleteTimeQuery(query: WebGLQuery): void;
  43716. /** @hidden */
  43717. _getGlAlgorithmType(algorithmType: number): number;
  43718. /** @hidden */
  43719. _getTimeQueryResult(query: WebGLQuery): any;
  43720. /** @hidden */
  43721. _getTimeQueryAvailability(query: WebGLQuery): any;
  43722. }
  43723. }
  43724. module "babylonjs/Meshes/abstractMesh" {
  43725. interface AbstractMesh {
  43726. /**
  43727. * Backing filed
  43728. * @hidden
  43729. */
  43730. __occlusionDataStorage: _OcclusionDataStorage;
  43731. /**
  43732. * Access property
  43733. * @hidden
  43734. */
  43735. _occlusionDataStorage: _OcclusionDataStorage;
  43736. /**
  43737. * 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.
  43738. * The default value is -1 which means don't break the query and wait till the result
  43739. * @see http://doc.babylonjs.com/features/occlusionquery
  43740. */
  43741. occlusionRetryCount: number;
  43742. /**
  43743. * 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:
  43744. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43745. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43746. * * 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.
  43747. * @see http://doc.babylonjs.com/features/occlusionquery
  43748. */
  43749. occlusionType: number;
  43750. /**
  43751. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43752. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43753. * * 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.
  43754. * @see http://doc.babylonjs.com/features/occlusionquery
  43755. */
  43756. occlusionQueryAlgorithmType: number;
  43757. /**
  43758. * 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
  43759. * @see http://doc.babylonjs.com/features/occlusionquery
  43760. */
  43761. isOccluded: boolean;
  43762. /**
  43763. * Flag to check the progress status of the query
  43764. * @see http://doc.babylonjs.com/features/occlusionquery
  43765. */
  43766. isOcclusionQueryInProgress: boolean;
  43767. }
  43768. }
  43769. }
  43770. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43771. import { Nullable } from "babylonjs/types";
  43772. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43773. /** @hidden */
  43774. export var _forceTransformFeedbackToBundle: boolean;
  43775. module "babylonjs/Engines/engine" {
  43776. interface Engine {
  43777. /**
  43778. * Creates a webGL transform feedback object
  43779. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43780. * @returns the webGL transform feedback object
  43781. */
  43782. createTransformFeedback(): WebGLTransformFeedback;
  43783. /**
  43784. * Delete a webGL transform feedback object
  43785. * @param value defines the webGL transform feedback object to delete
  43786. */
  43787. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43788. /**
  43789. * Bind a webGL transform feedback object to the webgl context
  43790. * @param value defines the webGL transform feedback object to bind
  43791. */
  43792. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43793. /**
  43794. * Begins a transform feedback operation
  43795. * @param usePoints defines if points or triangles must be used
  43796. */
  43797. beginTransformFeedback(usePoints: boolean): void;
  43798. /**
  43799. * Ends a transform feedback operation
  43800. */
  43801. endTransformFeedback(): void;
  43802. /**
  43803. * Specify the varyings to use with transform feedback
  43804. * @param program defines the associated webGL program
  43805. * @param value defines the list of strings representing the varying names
  43806. */
  43807. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43808. /**
  43809. * Bind a webGL buffer for a transform feedback operation
  43810. * @param value defines the webGL buffer to bind
  43811. */
  43812. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43813. }
  43814. }
  43815. }
  43816. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43817. import { Scene } from "babylonjs/scene";
  43818. import { Engine } from "babylonjs/Engines/engine";
  43819. import { Texture } from "babylonjs/Materials/Textures/texture";
  43820. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43821. import "babylonjs/Engines/Extensions/engine.multiRender";
  43822. /**
  43823. * Creation options of the multi render target texture.
  43824. */
  43825. export interface IMultiRenderTargetOptions {
  43826. /**
  43827. * Define if the texture needs to create mip maps after render.
  43828. */
  43829. generateMipMaps?: boolean;
  43830. /**
  43831. * Define the types of all the draw buffers we want to create
  43832. */
  43833. types?: number[];
  43834. /**
  43835. * Define the sampling modes of all the draw buffers we want to create
  43836. */
  43837. samplingModes?: number[];
  43838. /**
  43839. * Define if a depth buffer is required
  43840. */
  43841. generateDepthBuffer?: boolean;
  43842. /**
  43843. * Define if a stencil buffer is required
  43844. */
  43845. generateStencilBuffer?: boolean;
  43846. /**
  43847. * Define if a depth texture is required instead of a depth buffer
  43848. */
  43849. generateDepthTexture?: boolean;
  43850. /**
  43851. * Define the number of desired draw buffers
  43852. */
  43853. textureCount?: number;
  43854. /**
  43855. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43856. */
  43857. doNotChangeAspectRatio?: boolean;
  43858. /**
  43859. * Define the default type of the buffers we are creating
  43860. */
  43861. defaultType?: number;
  43862. }
  43863. /**
  43864. * A multi render target, like a render target provides the ability to render to a texture.
  43865. * Unlike the render target, it can render to several draw buffers in one draw.
  43866. * This is specially interesting in deferred rendering or for any effects requiring more than
  43867. * just one color from a single pass.
  43868. */
  43869. export class MultiRenderTarget extends RenderTargetTexture {
  43870. private _internalTextures;
  43871. private _textures;
  43872. private _multiRenderTargetOptions;
  43873. /**
  43874. * Get if draw buffers are currently supported by the used hardware and browser.
  43875. */
  43876. readonly isSupported: boolean;
  43877. /**
  43878. * Get the list of textures generated by the multi render target.
  43879. */
  43880. readonly textures: Texture[];
  43881. /**
  43882. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43883. */
  43884. readonly depthTexture: Texture;
  43885. /**
  43886. * Set the wrapping mode on U of all the textures we are rendering to.
  43887. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43888. */
  43889. wrapU: number;
  43890. /**
  43891. * Set the wrapping mode on V of all the textures we are rendering to.
  43892. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43893. */
  43894. wrapV: number;
  43895. /**
  43896. * Instantiate a new multi render target texture.
  43897. * A multi render target, like a render target provides the ability to render to a texture.
  43898. * Unlike the render target, it can render to several draw buffers in one draw.
  43899. * This is specially interesting in deferred rendering or for any effects requiring more than
  43900. * just one color from a single pass.
  43901. * @param name Define the name of the texture
  43902. * @param size Define the size of the buffers to render to
  43903. * @param count Define the number of target we are rendering into
  43904. * @param scene Define the scene the texture belongs to
  43905. * @param options Define the options used to create the multi render target
  43906. */
  43907. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43908. /** @hidden */
  43909. _rebuild(): void;
  43910. private _createInternalTextures;
  43911. private _createTextures;
  43912. /**
  43913. * Define the number of samples used if MSAA is enabled.
  43914. */
  43915. samples: number;
  43916. /**
  43917. * Resize all the textures in the multi render target.
  43918. * Be carrefull as it will recreate all the data in the new texture.
  43919. * @param size Define the new size
  43920. */
  43921. resize(size: any): void;
  43922. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43923. /**
  43924. * Dispose the render targets and their associated resources
  43925. */
  43926. dispose(): void;
  43927. /**
  43928. * Release all the underlying texture used as draw buffers.
  43929. */
  43930. releaseInternalTextures(): void;
  43931. }
  43932. }
  43933. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43934. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43935. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43936. import { Nullable } from "babylonjs/types";
  43937. module "babylonjs/Engines/engine" {
  43938. interface Engine {
  43939. /**
  43940. * Unbind a list of render target textures from the webGL context
  43941. * This is used only when drawBuffer extension or webGL2 are active
  43942. * @param textures defines the render target textures to unbind
  43943. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43944. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43945. */
  43946. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43947. /**
  43948. * Create a multi render target texture
  43949. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43950. * @param size defines the size of the texture
  43951. * @param options defines the creation options
  43952. * @returns the cube texture as an InternalTexture
  43953. */
  43954. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43955. /**
  43956. * Update the sample count for a given multiple render target texture
  43957. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43958. * @param textures defines the textures to update
  43959. * @param samples defines the sample count to set
  43960. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43961. */
  43962. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43963. }
  43964. }
  43965. }
  43966. declare module "babylonjs/Engines/Extensions/index" {
  43967. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43968. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43969. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43970. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43971. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43972. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43973. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43974. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43975. }
  43976. declare module "babylonjs/Engines/index" {
  43977. export * from "babylonjs/Engines/constants";
  43978. export * from "babylonjs/Engines/engine";
  43979. export * from "babylonjs/Engines/engineStore";
  43980. export * from "babylonjs/Engines/nullEngine";
  43981. export * from "babylonjs/Engines/Extensions/index";
  43982. export * from "babylonjs/Engines/IPipelineContext";
  43983. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43984. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  43985. }
  43986. declare module "babylonjs/Events/clipboardEvents" {
  43987. /**
  43988. * Gather the list of clipboard event types as constants.
  43989. */
  43990. export class ClipboardEventTypes {
  43991. /**
  43992. * The clipboard event is fired when a copy command is active (pressed).
  43993. */
  43994. static readonly COPY: number;
  43995. /**
  43996. * The clipboard event is fired when a cut command is active (pressed).
  43997. */
  43998. static readonly CUT: number;
  43999. /**
  44000. * The clipboard event is fired when a paste command is active (pressed).
  44001. */
  44002. static readonly PASTE: number;
  44003. }
  44004. /**
  44005. * This class is used to store clipboard related info for the onClipboardObservable event.
  44006. */
  44007. export class ClipboardInfo {
  44008. /**
  44009. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44010. */
  44011. type: number;
  44012. /**
  44013. * Defines the related dom event
  44014. */
  44015. event: ClipboardEvent;
  44016. /**
  44017. *Creates an instance of ClipboardInfo.
  44018. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44019. * @param event Defines the related dom event
  44020. */
  44021. constructor(
  44022. /**
  44023. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44024. */
  44025. type: number,
  44026. /**
  44027. * Defines the related dom event
  44028. */
  44029. event: ClipboardEvent);
  44030. /**
  44031. * Get the clipboard event's type from the keycode.
  44032. * @param keyCode Defines the keyCode for the current keyboard event.
  44033. * @return {number}
  44034. */
  44035. static GetTypeFromCharacter(keyCode: number): number;
  44036. }
  44037. }
  44038. declare module "babylonjs/Events/index" {
  44039. export * from "babylonjs/Events/keyboardEvents";
  44040. export * from "babylonjs/Events/pointerEvents";
  44041. export * from "babylonjs/Events/clipboardEvents";
  44042. }
  44043. declare module "babylonjs/Loading/sceneLoader" {
  44044. import { Observable } from "babylonjs/Misc/observable";
  44045. import { Nullable } from "babylonjs/types";
  44046. import { Scene } from "babylonjs/scene";
  44047. import { Engine } from "babylonjs/Engines/engine";
  44048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44049. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44050. import { AssetContainer } from "babylonjs/assetContainer";
  44051. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44052. import { Skeleton } from "babylonjs/Bones/skeleton";
  44053. /**
  44054. * Class used to represent data loading progression
  44055. */
  44056. export class SceneLoaderProgressEvent {
  44057. /** defines if data length to load can be evaluated */
  44058. readonly lengthComputable: boolean;
  44059. /** defines the loaded data length */
  44060. readonly loaded: number;
  44061. /** defines the data length to load */
  44062. readonly total: number;
  44063. /**
  44064. * Create a new progress event
  44065. * @param lengthComputable defines if data length to load can be evaluated
  44066. * @param loaded defines the loaded data length
  44067. * @param total defines the data length to load
  44068. */
  44069. constructor(
  44070. /** defines if data length to load can be evaluated */
  44071. lengthComputable: boolean,
  44072. /** defines the loaded data length */
  44073. loaded: number,
  44074. /** defines the data length to load */
  44075. total: number);
  44076. /**
  44077. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44078. * @param event defines the source event
  44079. * @returns a new SceneLoaderProgressEvent
  44080. */
  44081. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44082. }
  44083. /**
  44084. * Interface used by SceneLoader plugins to define supported file extensions
  44085. */
  44086. export interface ISceneLoaderPluginExtensions {
  44087. /**
  44088. * Defines the list of supported extensions
  44089. */
  44090. [extension: string]: {
  44091. isBinary: boolean;
  44092. };
  44093. }
  44094. /**
  44095. * Interface used by SceneLoader plugin factory
  44096. */
  44097. export interface ISceneLoaderPluginFactory {
  44098. /**
  44099. * Defines the name of the factory
  44100. */
  44101. name: string;
  44102. /**
  44103. * Function called to create a new plugin
  44104. * @return the new plugin
  44105. */
  44106. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44107. /**
  44108. * Boolean indicating if the plugin can direct load specific data
  44109. */
  44110. canDirectLoad?: (data: string) => boolean;
  44111. }
  44112. /**
  44113. * Interface used to define a SceneLoader plugin
  44114. */
  44115. export interface ISceneLoaderPlugin {
  44116. /**
  44117. * The friendly name of this plugin.
  44118. */
  44119. name: string;
  44120. /**
  44121. * The file extensions supported by this plugin.
  44122. */
  44123. extensions: string | ISceneLoaderPluginExtensions;
  44124. /**
  44125. * Import meshes into a scene.
  44126. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44127. * @param scene The scene to import into
  44128. * @param data The data to import
  44129. * @param rootUrl The root url for scene and resources
  44130. * @param meshes The meshes array to import into
  44131. * @param particleSystems The particle systems array to import into
  44132. * @param skeletons The skeletons array to import into
  44133. * @param onError The callback when import fails
  44134. * @returns True if successful or false otherwise
  44135. */
  44136. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44137. /**
  44138. * Load into a scene.
  44139. * @param scene The scene to load into
  44140. * @param data The data to import
  44141. * @param rootUrl The root url for scene and resources
  44142. * @param onError The callback when import fails
  44143. * @returns true if successful or false otherwise
  44144. */
  44145. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44146. /**
  44147. * The callback that returns true if the data can be directly loaded.
  44148. */
  44149. canDirectLoad?: (data: string) => boolean;
  44150. /**
  44151. * The callback that allows custom handling of the root url based on the response url.
  44152. */
  44153. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44154. /**
  44155. * Load into an asset container.
  44156. * @param scene The scene to load into
  44157. * @param data The data to import
  44158. * @param rootUrl The root url for scene and resources
  44159. * @param onError The callback when import fails
  44160. * @returns The loaded asset container
  44161. */
  44162. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44163. }
  44164. /**
  44165. * Interface used to define an async SceneLoader plugin
  44166. */
  44167. export interface ISceneLoaderPluginAsync {
  44168. /**
  44169. * The friendly name of this plugin.
  44170. */
  44171. name: string;
  44172. /**
  44173. * The file extensions supported by this plugin.
  44174. */
  44175. extensions: string | ISceneLoaderPluginExtensions;
  44176. /**
  44177. * Import meshes into a scene.
  44178. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44179. * @param scene The scene to import into
  44180. * @param data The data to import
  44181. * @param rootUrl The root url for scene and resources
  44182. * @param onProgress The callback when the load progresses
  44183. * @param fileName Defines the name of the file to load
  44184. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44185. */
  44186. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44187. meshes: AbstractMesh[];
  44188. particleSystems: IParticleSystem[];
  44189. skeletons: Skeleton[];
  44190. animationGroups: AnimationGroup[];
  44191. }>;
  44192. /**
  44193. * Load into a scene.
  44194. * @param scene The scene to load into
  44195. * @param data The data to import
  44196. * @param rootUrl The root url for scene and resources
  44197. * @param onProgress The callback when the load progresses
  44198. * @param fileName Defines the name of the file to load
  44199. * @returns Nothing
  44200. */
  44201. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44202. /**
  44203. * The callback that returns true if the data can be directly loaded.
  44204. */
  44205. canDirectLoad?: (data: string) => boolean;
  44206. /**
  44207. * The callback that allows custom handling of the root url based on the response url.
  44208. */
  44209. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44210. /**
  44211. * Load into an asset container.
  44212. * @param scene The scene to load into
  44213. * @param data The data to import
  44214. * @param rootUrl The root url for scene and resources
  44215. * @param onProgress The callback when the load progresses
  44216. * @param fileName Defines the name of the file to load
  44217. * @returns The loaded asset container
  44218. */
  44219. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44220. }
  44221. /**
  44222. * Class used to load scene from various file formats using registered plugins
  44223. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44224. */
  44225. export class SceneLoader {
  44226. /**
  44227. * No logging while loading
  44228. */
  44229. static readonly NO_LOGGING: number;
  44230. /**
  44231. * Minimal logging while loading
  44232. */
  44233. static readonly MINIMAL_LOGGING: number;
  44234. /**
  44235. * Summary logging while loading
  44236. */
  44237. static readonly SUMMARY_LOGGING: number;
  44238. /**
  44239. * Detailled logging while loading
  44240. */
  44241. static readonly DETAILED_LOGGING: number;
  44242. /**
  44243. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44244. */
  44245. static ForceFullSceneLoadingForIncremental: boolean;
  44246. /**
  44247. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44248. */
  44249. static ShowLoadingScreen: boolean;
  44250. /**
  44251. * Defines the current logging level (while loading the scene)
  44252. * @ignorenaming
  44253. */
  44254. static loggingLevel: number;
  44255. /**
  44256. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44257. */
  44258. static CleanBoneMatrixWeights: boolean;
  44259. /**
  44260. * Event raised when a plugin is used to load a scene
  44261. */
  44262. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44263. private static _registeredPlugins;
  44264. private static _getDefaultPlugin;
  44265. private static _getPluginForExtension;
  44266. private static _getPluginForDirectLoad;
  44267. private static _getPluginForFilename;
  44268. private static _getDirectLoad;
  44269. private static _loadData;
  44270. private static _getFileInfo;
  44271. /**
  44272. * Gets a plugin that can load the given extension
  44273. * @param extension defines the extension to load
  44274. * @returns a plugin or null if none works
  44275. */
  44276. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44277. /**
  44278. * Gets a boolean indicating that the given extension can be loaded
  44279. * @param extension defines the extension to load
  44280. * @returns true if the extension is supported
  44281. */
  44282. static IsPluginForExtensionAvailable(extension: string): boolean;
  44283. /**
  44284. * Adds a new plugin to the list of registered plugins
  44285. * @param plugin defines the plugin to add
  44286. */
  44287. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44288. /**
  44289. * Import meshes into a scene
  44290. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44291. * @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)
  44292. * @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)
  44293. * @param scene the instance of BABYLON.Scene to append to
  44294. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44295. * @param onProgress a callback with a progress event for each file being loaded
  44296. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44297. * @param pluginExtension the extension used to determine the plugin
  44298. * @returns The loaded plugin
  44299. */
  44300. 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>;
  44301. /**
  44302. * Import meshes into a scene
  44303. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44304. * @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)
  44305. * @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)
  44306. * @param scene the instance of BABYLON.Scene to append to
  44307. * @param onProgress a callback with a progress event for each file being loaded
  44308. * @param pluginExtension the extension used to determine the plugin
  44309. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44310. */
  44311. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44312. meshes: AbstractMesh[];
  44313. particleSystems: IParticleSystem[];
  44314. skeletons: Skeleton[];
  44315. animationGroups: AnimationGroup[];
  44316. }>;
  44317. /**
  44318. * Load a scene
  44319. * @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)
  44320. * @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)
  44321. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44322. * @param onSuccess a callback with the scene when import succeeds
  44323. * @param onProgress a callback with a progress event for each file being loaded
  44324. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44325. * @param pluginExtension the extension used to determine the plugin
  44326. * @returns The loaded plugin
  44327. */
  44328. 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>;
  44329. /**
  44330. * Load a scene
  44331. * @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)
  44332. * @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)
  44333. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44334. * @param onProgress a callback with a progress event for each file being loaded
  44335. * @param pluginExtension the extension used to determine the plugin
  44336. * @returns The loaded scene
  44337. */
  44338. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44339. /**
  44340. * Append a scene
  44341. * @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)
  44342. * @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)
  44343. * @param scene is the instance of BABYLON.Scene to append to
  44344. * @param onSuccess a callback with the scene when import succeeds
  44345. * @param onProgress a callback with a progress event for each file being loaded
  44346. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44347. * @param pluginExtension the extension used to determine the plugin
  44348. * @returns The loaded plugin
  44349. */
  44350. 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>;
  44351. /**
  44352. * Append a scene
  44353. * @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)
  44354. * @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)
  44355. * @param scene is the instance of BABYLON.Scene to append to
  44356. * @param onProgress a callback with a progress event for each file being loaded
  44357. * @param pluginExtension the extension used to determine the plugin
  44358. * @returns The given scene
  44359. */
  44360. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44361. /**
  44362. * Load a scene into an asset container
  44363. * @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)
  44364. * @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)
  44365. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44366. * @param onSuccess a callback with the scene when import succeeds
  44367. * @param onProgress a callback with a progress event for each file being loaded
  44368. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44369. * @param pluginExtension the extension used to determine the plugin
  44370. * @returns The loaded plugin
  44371. */
  44372. 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>;
  44373. /**
  44374. * Load a scene into an asset container
  44375. * @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)
  44376. * @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)
  44377. * @param scene is the instance of Scene to append to
  44378. * @param onProgress a callback with a progress event for each file being loaded
  44379. * @param pluginExtension the extension used to determine the plugin
  44380. * @returns The loaded asset container
  44381. */
  44382. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44383. }
  44384. }
  44385. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44386. import { Scene } from "babylonjs/scene";
  44387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44388. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44389. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44390. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44391. /**
  44392. * Google Daydream controller
  44393. */
  44394. export class DaydreamController extends WebVRController {
  44395. /**
  44396. * Base Url for the controller model.
  44397. */
  44398. static MODEL_BASE_URL: string;
  44399. /**
  44400. * File name for the controller model.
  44401. */
  44402. static MODEL_FILENAME: string;
  44403. /**
  44404. * Gamepad Id prefix used to identify Daydream Controller.
  44405. */
  44406. static readonly GAMEPAD_ID_PREFIX: string;
  44407. /**
  44408. * Creates a new DaydreamController from a gamepad
  44409. * @param vrGamepad the gamepad that the controller should be created from
  44410. */
  44411. constructor(vrGamepad: any);
  44412. /**
  44413. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44414. * @param scene scene in which to add meshes
  44415. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44416. */
  44417. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44418. /**
  44419. * Called once for each button that changed state since the last frame
  44420. * @param buttonIdx Which button index changed
  44421. * @param state New state of the button
  44422. * @param changes Which properties on the state changed since last frame
  44423. */
  44424. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44425. }
  44426. }
  44427. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44428. import { Scene } from "babylonjs/scene";
  44429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44430. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44431. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44432. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44433. /**
  44434. * Gear VR Controller
  44435. */
  44436. export class GearVRController extends WebVRController {
  44437. /**
  44438. * Base Url for the controller model.
  44439. */
  44440. static MODEL_BASE_URL: string;
  44441. /**
  44442. * File name for the controller model.
  44443. */
  44444. static MODEL_FILENAME: string;
  44445. /**
  44446. * Gamepad Id prefix used to identify this controller.
  44447. */
  44448. static readonly GAMEPAD_ID_PREFIX: string;
  44449. private readonly _buttonIndexToObservableNameMap;
  44450. /**
  44451. * Creates a new GearVRController from a gamepad
  44452. * @param vrGamepad the gamepad that the controller should be created from
  44453. */
  44454. constructor(vrGamepad: any);
  44455. /**
  44456. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44457. * @param scene scene in which to add meshes
  44458. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44459. */
  44460. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44461. /**
  44462. * Called once for each button that changed state since the last frame
  44463. * @param buttonIdx Which button index changed
  44464. * @param state New state of the button
  44465. * @param changes Which properties on the state changed since last frame
  44466. */
  44467. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44468. }
  44469. }
  44470. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44471. import { Scene } from "babylonjs/scene";
  44472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44473. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44474. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44475. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44476. /**
  44477. * Generic Controller
  44478. */
  44479. export class GenericController extends WebVRController {
  44480. /**
  44481. * Base Url for the controller model.
  44482. */
  44483. static readonly MODEL_BASE_URL: string;
  44484. /**
  44485. * File name for the controller model.
  44486. */
  44487. static readonly MODEL_FILENAME: string;
  44488. /**
  44489. * Creates a new GenericController from a gamepad
  44490. * @param vrGamepad the gamepad that the controller should be created from
  44491. */
  44492. constructor(vrGamepad: any);
  44493. /**
  44494. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44495. * @param scene scene in which to add meshes
  44496. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44497. */
  44498. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44499. /**
  44500. * Called once for each button that changed state since the last frame
  44501. * @param buttonIdx Which button index changed
  44502. * @param state New state of the button
  44503. * @param changes Which properties on the state changed since last frame
  44504. */
  44505. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44506. }
  44507. }
  44508. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44509. import { Observable } from "babylonjs/Misc/observable";
  44510. import { Scene } from "babylonjs/scene";
  44511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44512. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44513. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44514. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44515. /**
  44516. * Oculus Touch Controller
  44517. */
  44518. export class OculusTouchController extends WebVRController {
  44519. /**
  44520. * Base Url for the controller model.
  44521. */
  44522. static MODEL_BASE_URL: string;
  44523. /**
  44524. * File name for the left controller model.
  44525. */
  44526. static MODEL_LEFT_FILENAME: string;
  44527. /**
  44528. * File name for the right controller model.
  44529. */
  44530. static MODEL_RIGHT_FILENAME: string;
  44531. /**
  44532. * Base Url for the Quest controller model.
  44533. */
  44534. static QUEST_MODEL_BASE_URL: string;
  44535. /**
  44536. * @hidden
  44537. * If the controllers are running on a device that needs the updated Quest controller models
  44538. */
  44539. static _IsQuest: boolean;
  44540. /**
  44541. * Fired when the secondary trigger on this controller is modified
  44542. */
  44543. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44544. /**
  44545. * Fired when the thumb rest on this controller is modified
  44546. */
  44547. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44548. /**
  44549. * Creates a new OculusTouchController from a gamepad
  44550. * @param vrGamepad the gamepad that the controller should be created from
  44551. */
  44552. constructor(vrGamepad: any);
  44553. /**
  44554. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44555. * @param scene scene in which to add meshes
  44556. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44557. */
  44558. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44559. /**
  44560. * Fired when the A button on this controller is modified
  44561. */
  44562. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44563. /**
  44564. * Fired when the B button on this controller is modified
  44565. */
  44566. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44567. /**
  44568. * Fired when the X button on this controller is modified
  44569. */
  44570. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44571. /**
  44572. * Fired when the Y button on this controller is modified
  44573. */
  44574. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44575. /**
  44576. * Called once for each button that changed state since the last frame
  44577. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44578. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44579. * 2) secondary trigger (same)
  44580. * 3) A (right) X (left), touch, pressed = value
  44581. * 4) B / Y
  44582. * 5) thumb rest
  44583. * @param buttonIdx Which button index changed
  44584. * @param state New state of the button
  44585. * @param changes Which properties on the state changed since last frame
  44586. */
  44587. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44588. }
  44589. }
  44590. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44591. import { Scene } from "babylonjs/scene";
  44592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44593. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44594. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44595. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44596. import { Observable } from "babylonjs/Misc/observable";
  44597. /**
  44598. * Vive Controller
  44599. */
  44600. export class ViveController extends WebVRController {
  44601. /**
  44602. * Base Url for the controller model.
  44603. */
  44604. static MODEL_BASE_URL: string;
  44605. /**
  44606. * File name for the controller model.
  44607. */
  44608. static MODEL_FILENAME: string;
  44609. /**
  44610. * Creates a new ViveController from a gamepad
  44611. * @param vrGamepad the gamepad that the controller should be created from
  44612. */
  44613. constructor(vrGamepad: any);
  44614. /**
  44615. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44616. * @param scene scene in which to add meshes
  44617. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44618. */
  44619. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44620. /**
  44621. * Fired when the left button on this controller is modified
  44622. */
  44623. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44624. /**
  44625. * Fired when the right button on this controller is modified
  44626. */
  44627. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44628. /**
  44629. * Fired when the menu button on this controller is modified
  44630. */
  44631. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44632. /**
  44633. * Called once for each button that changed state since the last frame
  44634. * Vive mapping:
  44635. * 0: touchpad
  44636. * 1: trigger
  44637. * 2: left AND right buttons
  44638. * 3: menu button
  44639. * @param buttonIdx Which button index changed
  44640. * @param state New state of the button
  44641. * @param changes Which properties on the state changed since last frame
  44642. */
  44643. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44644. }
  44645. }
  44646. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44647. import { Observable } from "babylonjs/Misc/observable";
  44648. import { Scene } from "babylonjs/scene";
  44649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44650. import { Ray } from "babylonjs/Culling/ray";
  44651. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44652. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44653. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44654. /**
  44655. * Defines the WindowsMotionController object that the state of the windows motion controller
  44656. */
  44657. export class WindowsMotionController extends WebVRController {
  44658. /**
  44659. * The base url used to load the left and right controller models
  44660. */
  44661. static MODEL_BASE_URL: string;
  44662. /**
  44663. * The name of the left controller model file
  44664. */
  44665. static MODEL_LEFT_FILENAME: string;
  44666. /**
  44667. * The name of the right controller model file
  44668. */
  44669. static MODEL_RIGHT_FILENAME: string;
  44670. /**
  44671. * The controller name prefix for this controller type
  44672. */
  44673. static readonly GAMEPAD_ID_PREFIX: string;
  44674. /**
  44675. * The controller id pattern for this controller type
  44676. */
  44677. private static readonly GAMEPAD_ID_PATTERN;
  44678. private _loadedMeshInfo;
  44679. private readonly _mapping;
  44680. /**
  44681. * Fired when the trackpad on this controller is clicked
  44682. */
  44683. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44684. /**
  44685. * Fired when the trackpad on this controller is modified
  44686. */
  44687. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44688. /**
  44689. * The current x and y values of this controller's trackpad
  44690. */
  44691. trackpad: StickValues;
  44692. /**
  44693. * Creates a new WindowsMotionController from a gamepad
  44694. * @param vrGamepad the gamepad that the controller should be created from
  44695. */
  44696. constructor(vrGamepad: any);
  44697. /**
  44698. * Fired when the trigger on this controller is modified
  44699. */
  44700. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44701. /**
  44702. * Fired when the menu button on this controller is modified
  44703. */
  44704. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44705. /**
  44706. * Fired when the grip button on this controller is modified
  44707. */
  44708. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44709. /**
  44710. * Fired when the thumbstick button on this controller is modified
  44711. */
  44712. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44713. /**
  44714. * Fired when the touchpad button on this controller is modified
  44715. */
  44716. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44717. /**
  44718. * Fired when the touchpad values on this controller are modified
  44719. */
  44720. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44721. private _updateTrackpad;
  44722. /**
  44723. * Called once per frame by the engine.
  44724. */
  44725. update(): void;
  44726. /**
  44727. * Called once for each button that changed state since the last frame
  44728. * @param buttonIdx Which button index changed
  44729. * @param state New state of the button
  44730. * @param changes Which properties on the state changed since last frame
  44731. */
  44732. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44733. /**
  44734. * Moves the buttons on the controller mesh based on their current state
  44735. * @param buttonName the name of the button to move
  44736. * @param buttonValue the value of the button which determines the buttons new position
  44737. */
  44738. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44739. /**
  44740. * Moves the axis on the controller mesh based on its current state
  44741. * @param axis the index of the axis
  44742. * @param axisValue the value of the axis which determines the meshes new position
  44743. * @hidden
  44744. */
  44745. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44746. /**
  44747. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44748. * @param scene scene in which to add meshes
  44749. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44750. */
  44751. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44752. /**
  44753. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44754. * can be transformed by button presses and axes values, based on this._mapping.
  44755. *
  44756. * @param scene scene in which the meshes exist
  44757. * @param meshes list of meshes that make up the controller model to process
  44758. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44759. */
  44760. private processModel;
  44761. private createMeshInfo;
  44762. /**
  44763. * Gets the ray of the controller in the direction the controller is pointing
  44764. * @param length the length the resulting ray should be
  44765. * @returns a ray in the direction the controller is pointing
  44766. */
  44767. getForwardRay(length?: number): Ray;
  44768. /**
  44769. * Disposes of the controller
  44770. */
  44771. dispose(): void;
  44772. }
  44773. }
  44774. declare module "babylonjs/Gamepads/Controllers/index" {
  44775. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44776. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44777. export * from "babylonjs/Gamepads/Controllers/genericController";
  44778. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44779. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44780. export * from "babylonjs/Gamepads/Controllers/viveController";
  44781. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44782. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44783. }
  44784. declare module "babylonjs/Gamepads/index" {
  44785. export * from "babylonjs/Gamepads/Controllers/index";
  44786. export * from "babylonjs/Gamepads/gamepad";
  44787. export * from "babylonjs/Gamepads/gamepadManager";
  44788. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44789. export * from "babylonjs/Gamepads/xboxGamepad";
  44790. }
  44791. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44792. import { Scene } from "babylonjs/scene";
  44793. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44794. import { Mesh } from "babylonjs/Meshes/mesh";
  44795. import { Nullable } from "babylonjs/types";
  44796. /**
  44797. * Class containing static functions to help procedurally build meshes
  44798. */
  44799. export class PolyhedronBuilder {
  44800. /**
  44801. * Creates a polyhedron mesh
  44802. * * 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
  44803. * * The parameter `size` (positive float, default 1) sets the polygon size
  44804. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44805. * * 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`
  44806. * * 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
  44807. * * 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)`)
  44808. * * 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
  44809. * * 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
  44810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44813. * @param name defines the name of the mesh
  44814. * @param options defines the options used to create the mesh
  44815. * @param scene defines the hosting scene
  44816. * @returns the polyhedron mesh
  44817. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44818. */
  44819. static CreatePolyhedron(name: string, options: {
  44820. type?: number;
  44821. size?: number;
  44822. sizeX?: number;
  44823. sizeY?: number;
  44824. sizeZ?: number;
  44825. custom?: any;
  44826. faceUV?: Vector4[];
  44827. faceColors?: Color4[];
  44828. flat?: boolean;
  44829. updatable?: boolean;
  44830. sideOrientation?: number;
  44831. frontUVs?: Vector4;
  44832. backUVs?: Vector4;
  44833. }, scene?: Nullable<Scene>): Mesh;
  44834. }
  44835. }
  44836. declare module "babylonjs/Gizmos/scaleGizmo" {
  44837. import { Observable } from "babylonjs/Misc/observable";
  44838. import { Nullable } from "babylonjs/types";
  44839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44840. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44841. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44842. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44843. /**
  44844. * Gizmo that enables scaling a mesh along 3 axis
  44845. */
  44846. export class ScaleGizmo extends Gizmo {
  44847. /**
  44848. * Internal gizmo used for interactions on the x axis
  44849. */
  44850. xGizmo: AxisScaleGizmo;
  44851. /**
  44852. * Internal gizmo used for interactions on the y axis
  44853. */
  44854. yGizmo: AxisScaleGizmo;
  44855. /**
  44856. * Internal gizmo used for interactions on the z axis
  44857. */
  44858. zGizmo: AxisScaleGizmo;
  44859. /**
  44860. * Internal gizmo used to scale all axis equally
  44861. */
  44862. uniformScaleGizmo: AxisScaleGizmo;
  44863. private _meshAttached;
  44864. private _updateGizmoRotationToMatchAttachedMesh;
  44865. private _snapDistance;
  44866. private _scaleRatio;
  44867. private _uniformScalingMesh;
  44868. private _octahedron;
  44869. /** Fires an event when any of it's sub gizmos are dragged */
  44870. onDragStartObservable: Observable<{}>;
  44871. /** Fires an event when any of it's sub gizmos are released from dragging */
  44872. onDragEndObservable: Observable<{}>;
  44873. attachedMesh: Nullable<AbstractMesh>;
  44874. /**
  44875. * Creates a ScaleGizmo
  44876. * @param gizmoLayer The utility layer the gizmo will be added to
  44877. */
  44878. constructor(gizmoLayer?: UtilityLayerRenderer);
  44879. updateGizmoRotationToMatchAttachedMesh: boolean;
  44880. /**
  44881. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44882. */
  44883. snapDistance: number;
  44884. /**
  44885. * Ratio for the scale of the gizmo (Default: 1)
  44886. */
  44887. scaleRatio: number;
  44888. /**
  44889. * Disposes of the gizmo
  44890. */
  44891. dispose(): void;
  44892. }
  44893. }
  44894. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44895. import { Observable } from "babylonjs/Misc/observable";
  44896. import { Nullable } from "babylonjs/types";
  44897. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44899. import { Mesh } from "babylonjs/Meshes/mesh";
  44900. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44901. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44902. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44903. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44904. /**
  44905. * Single axis scale gizmo
  44906. */
  44907. export class AxisScaleGizmo extends Gizmo {
  44908. /**
  44909. * Drag behavior responsible for the gizmos dragging interactions
  44910. */
  44911. dragBehavior: PointerDragBehavior;
  44912. private _pointerObserver;
  44913. /**
  44914. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44915. */
  44916. snapDistance: number;
  44917. /**
  44918. * Event that fires each time the gizmo snaps to a new location.
  44919. * * snapDistance is the the change in distance
  44920. */
  44921. onSnapObservable: Observable<{
  44922. snapDistance: number;
  44923. }>;
  44924. /**
  44925. * If the scaling operation should be done on all axis (default: false)
  44926. */
  44927. uniformScaling: boolean;
  44928. private _isEnabled;
  44929. private _parent;
  44930. private _arrow;
  44931. private _coloredMaterial;
  44932. private _hoverMaterial;
  44933. /**
  44934. * Creates an AxisScaleGizmo
  44935. * @param gizmoLayer The utility layer the gizmo will be added to
  44936. * @param dragAxis The axis which the gizmo will be able to scale on
  44937. * @param color The color of the gizmo
  44938. */
  44939. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44940. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44941. /**
  44942. * If the gizmo is enabled
  44943. */
  44944. isEnabled: boolean;
  44945. /**
  44946. * Disposes of the gizmo
  44947. */
  44948. dispose(): void;
  44949. /**
  44950. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44951. * @param mesh The mesh to replace the default mesh of the gizmo
  44952. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44953. */
  44954. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44955. }
  44956. }
  44957. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44958. import { Observable } from "babylonjs/Misc/observable";
  44959. import { Nullable } from "babylonjs/types";
  44960. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44962. import { Mesh } from "babylonjs/Meshes/mesh";
  44963. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44964. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44965. import "babylonjs/Meshes/Builders/boxBuilder";
  44966. /**
  44967. * Bounding box gizmo
  44968. */
  44969. export class BoundingBoxGizmo extends Gizmo {
  44970. private _lineBoundingBox;
  44971. private _rotateSpheresParent;
  44972. private _scaleBoxesParent;
  44973. private _boundingDimensions;
  44974. private _renderObserver;
  44975. private _pointerObserver;
  44976. private _scaleDragSpeed;
  44977. private _tmpQuaternion;
  44978. private _tmpVector;
  44979. private _tmpRotationMatrix;
  44980. /**
  44981. * 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)
  44982. */
  44983. ignoreChildren: boolean;
  44984. /**
  44985. * 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)
  44986. */
  44987. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44988. /**
  44989. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44990. */
  44991. rotationSphereSize: number;
  44992. /**
  44993. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44994. */
  44995. scaleBoxSize: number;
  44996. /**
  44997. * 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)
  44998. */
  44999. fixedDragMeshScreenSize: boolean;
  45000. /**
  45001. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45002. */
  45003. fixedDragMeshScreenSizeDistanceFactor: number;
  45004. /**
  45005. * Fired when a rotation sphere or scale box is dragged
  45006. */
  45007. onDragStartObservable: Observable<{}>;
  45008. /**
  45009. * Fired when a scale box is dragged
  45010. */
  45011. onScaleBoxDragObservable: Observable<{}>;
  45012. /**
  45013. * Fired when a scale box drag is ended
  45014. */
  45015. onScaleBoxDragEndObservable: Observable<{}>;
  45016. /**
  45017. * Fired when a rotation sphere is dragged
  45018. */
  45019. onRotationSphereDragObservable: Observable<{}>;
  45020. /**
  45021. * Fired when a rotation sphere drag is ended
  45022. */
  45023. onRotationSphereDragEndObservable: Observable<{}>;
  45024. /**
  45025. * 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)
  45026. */
  45027. scalePivot: Nullable<Vector3>;
  45028. /**
  45029. * Mesh used as a pivot to rotate the attached mesh
  45030. */
  45031. private _anchorMesh;
  45032. private _existingMeshScale;
  45033. private _dragMesh;
  45034. private pointerDragBehavior;
  45035. private coloredMaterial;
  45036. private hoverColoredMaterial;
  45037. /**
  45038. * Sets the color of the bounding box gizmo
  45039. * @param color the color to set
  45040. */
  45041. setColor(color: Color3): void;
  45042. /**
  45043. * Creates an BoundingBoxGizmo
  45044. * @param gizmoLayer The utility layer the gizmo will be added to
  45045. * @param color The color of the gizmo
  45046. */
  45047. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45048. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45049. private _selectNode;
  45050. /**
  45051. * Updates the bounding box information for the Gizmo
  45052. */
  45053. updateBoundingBox(): void;
  45054. private _updateRotationSpheres;
  45055. private _updateScaleBoxes;
  45056. /**
  45057. * Enables rotation on the specified axis and disables rotation on the others
  45058. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45059. */
  45060. setEnabledRotationAxis(axis: string): void;
  45061. /**
  45062. * Enables/disables scaling
  45063. * @param enable if scaling should be enabled
  45064. */
  45065. setEnabledScaling(enable: boolean): void;
  45066. private _updateDummy;
  45067. /**
  45068. * Enables a pointer drag behavior on the bounding box of the gizmo
  45069. */
  45070. enableDragBehavior(): void;
  45071. /**
  45072. * Disposes of the gizmo
  45073. */
  45074. dispose(): void;
  45075. /**
  45076. * 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)
  45077. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45078. * @returns the bounding box mesh with the passed in mesh as a child
  45079. */
  45080. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45081. /**
  45082. * CustomMeshes are not supported by this gizmo
  45083. * @param mesh The mesh to replace the default mesh of the gizmo
  45084. */
  45085. setCustomMesh(mesh: Mesh): void;
  45086. }
  45087. }
  45088. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45089. import { Observable } from "babylonjs/Misc/observable";
  45090. import { Nullable } from "babylonjs/types";
  45091. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45093. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45094. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45095. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45096. import "babylonjs/Meshes/Builders/linesBuilder";
  45097. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45098. /**
  45099. * Single plane rotation gizmo
  45100. */
  45101. export class PlaneRotationGizmo extends Gizmo {
  45102. /**
  45103. * Drag behavior responsible for the gizmos dragging interactions
  45104. */
  45105. dragBehavior: PointerDragBehavior;
  45106. private _pointerObserver;
  45107. /**
  45108. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45109. */
  45110. snapDistance: number;
  45111. /**
  45112. * Event that fires each time the gizmo snaps to a new location.
  45113. * * snapDistance is the the change in distance
  45114. */
  45115. onSnapObservable: Observable<{
  45116. snapDistance: number;
  45117. }>;
  45118. private _isEnabled;
  45119. private _parent;
  45120. /**
  45121. * Creates a PlaneRotationGizmo
  45122. * @param gizmoLayer The utility layer the gizmo will be added to
  45123. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45124. * @param color The color of the gizmo
  45125. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45126. */
  45127. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45128. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45129. /**
  45130. * If the gizmo is enabled
  45131. */
  45132. isEnabled: boolean;
  45133. /**
  45134. * Disposes of the gizmo
  45135. */
  45136. dispose(): void;
  45137. }
  45138. }
  45139. declare module "babylonjs/Gizmos/rotationGizmo" {
  45140. import { Observable } from "babylonjs/Misc/observable";
  45141. import { Nullable } from "babylonjs/types";
  45142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45143. import { Mesh } from "babylonjs/Meshes/mesh";
  45144. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45145. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45146. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45147. /**
  45148. * Gizmo that enables rotating a mesh along 3 axis
  45149. */
  45150. export class RotationGizmo extends Gizmo {
  45151. /**
  45152. * Internal gizmo used for interactions on the x axis
  45153. */
  45154. xGizmo: PlaneRotationGizmo;
  45155. /**
  45156. * Internal gizmo used for interactions on the y axis
  45157. */
  45158. yGizmo: PlaneRotationGizmo;
  45159. /**
  45160. * Internal gizmo used for interactions on the z axis
  45161. */
  45162. zGizmo: PlaneRotationGizmo;
  45163. /** Fires an event when any of it's sub gizmos are dragged */
  45164. onDragStartObservable: Observable<{}>;
  45165. /** Fires an event when any of it's sub gizmos are released from dragging */
  45166. onDragEndObservable: Observable<{}>;
  45167. private _meshAttached;
  45168. attachedMesh: Nullable<AbstractMesh>;
  45169. /**
  45170. * Creates a RotationGizmo
  45171. * @param gizmoLayer The utility layer the gizmo will be added to
  45172. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45173. */
  45174. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45175. updateGizmoRotationToMatchAttachedMesh: boolean;
  45176. /**
  45177. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45178. */
  45179. snapDistance: number;
  45180. /**
  45181. * Ratio for the scale of the gizmo (Default: 1)
  45182. */
  45183. scaleRatio: number;
  45184. /**
  45185. * Disposes of the gizmo
  45186. */
  45187. dispose(): void;
  45188. /**
  45189. * CustomMeshes are not supported by this gizmo
  45190. * @param mesh The mesh to replace the default mesh of the gizmo
  45191. */
  45192. setCustomMesh(mesh: Mesh): void;
  45193. }
  45194. }
  45195. declare module "babylonjs/Gizmos/gizmoManager" {
  45196. import { Observable } from "babylonjs/Misc/observable";
  45197. import { Nullable } from "babylonjs/types";
  45198. import { Scene, IDisposable } from "babylonjs/scene";
  45199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45200. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45201. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45202. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45203. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45204. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45205. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45206. /**
  45207. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45208. */
  45209. export class GizmoManager implements IDisposable {
  45210. private scene;
  45211. /**
  45212. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45213. */
  45214. gizmos: {
  45215. positionGizmo: Nullable<PositionGizmo>;
  45216. rotationGizmo: Nullable<RotationGizmo>;
  45217. scaleGizmo: Nullable<ScaleGizmo>;
  45218. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45219. };
  45220. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45221. clearGizmoOnEmptyPointerEvent: boolean;
  45222. /** Fires an event when the manager is attached to a mesh */
  45223. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45224. private _gizmosEnabled;
  45225. private _pointerObserver;
  45226. private _attachedMesh;
  45227. private _boundingBoxColor;
  45228. private _defaultUtilityLayer;
  45229. private _defaultKeepDepthUtilityLayer;
  45230. /**
  45231. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45232. */
  45233. boundingBoxDragBehavior: SixDofDragBehavior;
  45234. /**
  45235. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45236. */
  45237. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45238. /**
  45239. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45240. */
  45241. usePointerToAttachGizmos: boolean;
  45242. /**
  45243. * Utility layer that the bounding box gizmo belongs to
  45244. */
  45245. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45246. /**
  45247. * Utility layer that all gizmos besides bounding box belong to
  45248. */
  45249. readonly utilityLayer: UtilityLayerRenderer;
  45250. /**
  45251. * Instatiates a gizmo manager
  45252. * @param scene the scene to overlay the gizmos on top of
  45253. */
  45254. constructor(scene: Scene);
  45255. /**
  45256. * Attaches a set of gizmos to the specified mesh
  45257. * @param mesh The mesh the gizmo's should be attached to
  45258. */
  45259. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45260. /**
  45261. * If the position gizmo is enabled
  45262. */
  45263. positionGizmoEnabled: boolean;
  45264. /**
  45265. * If the rotation gizmo is enabled
  45266. */
  45267. rotationGizmoEnabled: boolean;
  45268. /**
  45269. * If the scale gizmo is enabled
  45270. */
  45271. scaleGizmoEnabled: boolean;
  45272. /**
  45273. * If the boundingBox gizmo is enabled
  45274. */
  45275. boundingBoxGizmoEnabled: boolean;
  45276. /**
  45277. * Disposes of the gizmo manager
  45278. */
  45279. dispose(): void;
  45280. }
  45281. }
  45282. declare module "babylonjs/Lights/directionalLight" {
  45283. import { Camera } from "babylonjs/Cameras/camera";
  45284. import { Scene } from "babylonjs/scene";
  45285. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45287. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45288. import { Effect } from "babylonjs/Materials/effect";
  45289. /**
  45290. * A directional light is defined by a direction (what a surprise!).
  45291. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45292. * 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.
  45293. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45294. */
  45295. export class DirectionalLight extends ShadowLight {
  45296. private _shadowFrustumSize;
  45297. /**
  45298. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45299. */
  45300. /**
  45301. * Specifies a fix frustum size for the shadow generation.
  45302. */
  45303. shadowFrustumSize: number;
  45304. private _shadowOrthoScale;
  45305. /**
  45306. * Gets the shadow projection scale against the optimal computed one.
  45307. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45308. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45309. */
  45310. /**
  45311. * Sets the shadow projection scale against the optimal computed one.
  45312. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45313. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45314. */
  45315. shadowOrthoScale: number;
  45316. /**
  45317. * Automatically compute the projection matrix to best fit (including all the casters)
  45318. * on each frame.
  45319. */
  45320. autoUpdateExtends: boolean;
  45321. private _orthoLeft;
  45322. private _orthoRight;
  45323. private _orthoTop;
  45324. private _orthoBottom;
  45325. /**
  45326. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45327. * The directional light is emitted from everywhere in the given direction.
  45328. * It can cast shadows.
  45329. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45330. * @param name The friendly name of the light
  45331. * @param direction The direction of the light
  45332. * @param scene The scene the light belongs to
  45333. */
  45334. constructor(name: string, direction: Vector3, scene: Scene);
  45335. /**
  45336. * Returns the string "DirectionalLight".
  45337. * @return The class name
  45338. */
  45339. getClassName(): string;
  45340. /**
  45341. * Returns the integer 1.
  45342. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45343. */
  45344. getTypeID(): number;
  45345. /**
  45346. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45347. * Returns the DirectionalLight Shadow projection matrix.
  45348. */
  45349. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45350. /**
  45351. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45352. * Returns the DirectionalLight Shadow projection matrix.
  45353. */
  45354. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45355. /**
  45356. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45357. * Returns the DirectionalLight Shadow projection matrix.
  45358. */
  45359. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45360. protected _buildUniformLayout(): void;
  45361. /**
  45362. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45363. * @param effect The effect to update
  45364. * @param lightIndex The index of the light in the effect to update
  45365. * @returns The directional light
  45366. */
  45367. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45368. /**
  45369. * Gets the minZ used for shadow according to both the scene and the light.
  45370. *
  45371. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45372. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45373. * @param activeCamera The camera we are returning the min for
  45374. * @returns the depth min z
  45375. */
  45376. getDepthMinZ(activeCamera: Camera): number;
  45377. /**
  45378. * Gets the maxZ used for shadow according to both the scene and the light.
  45379. *
  45380. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45381. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45382. * @param activeCamera The camera we are returning the max for
  45383. * @returns the depth max z
  45384. */
  45385. getDepthMaxZ(activeCamera: Camera): number;
  45386. /**
  45387. * Prepares the list of defines specific to the light type.
  45388. * @param defines the list of defines
  45389. * @param lightIndex defines the index of the light for the effect
  45390. */
  45391. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45392. }
  45393. }
  45394. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45395. import { Mesh } from "babylonjs/Meshes/mesh";
  45396. /**
  45397. * Class containing static functions to help procedurally build meshes
  45398. */
  45399. export class HemisphereBuilder {
  45400. /**
  45401. * Creates a hemisphere mesh
  45402. * @param name defines the name of the mesh
  45403. * @param options defines the options used to create the mesh
  45404. * @param scene defines the hosting scene
  45405. * @returns the hemisphere mesh
  45406. */
  45407. static CreateHemisphere(name: string, options: {
  45408. segments?: number;
  45409. diameter?: number;
  45410. sideOrientation?: number;
  45411. }, scene: any): Mesh;
  45412. }
  45413. }
  45414. declare module "babylonjs/Lights/spotLight" {
  45415. import { Nullable } from "babylonjs/types";
  45416. import { Scene } from "babylonjs/scene";
  45417. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45419. import { Effect } from "babylonjs/Materials/effect";
  45420. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45421. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45422. /**
  45423. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45424. * These values define a cone of light starting from the position, emitting toward the direction.
  45425. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45426. * and the exponent defines the speed of the decay of the light with distance (reach).
  45427. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45428. */
  45429. export class SpotLight extends ShadowLight {
  45430. private _angle;
  45431. private _innerAngle;
  45432. private _cosHalfAngle;
  45433. private _lightAngleScale;
  45434. private _lightAngleOffset;
  45435. /**
  45436. * Gets the cone angle of the spot light in Radians.
  45437. */
  45438. /**
  45439. * Sets the cone angle of the spot light in Radians.
  45440. */
  45441. angle: number;
  45442. /**
  45443. * Only used in gltf falloff mode, this defines the angle where
  45444. * the directional falloff will start before cutting at angle which could be seen
  45445. * as outer angle.
  45446. */
  45447. /**
  45448. * Only used in gltf falloff mode, this defines the angle where
  45449. * the directional falloff will start before cutting at angle which could be seen
  45450. * as outer angle.
  45451. */
  45452. innerAngle: number;
  45453. private _shadowAngleScale;
  45454. /**
  45455. * Allows scaling the angle of the light for shadow generation only.
  45456. */
  45457. /**
  45458. * Allows scaling the angle of the light for shadow generation only.
  45459. */
  45460. shadowAngleScale: number;
  45461. /**
  45462. * The light decay speed with the distance from the emission spot.
  45463. */
  45464. exponent: number;
  45465. private _projectionTextureMatrix;
  45466. /**
  45467. * Allows reading the projecton texture
  45468. */
  45469. readonly projectionTextureMatrix: Matrix;
  45470. protected _projectionTextureLightNear: number;
  45471. /**
  45472. * Gets the near clip of the Spotlight for texture projection.
  45473. */
  45474. /**
  45475. * Sets the near clip of the Spotlight for texture projection.
  45476. */
  45477. projectionTextureLightNear: number;
  45478. protected _projectionTextureLightFar: number;
  45479. /**
  45480. * Gets the far clip of the Spotlight for texture projection.
  45481. */
  45482. /**
  45483. * Sets the far clip of the Spotlight for texture projection.
  45484. */
  45485. projectionTextureLightFar: number;
  45486. protected _projectionTextureUpDirection: Vector3;
  45487. /**
  45488. * Gets the Up vector of the Spotlight for texture projection.
  45489. */
  45490. /**
  45491. * Sets the Up vector of the Spotlight for texture projection.
  45492. */
  45493. projectionTextureUpDirection: Vector3;
  45494. private _projectionTexture;
  45495. /**
  45496. * Gets the projection texture of the light.
  45497. */
  45498. /**
  45499. * Sets the projection texture of the light.
  45500. */
  45501. projectionTexture: Nullable<BaseTexture>;
  45502. private _projectionTextureViewLightDirty;
  45503. private _projectionTextureProjectionLightDirty;
  45504. private _projectionTextureDirty;
  45505. private _projectionTextureViewTargetVector;
  45506. private _projectionTextureViewLightMatrix;
  45507. private _projectionTextureProjectionLightMatrix;
  45508. private _projectionTextureScalingMatrix;
  45509. /**
  45510. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45511. * It can cast shadows.
  45512. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45513. * @param name The light friendly name
  45514. * @param position The position of the spot light in the scene
  45515. * @param direction The direction of the light in the scene
  45516. * @param angle The cone angle of the light in Radians
  45517. * @param exponent The light decay speed with the distance from the emission spot
  45518. * @param scene The scene the lights belongs to
  45519. */
  45520. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45521. /**
  45522. * Returns the string "SpotLight".
  45523. * @returns the class name
  45524. */
  45525. getClassName(): string;
  45526. /**
  45527. * Returns the integer 2.
  45528. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45529. */
  45530. getTypeID(): number;
  45531. /**
  45532. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45533. */
  45534. protected _setDirection(value: Vector3): void;
  45535. /**
  45536. * Overrides the position setter to recompute the projection texture view light Matrix.
  45537. */
  45538. protected _setPosition(value: Vector3): void;
  45539. /**
  45540. * 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.
  45541. * Returns the SpotLight.
  45542. */
  45543. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45544. protected _computeProjectionTextureViewLightMatrix(): void;
  45545. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45546. /**
  45547. * Main function for light texture projection matrix computing.
  45548. */
  45549. protected _computeProjectionTextureMatrix(): void;
  45550. protected _buildUniformLayout(): void;
  45551. private _computeAngleValues;
  45552. /**
  45553. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45554. * @param effect The effect to update
  45555. * @param lightIndex The index of the light in the effect to update
  45556. * @returns The spot light
  45557. */
  45558. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45559. /**
  45560. * Disposes the light and the associated resources.
  45561. */
  45562. dispose(): void;
  45563. /**
  45564. * Prepares the list of defines specific to the light type.
  45565. * @param defines the list of defines
  45566. * @param lightIndex defines the index of the light for the effect
  45567. */
  45568. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45569. }
  45570. }
  45571. declare module "babylonjs/Gizmos/lightGizmo" {
  45572. import { Nullable } from "babylonjs/types";
  45573. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45574. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45575. import { Light } from "babylonjs/Lights/light";
  45576. /**
  45577. * Gizmo that enables viewing a light
  45578. */
  45579. export class LightGizmo extends Gizmo {
  45580. private _lightMesh;
  45581. private _material;
  45582. private cachedPosition;
  45583. private cachedForward;
  45584. /**
  45585. * Creates a LightGizmo
  45586. * @param gizmoLayer The utility layer the gizmo will be added to
  45587. */
  45588. constructor(gizmoLayer?: UtilityLayerRenderer);
  45589. private _light;
  45590. /**
  45591. * The light that the gizmo is attached to
  45592. */
  45593. light: Nullable<Light>;
  45594. /**
  45595. * @hidden
  45596. * Updates the gizmo to match the attached mesh's position/rotation
  45597. */
  45598. protected _update(): void;
  45599. private static _Scale;
  45600. /**
  45601. * Creates the lines for a light mesh
  45602. */
  45603. private static _createLightLines;
  45604. /**
  45605. * Disposes of the light gizmo
  45606. */
  45607. dispose(): void;
  45608. private static _CreateHemisphericLightMesh;
  45609. private static _CreatePointLightMesh;
  45610. private static _CreateSpotLightMesh;
  45611. private static _CreateDirectionalLightMesh;
  45612. }
  45613. }
  45614. declare module "babylonjs/Gizmos/index" {
  45615. export * from "babylonjs/Gizmos/axisDragGizmo";
  45616. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45617. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45618. export * from "babylonjs/Gizmos/gizmo";
  45619. export * from "babylonjs/Gizmos/gizmoManager";
  45620. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45621. export * from "babylonjs/Gizmos/positionGizmo";
  45622. export * from "babylonjs/Gizmos/rotationGizmo";
  45623. export * from "babylonjs/Gizmos/scaleGizmo";
  45624. export * from "babylonjs/Gizmos/lightGizmo";
  45625. }
  45626. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45627. /** @hidden */
  45628. export var backgroundFragmentDeclaration: {
  45629. name: string;
  45630. shader: string;
  45631. };
  45632. }
  45633. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45634. /** @hidden */
  45635. export var backgroundUboDeclaration: {
  45636. name: string;
  45637. shader: string;
  45638. };
  45639. }
  45640. declare module "babylonjs/Shaders/background.fragment" {
  45641. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45642. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45643. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45644. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45645. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45646. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45647. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45648. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45649. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45650. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45651. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45652. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45653. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45654. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45655. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45656. /** @hidden */
  45657. export var backgroundPixelShader: {
  45658. name: string;
  45659. shader: string;
  45660. };
  45661. }
  45662. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45663. /** @hidden */
  45664. export var backgroundVertexDeclaration: {
  45665. name: string;
  45666. shader: string;
  45667. };
  45668. }
  45669. declare module "babylonjs/Shaders/background.vertex" {
  45670. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45671. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45672. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45673. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45674. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45675. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45676. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45677. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45678. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45679. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45680. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45681. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45682. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45683. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45684. /** @hidden */
  45685. export var backgroundVertexShader: {
  45686. name: string;
  45687. shader: string;
  45688. };
  45689. }
  45690. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45691. import { Nullable, int, float } from "babylonjs/types";
  45692. import { Scene } from "babylonjs/scene";
  45693. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45696. import { Mesh } from "babylonjs/Meshes/mesh";
  45697. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45698. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45699. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45700. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45701. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45702. import "babylonjs/Shaders/background.fragment";
  45703. import "babylonjs/Shaders/background.vertex";
  45704. /**
  45705. * Background material used to create an efficient environement around your scene.
  45706. */
  45707. export class BackgroundMaterial extends PushMaterial {
  45708. /**
  45709. * Standard reflectance value at parallel view angle.
  45710. */
  45711. static StandardReflectance0: number;
  45712. /**
  45713. * Standard reflectance value at grazing angle.
  45714. */
  45715. static StandardReflectance90: number;
  45716. protected _primaryColor: Color3;
  45717. /**
  45718. * Key light Color (multiply against the environement texture)
  45719. */
  45720. primaryColor: Color3;
  45721. protected __perceptualColor: Nullable<Color3>;
  45722. /**
  45723. * Experimental Internal Use Only.
  45724. *
  45725. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45726. * This acts as a helper to set the primary color to a more "human friendly" value.
  45727. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45728. * output color as close as possible from the chosen value.
  45729. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45730. * part of lighting setup.)
  45731. */
  45732. _perceptualColor: Nullable<Color3>;
  45733. protected _primaryColorShadowLevel: float;
  45734. /**
  45735. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45736. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45737. */
  45738. primaryColorShadowLevel: float;
  45739. protected _primaryColorHighlightLevel: float;
  45740. /**
  45741. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45742. * The primary color is used at the level chosen to define what the white area would look.
  45743. */
  45744. primaryColorHighlightLevel: float;
  45745. protected _reflectionTexture: Nullable<BaseTexture>;
  45746. /**
  45747. * Reflection Texture used in the material.
  45748. * Should be author in a specific way for the best result (refer to the documentation).
  45749. */
  45750. reflectionTexture: Nullable<BaseTexture>;
  45751. protected _reflectionBlur: float;
  45752. /**
  45753. * Reflection Texture level of blur.
  45754. *
  45755. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45756. * texture twice.
  45757. */
  45758. reflectionBlur: float;
  45759. protected _diffuseTexture: Nullable<BaseTexture>;
  45760. /**
  45761. * Diffuse Texture used in the material.
  45762. * Should be author in a specific way for the best result (refer to the documentation).
  45763. */
  45764. diffuseTexture: Nullable<BaseTexture>;
  45765. protected _shadowLights: Nullable<IShadowLight[]>;
  45766. /**
  45767. * Specify the list of lights casting shadow on the material.
  45768. * All scene shadow lights will be included if null.
  45769. */
  45770. shadowLights: Nullable<IShadowLight[]>;
  45771. protected _shadowLevel: float;
  45772. /**
  45773. * Helps adjusting the shadow to a softer level if required.
  45774. * 0 means black shadows and 1 means no shadows.
  45775. */
  45776. shadowLevel: float;
  45777. protected _sceneCenter: Vector3;
  45778. /**
  45779. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45780. * It is usually zero but might be interesting to modify according to your setup.
  45781. */
  45782. sceneCenter: Vector3;
  45783. protected _opacityFresnel: boolean;
  45784. /**
  45785. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45786. * This helps ensuring a nice transition when the camera goes under the ground.
  45787. */
  45788. opacityFresnel: boolean;
  45789. protected _reflectionFresnel: boolean;
  45790. /**
  45791. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45792. * This helps adding a mirror texture on the ground.
  45793. */
  45794. reflectionFresnel: boolean;
  45795. protected _reflectionFalloffDistance: number;
  45796. /**
  45797. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45798. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45799. */
  45800. reflectionFalloffDistance: number;
  45801. protected _reflectionAmount: number;
  45802. /**
  45803. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45804. */
  45805. reflectionAmount: number;
  45806. protected _reflectionReflectance0: number;
  45807. /**
  45808. * This specifies the weight of the reflection at grazing angle.
  45809. */
  45810. reflectionReflectance0: number;
  45811. protected _reflectionReflectance90: number;
  45812. /**
  45813. * This specifies the weight of the reflection at a perpendicular point of view.
  45814. */
  45815. reflectionReflectance90: number;
  45816. /**
  45817. * Sets the reflection reflectance fresnel values according to the default standard
  45818. * empirically know to work well :-)
  45819. */
  45820. reflectionStandardFresnelWeight: number;
  45821. protected _useRGBColor: boolean;
  45822. /**
  45823. * Helps to directly use the maps channels instead of their level.
  45824. */
  45825. useRGBColor: boolean;
  45826. protected _enableNoise: boolean;
  45827. /**
  45828. * This helps reducing the banding effect that could occur on the background.
  45829. */
  45830. enableNoise: boolean;
  45831. /**
  45832. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45833. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45834. * Recommended to be keep at 1.0 except for special cases.
  45835. */
  45836. fovMultiplier: number;
  45837. private _fovMultiplier;
  45838. /**
  45839. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45840. */
  45841. useEquirectangularFOV: boolean;
  45842. private _maxSimultaneousLights;
  45843. /**
  45844. * Number of Simultaneous lights allowed on the material.
  45845. */
  45846. maxSimultaneousLights: int;
  45847. /**
  45848. * Default configuration related to image processing available in the Background Material.
  45849. */
  45850. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45851. /**
  45852. * Keep track of the image processing observer to allow dispose and replace.
  45853. */
  45854. private _imageProcessingObserver;
  45855. /**
  45856. * Attaches a new image processing configuration to the PBR Material.
  45857. * @param configuration (if null the scene configuration will be use)
  45858. */
  45859. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45860. /**
  45861. * Gets the image processing configuration used either in this material.
  45862. */
  45863. /**
  45864. * Sets the Default image processing configuration used either in the this material.
  45865. *
  45866. * If sets to null, the scene one is in use.
  45867. */
  45868. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45869. /**
  45870. * Gets wether the color curves effect is enabled.
  45871. */
  45872. /**
  45873. * Sets wether the color curves effect is enabled.
  45874. */
  45875. cameraColorCurvesEnabled: boolean;
  45876. /**
  45877. * Gets wether the color grading effect is enabled.
  45878. */
  45879. /**
  45880. * Gets wether the color grading effect is enabled.
  45881. */
  45882. cameraColorGradingEnabled: boolean;
  45883. /**
  45884. * Gets wether tonemapping is enabled or not.
  45885. */
  45886. /**
  45887. * Sets wether tonemapping is enabled or not
  45888. */
  45889. cameraToneMappingEnabled: boolean;
  45890. /**
  45891. * The camera exposure used on this material.
  45892. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45893. * This corresponds to a photographic exposure.
  45894. */
  45895. /**
  45896. * The camera exposure used on this material.
  45897. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45898. * This corresponds to a photographic exposure.
  45899. */
  45900. cameraExposure: float;
  45901. /**
  45902. * Gets The camera contrast used on this material.
  45903. */
  45904. /**
  45905. * Sets The camera contrast used on this material.
  45906. */
  45907. cameraContrast: float;
  45908. /**
  45909. * Gets the Color Grading 2D Lookup Texture.
  45910. */
  45911. /**
  45912. * Sets the Color Grading 2D Lookup Texture.
  45913. */
  45914. cameraColorGradingTexture: Nullable<BaseTexture>;
  45915. /**
  45916. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45917. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45918. * 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;
  45919. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45920. */
  45921. /**
  45922. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45923. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45924. * 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;
  45925. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45926. */
  45927. cameraColorCurves: Nullable<ColorCurves>;
  45928. /**
  45929. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45930. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45931. */
  45932. switchToBGR: boolean;
  45933. private _renderTargets;
  45934. private _reflectionControls;
  45935. private _white;
  45936. private _primaryShadowColor;
  45937. private _primaryHighlightColor;
  45938. /**
  45939. * Instantiates a Background Material in the given scene
  45940. * @param name The friendly name of the material
  45941. * @param scene The scene to add the material to
  45942. */
  45943. constructor(name: string, scene: Scene);
  45944. /**
  45945. * Gets a boolean indicating that current material needs to register RTT
  45946. */
  45947. readonly hasRenderTargetTextures: boolean;
  45948. /**
  45949. * The entire material has been created in order to prevent overdraw.
  45950. * @returns false
  45951. */
  45952. needAlphaTesting(): boolean;
  45953. /**
  45954. * The entire material has been created in order to prevent overdraw.
  45955. * @returns true if blending is enable
  45956. */
  45957. needAlphaBlending(): boolean;
  45958. /**
  45959. * Checks wether the material is ready to be rendered for a given mesh.
  45960. * @param mesh The mesh to render
  45961. * @param subMesh The submesh to check against
  45962. * @param useInstances Specify wether or not the material is used with instances
  45963. * @returns true if all the dependencies are ready (Textures, Effects...)
  45964. */
  45965. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45966. /**
  45967. * Compute the primary color according to the chosen perceptual color.
  45968. */
  45969. private _computePrimaryColorFromPerceptualColor;
  45970. /**
  45971. * Compute the highlights and shadow colors according to their chosen levels.
  45972. */
  45973. private _computePrimaryColors;
  45974. /**
  45975. * Build the uniform buffer used in the material.
  45976. */
  45977. buildUniformLayout(): void;
  45978. /**
  45979. * Unbind the material.
  45980. */
  45981. unbind(): void;
  45982. /**
  45983. * Bind only the world matrix to the material.
  45984. * @param world The world matrix to bind.
  45985. */
  45986. bindOnlyWorldMatrix(world: Matrix): void;
  45987. /**
  45988. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45989. * @param world The world matrix to bind.
  45990. * @param subMesh The submesh to bind for.
  45991. */
  45992. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45993. /**
  45994. * Dispose the material.
  45995. * @param forceDisposeEffect Force disposal of the associated effect.
  45996. * @param forceDisposeTextures Force disposal of the associated textures.
  45997. */
  45998. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45999. /**
  46000. * Clones the material.
  46001. * @param name The cloned name.
  46002. * @returns The cloned material.
  46003. */
  46004. clone(name: string): BackgroundMaterial;
  46005. /**
  46006. * Serializes the current material to its JSON representation.
  46007. * @returns The JSON representation.
  46008. */
  46009. serialize(): any;
  46010. /**
  46011. * Gets the class name of the material
  46012. * @returns "BackgroundMaterial"
  46013. */
  46014. getClassName(): string;
  46015. /**
  46016. * Parse a JSON input to create back a background material.
  46017. * @param source The JSON data to parse
  46018. * @param scene The scene to create the parsed material in
  46019. * @param rootUrl The root url of the assets the material depends upon
  46020. * @returns the instantiated BackgroundMaterial.
  46021. */
  46022. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46023. }
  46024. }
  46025. declare module "babylonjs/Helpers/environmentHelper" {
  46026. import { Observable } from "babylonjs/Misc/observable";
  46027. import { Nullable } from "babylonjs/types";
  46028. import { Scene } from "babylonjs/scene";
  46029. import { Vector3, Color3 } from "babylonjs/Maths/math";
  46030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46031. import { Mesh } from "babylonjs/Meshes/mesh";
  46032. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46033. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46034. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46035. import "babylonjs/Meshes/Builders/planeBuilder";
  46036. import "babylonjs/Meshes/Builders/boxBuilder";
  46037. /**
  46038. * Represents the different options available during the creation of
  46039. * a Environment helper.
  46040. *
  46041. * This can control the default ground, skybox and image processing setup of your scene.
  46042. */
  46043. export interface IEnvironmentHelperOptions {
  46044. /**
  46045. * Specifies wether or not to create a ground.
  46046. * True by default.
  46047. */
  46048. createGround: boolean;
  46049. /**
  46050. * Specifies the ground size.
  46051. * 15 by default.
  46052. */
  46053. groundSize: number;
  46054. /**
  46055. * The texture used on the ground for the main color.
  46056. * Comes from the BabylonJS CDN by default.
  46057. *
  46058. * Remarks: Can be either a texture or a url.
  46059. */
  46060. groundTexture: string | BaseTexture;
  46061. /**
  46062. * The color mixed in the ground texture by default.
  46063. * BabylonJS clearColor by default.
  46064. */
  46065. groundColor: Color3;
  46066. /**
  46067. * Specifies the ground opacity.
  46068. * 1 by default.
  46069. */
  46070. groundOpacity: number;
  46071. /**
  46072. * Enables the ground to receive shadows.
  46073. * True by default.
  46074. */
  46075. enableGroundShadow: boolean;
  46076. /**
  46077. * Helps preventing the shadow to be fully black on the ground.
  46078. * 0.5 by default.
  46079. */
  46080. groundShadowLevel: number;
  46081. /**
  46082. * Creates a mirror texture attach to the ground.
  46083. * false by default.
  46084. */
  46085. enableGroundMirror: boolean;
  46086. /**
  46087. * Specifies the ground mirror size ratio.
  46088. * 0.3 by default as the default kernel is 64.
  46089. */
  46090. groundMirrorSizeRatio: number;
  46091. /**
  46092. * Specifies the ground mirror blur kernel size.
  46093. * 64 by default.
  46094. */
  46095. groundMirrorBlurKernel: number;
  46096. /**
  46097. * Specifies the ground mirror visibility amount.
  46098. * 1 by default
  46099. */
  46100. groundMirrorAmount: number;
  46101. /**
  46102. * Specifies the ground mirror reflectance weight.
  46103. * This uses the standard weight of the background material to setup the fresnel effect
  46104. * of the mirror.
  46105. * 1 by default.
  46106. */
  46107. groundMirrorFresnelWeight: number;
  46108. /**
  46109. * Specifies the ground mirror Falloff distance.
  46110. * This can helps reducing the size of the reflection.
  46111. * 0 by Default.
  46112. */
  46113. groundMirrorFallOffDistance: number;
  46114. /**
  46115. * Specifies the ground mirror texture type.
  46116. * Unsigned Int by Default.
  46117. */
  46118. groundMirrorTextureType: number;
  46119. /**
  46120. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46121. * the shown objects.
  46122. */
  46123. groundYBias: number;
  46124. /**
  46125. * Specifies wether or not to create a skybox.
  46126. * True by default.
  46127. */
  46128. createSkybox: boolean;
  46129. /**
  46130. * Specifies the skybox size.
  46131. * 20 by default.
  46132. */
  46133. skyboxSize: number;
  46134. /**
  46135. * The texture used on the skybox for the main color.
  46136. * Comes from the BabylonJS CDN by default.
  46137. *
  46138. * Remarks: Can be either a texture or a url.
  46139. */
  46140. skyboxTexture: string | BaseTexture;
  46141. /**
  46142. * The color mixed in the skybox texture by default.
  46143. * BabylonJS clearColor by default.
  46144. */
  46145. skyboxColor: Color3;
  46146. /**
  46147. * The background rotation around the Y axis of the scene.
  46148. * This helps aligning the key lights of your scene with the background.
  46149. * 0 by default.
  46150. */
  46151. backgroundYRotation: number;
  46152. /**
  46153. * Compute automatically the size of the elements to best fit with the scene.
  46154. */
  46155. sizeAuto: boolean;
  46156. /**
  46157. * Default position of the rootMesh if autoSize is not true.
  46158. */
  46159. rootPosition: Vector3;
  46160. /**
  46161. * Sets up the image processing in the scene.
  46162. * true by default.
  46163. */
  46164. setupImageProcessing: boolean;
  46165. /**
  46166. * The texture used as your environment texture in the scene.
  46167. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46168. *
  46169. * Remarks: Can be either a texture or a url.
  46170. */
  46171. environmentTexture: string | BaseTexture;
  46172. /**
  46173. * The value of the exposure to apply to the scene.
  46174. * 0.6 by default if setupImageProcessing is true.
  46175. */
  46176. cameraExposure: number;
  46177. /**
  46178. * The value of the contrast to apply to the scene.
  46179. * 1.6 by default if setupImageProcessing is true.
  46180. */
  46181. cameraContrast: number;
  46182. /**
  46183. * Specifies wether or not tonemapping should be enabled in the scene.
  46184. * true by default if setupImageProcessing is true.
  46185. */
  46186. toneMappingEnabled: boolean;
  46187. }
  46188. /**
  46189. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46190. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46191. * It also helps with the default setup of your imageProcessing configuration.
  46192. */
  46193. export class EnvironmentHelper {
  46194. /**
  46195. * Default ground texture URL.
  46196. */
  46197. private static _groundTextureCDNUrl;
  46198. /**
  46199. * Default skybox texture URL.
  46200. */
  46201. private static _skyboxTextureCDNUrl;
  46202. /**
  46203. * Default environment texture URL.
  46204. */
  46205. private static _environmentTextureCDNUrl;
  46206. /**
  46207. * Creates the default options for the helper.
  46208. */
  46209. private static _getDefaultOptions;
  46210. private _rootMesh;
  46211. /**
  46212. * Gets the root mesh created by the helper.
  46213. */
  46214. readonly rootMesh: Mesh;
  46215. private _skybox;
  46216. /**
  46217. * Gets the skybox created by the helper.
  46218. */
  46219. readonly skybox: Nullable<Mesh>;
  46220. private _skyboxTexture;
  46221. /**
  46222. * Gets the skybox texture created by the helper.
  46223. */
  46224. readonly skyboxTexture: Nullable<BaseTexture>;
  46225. private _skyboxMaterial;
  46226. /**
  46227. * Gets the skybox material created by the helper.
  46228. */
  46229. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46230. private _ground;
  46231. /**
  46232. * Gets the ground mesh created by the helper.
  46233. */
  46234. readonly ground: Nullable<Mesh>;
  46235. private _groundTexture;
  46236. /**
  46237. * Gets the ground texture created by the helper.
  46238. */
  46239. readonly groundTexture: Nullable<BaseTexture>;
  46240. private _groundMirror;
  46241. /**
  46242. * Gets the ground mirror created by the helper.
  46243. */
  46244. readonly groundMirror: Nullable<MirrorTexture>;
  46245. /**
  46246. * Gets the ground mirror render list to helps pushing the meshes
  46247. * you wish in the ground reflection.
  46248. */
  46249. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46250. private _groundMaterial;
  46251. /**
  46252. * Gets the ground material created by the helper.
  46253. */
  46254. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46255. /**
  46256. * Stores the creation options.
  46257. */
  46258. private readonly _scene;
  46259. private _options;
  46260. /**
  46261. * This observable will be notified with any error during the creation of the environment,
  46262. * mainly texture creation errors.
  46263. */
  46264. onErrorObservable: Observable<{
  46265. message?: string;
  46266. exception?: any;
  46267. }>;
  46268. /**
  46269. * constructor
  46270. * @param options Defines the options we want to customize the helper
  46271. * @param scene The scene to add the material to
  46272. */
  46273. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46274. /**
  46275. * Updates the background according to the new options
  46276. * @param options
  46277. */
  46278. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46279. /**
  46280. * Sets the primary color of all the available elements.
  46281. * @param color the main color to affect to the ground and the background
  46282. */
  46283. setMainColor(color: Color3): void;
  46284. /**
  46285. * Setup the image processing according to the specified options.
  46286. */
  46287. private _setupImageProcessing;
  46288. /**
  46289. * Setup the environment texture according to the specified options.
  46290. */
  46291. private _setupEnvironmentTexture;
  46292. /**
  46293. * Setup the background according to the specified options.
  46294. */
  46295. private _setupBackground;
  46296. /**
  46297. * Get the scene sizes according to the setup.
  46298. */
  46299. private _getSceneSize;
  46300. /**
  46301. * Setup the ground according to the specified options.
  46302. */
  46303. private _setupGround;
  46304. /**
  46305. * Setup the ground material according to the specified options.
  46306. */
  46307. private _setupGroundMaterial;
  46308. /**
  46309. * Setup the ground diffuse texture according to the specified options.
  46310. */
  46311. private _setupGroundDiffuseTexture;
  46312. /**
  46313. * Setup the ground mirror texture according to the specified options.
  46314. */
  46315. private _setupGroundMirrorTexture;
  46316. /**
  46317. * Setup the ground to receive the mirror texture.
  46318. */
  46319. private _setupMirrorInGroundMaterial;
  46320. /**
  46321. * Setup the skybox according to the specified options.
  46322. */
  46323. private _setupSkybox;
  46324. /**
  46325. * Setup the skybox material according to the specified options.
  46326. */
  46327. private _setupSkyboxMaterial;
  46328. /**
  46329. * Setup the skybox reflection texture according to the specified options.
  46330. */
  46331. private _setupSkyboxReflectionTexture;
  46332. private _errorHandler;
  46333. /**
  46334. * Dispose all the elements created by the Helper.
  46335. */
  46336. dispose(): void;
  46337. }
  46338. }
  46339. declare module "babylonjs/Helpers/photoDome" {
  46340. import { Observable } from "babylonjs/Misc/observable";
  46341. import { Nullable } from "babylonjs/types";
  46342. import { Scene } from "babylonjs/scene";
  46343. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46344. import { Mesh } from "babylonjs/Meshes/mesh";
  46345. import { Texture } from "babylonjs/Materials/Textures/texture";
  46346. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46347. import "babylonjs/Meshes/Builders/sphereBuilder";
  46348. /**
  46349. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46350. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46351. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46352. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46353. */
  46354. export class PhotoDome extends TransformNode {
  46355. /**
  46356. * Define the image as a Monoscopic panoramic 360 image.
  46357. */
  46358. static readonly MODE_MONOSCOPIC: number;
  46359. /**
  46360. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46361. */
  46362. static readonly MODE_TOPBOTTOM: number;
  46363. /**
  46364. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46365. */
  46366. static readonly MODE_SIDEBYSIDE: number;
  46367. private _useDirectMapping;
  46368. /**
  46369. * The texture being displayed on the sphere
  46370. */
  46371. protected _photoTexture: Texture;
  46372. /**
  46373. * Gets or sets the texture being displayed on the sphere
  46374. */
  46375. photoTexture: Texture;
  46376. /**
  46377. * Observable raised when an error occured while loading the 360 image
  46378. */
  46379. onLoadErrorObservable: Observable<string>;
  46380. /**
  46381. * The skybox material
  46382. */
  46383. protected _material: BackgroundMaterial;
  46384. /**
  46385. * The surface used for the skybox
  46386. */
  46387. protected _mesh: Mesh;
  46388. /**
  46389. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46390. * Also see the options.resolution property.
  46391. */
  46392. fovMultiplier: number;
  46393. private _imageMode;
  46394. /**
  46395. * Gets or set the current video mode for the video. It can be:
  46396. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46397. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46398. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46399. */
  46400. imageMode: number;
  46401. /**
  46402. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46403. * @param name Element's name, child elements will append suffixes for their own names.
  46404. * @param urlsOfPhoto defines the url of the photo to display
  46405. * @param options defines an object containing optional or exposed sub element properties
  46406. * @param onError defines a callback called when an error occured while loading the texture
  46407. */
  46408. constructor(name: string, urlOfPhoto: string, options: {
  46409. resolution?: number;
  46410. size?: number;
  46411. useDirectMapping?: boolean;
  46412. faceForward?: boolean;
  46413. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46414. private _onBeforeCameraRenderObserver;
  46415. private _changeImageMode;
  46416. /**
  46417. * Releases resources associated with this node.
  46418. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46419. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46420. */
  46421. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46422. }
  46423. }
  46424. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46425. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46426. /** @hidden */
  46427. export var rgbdDecodePixelShader: {
  46428. name: string;
  46429. shader: string;
  46430. };
  46431. }
  46432. declare module "babylonjs/Misc/brdfTextureTools" {
  46433. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46434. import { Scene } from "babylonjs/scene";
  46435. import "babylonjs/Shaders/rgbdDecode.fragment";
  46436. /**
  46437. * Class used to host texture specific utilities
  46438. */
  46439. export class BRDFTextureTools {
  46440. /**
  46441. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46442. * @param texture the texture to expand.
  46443. */
  46444. private static _ExpandDefaultBRDFTexture;
  46445. /**
  46446. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46447. * @param scene defines the hosting scene
  46448. * @returns the environment BRDF texture
  46449. */
  46450. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46451. private static _environmentBRDFBase64Texture;
  46452. }
  46453. }
  46454. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46455. import { Nullable } from "babylonjs/types";
  46456. import { IAnimatable } from "babylonjs/Misc/tools";
  46457. import { Color3 } from "babylonjs/Maths/math";
  46458. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46459. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46460. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46461. import { Engine } from "babylonjs/Engines/engine";
  46462. import { Scene } from "babylonjs/scene";
  46463. /**
  46464. * @hidden
  46465. */
  46466. export interface IMaterialClearCoatDefines {
  46467. CLEARCOAT: boolean;
  46468. CLEARCOAT_DEFAULTIOR: boolean;
  46469. CLEARCOAT_TEXTURE: boolean;
  46470. CLEARCOAT_TEXTUREDIRECTUV: number;
  46471. CLEARCOAT_BUMP: boolean;
  46472. CLEARCOAT_BUMPDIRECTUV: number;
  46473. CLEARCOAT_TINT: boolean;
  46474. CLEARCOAT_TINT_TEXTURE: boolean;
  46475. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46476. /** @hidden */
  46477. _areTexturesDirty: boolean;
  46478. }
  46479. /**
  46480. * Define the code related to the clear coat parameters of the pbr material.
  46481. */
  46482. export class PBRClearCoatConfiguration {
  46483. /**
  46484. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46485. * The default fits with a polyurethane material.
  46486. */
  46487. private static readonly _DefaultIndexOfRefraction;
  46488. private _isEnabled;
  46489. /**
  46490. * Defines if the clear coat is enabled in the material.
  46491. */
  46492. isEnabled: boolean;
  46493. /**
  46494. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46495. */
  46496. intensity: number;
  46497. /**
  46498. * Defines the clear coat layer roughness.
  46499. */
  46500. roughness: number;
  46501. private _indexOfRefraction;
  46502. /**
  46503. * Defines the index of refraction of the clear coat.
  46504. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46505. * The default fits with a polyurethane material.
  46506. * Changing the default value is more performance intensive.
  46507. */
  46508. indexOfRefraction: number;
  46509. private _texture;
  46510. /**
  46511. * Stores the clear coat values in a texture.
  46512. */
  46513. texture: Nullable<BaseTexture>;
  46514. private _bumpTexture;
  46515. /**
  46516. * Define the clear coat specific bump texture.
  46517. */
  46518. bumpTexture: Nullable<BaseTexture>;
  46519. private _isTintEnabled;
  46520. /**
  46521. * Defines if the clear coat tint is enabled in the material.
  46522. */
  46523. isTintEnabled: boolean;
  46524. /**
  46525. * Defines the clear coat tint of the material.
  46526. * This is only use if tint is enabled
  46527. */
  46528. tintColor: Color3;
  46529. /**
  46530. * Defines the distance at which the tint color should be found in the
  46531. * clear coat media.
  46532. * This is only use if tint is enabled
  46533. */
  46534. tintColorAtDistance: number;
  46535. /**
  46536. * Defines the clear coat layer thickness.
  46537. * This is only use if tint is enabled
  46538. */
  46539. tintThickness: number;
  46540. private _tintTexture;
  46541. /**
  46542. * Stores the clear tint values in a texture.
  46543. * rgb is tint
  46544. * a is a thickness factor
  46545. */
  46546. tintTexture: Nullable<BaseTexture>;
  46547. /** @hidden */
  46548. private _internalMarkAllSubMeshesAsTexturesDirty;
  46549. /** @hidden */
  46550. _markAllSubMeshesAsTexturesDirty(): void;
  46551. /**
  46552. * Instantiate a new istance of clear coat configuration.
  46553. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46554. */
  46555. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46556. /**
  46557. * Gets wehter the submesh is ready to be used or not.
  46558. * @param defines the list of "defines" to update.
  46559. * @param scene defines the scene the material belongs to.
  46560. * @param engine defines the engine the material belongs to.
  46561. * @param disableBumpMap defines wether the material disables bump or not.
  46562. * @returns - boolean indicating that the submesh is ready or not.
  46563. */
  46564. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46565. /**
  46566. * Checks to see if a texture is used in the material.
  46567. * @param defines the list of "defines" to update.
  46568. * @param scene defines the scene to the material belongs to.
  46569. */
  46570. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46571. /**
  46572. * Binds the material data.
  46573. * @param uniformBuffer defines the Uniform buffer to fill in.
  46574. * @param scene defines the scene the material belongs to.
  46575. * @param engine defines the engine the material belongs to.
  46576. * @param disableBumpMap defines wether the material disables bump or not.
  46577. * @param isFrozen defines wether the material is frozen or not.
  46578. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46579. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46580. */
  46581. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46582. /**
  46583. * Checks to see if a texture is used in the material.
  46584. * @param texture - Base texture to use.
  46585. * @returns - Boolean specifying if a texture is used in the material.
  46586. */
  46587. hasTexture(texture: BaseTexture): boolean;
  46588. /**
  46589. * Returns an array of the actively used textures.
  46590. * @param activeTextures Array of BaseTextures
  46591. */
  46592. getActiveTextures(activeTextures: BaseTexture[]): void;
  46593. /**
  46594. * Returns the animatable textures.
  46595. * @param animatables Array of animatable textures.
  46596. */
  46597. getAnimatables(animatables: IAnimatable[]): void;
  46598. /**
  46599. * Disposes the resources of the material.
  46600. * @param forceDisposeTextures - Forces the disposal of all textures.
  46601. */
  46602. dispose(forceDisposeTextures?: boolean): void;
  46603. /**
  46604. * Get the current class name of the texture useful for serialization or dynamic coding.
  46605. * @returns "PBRClearCoatConfiguration"
  46606. */
  46607. getClassName(): string;
  46608. /**
  46609. * Add fallbacks to the effect fallbacks list.
  46610. * @param defines defines the Base texture to use.
  46611. * @param fallbacks defines the current fallback list.
  46612. * @param currentRank defines the current fallback rank.
  46613. * @returns the new fallback rank.
  46614. */
  46615. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46616. /**
  46617. * Add the required uniforms to the current list.
  46618. * @param uniforms defines the current uniform list.
  46619. */
  46620. static AddUniforms(uniforms: string[]): void;
  46621. /**
  46622. * Add the required samplers to the current list.
  46623. * @param samplers defines the current sampler list.
  46624. */
  46625. static AddSamplers(samplers: string[]): void;
  46626. /**
  46627. * Add the required uniforms to the current buffer.
  46628. * @param uniformBuffer defines the current uniform buffer.
  46629. */
  46630. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46631. /**
  46632. * Makes a duplicate of the current configuration into another one.
  46633. * @param clearCoatConfiguration define the config where to copy the info
  46634. */
  46635. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46636. /**
  46637. * Serializes this clear coat configuration.
  46638. * @returns - An object with the serialized config.
  46639. */
  46640. serialize(): any;
  46641. /**
  46642. * Parses a anisotropy Configuration from a serialized object.
  46643. * @param source - Serialized object.
  46644. * @param scene Defines the scene we are parsing for
  46645. * @param rootUrl Defines the rootUrl to load from
  46646. */
  46647. parse(source: any, scene: Scene, rootUrl: string): void;
  46648. }
  46649. }
  46650. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46651. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46652. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46654. import { Vector2 } from "babylonjs/Maths/math";
  46655. import { Scene } from "babylonjs/scene";
  46656. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46657. import { IAnimatable } from "babylonjs/Misc/tools";
  46658. import { Nullable } from "babylonjs/types";
  46659. /**
  46660. * @hidden
  46661. */
  46662. export interface IMaterialAnisotropicDefines {
  46663. ANISOTROPIC: boolean;
  46664. ANISOTROPIC_TEXTURE: boolean;
  46665. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46666. MAINUV1: boolean;
  46667. _areTexturesDirty: boolean;
  46668. _needUVs: boolean;
  46669. }
  46670. /**
  46671. * Define the code related to the anisotropic parameters of the pbr material.
  46672. */
  46673. export class PBRAnisotropicConfiguration {
  46674. private _isEnabled;
  46675. /**
  46676. * Defines if the anisotropy is enabled in the material.
  46677. */
  46678. isEnabled: boolean;
  46679. /**
  46680. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46681. */
  46682. intensity: number;
  46683. /**
  46684. * Defines if the effect is along the tangents, bitangents or in between.
  46685. * By default, the effect is "strectching" the highlights along the tangents.
  46686. */
  46687. direction: Vector2;
  46688. private _texture;
  46689. /**
  46690. * Stores the anisotropy values in a texture.
  46691. * rg is direction (like normal from -1 to 1)
  46692. * b is a intensity
  46693. */
  46694. texture: Nullable<BaseTexture>;
  46695. /** @hidden */
  46696. private _internalMarkAllSubMeshesAsTexturesDirty;
  46697. /** @hidden */
  46698. _markAllSubMeshesAsTexturesDirty(): void;
  46699. /**
  46700. * Instantiate a new istance of anisotropy configuration.
  46701. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46702. */
  46703. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46704. /**
  46705. * Specifies that the submesh is ready to be used.
  46706. * @param defines the list of "defines" to update.
  46707. * @param scene defines the scene the material belongs to.
  46708. * @returns - boolean indicating that the submesh is ready or not.
  46709. */
  46710. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46711. /**
  46712. * Checks to see if a texture is used in the material.
  46713. * @param defines the list of "defines" to update.
  46714. * @param mesh the mesh we are preparing the defines for.
  46715. * @param scene defines the scene the material belongs to.
  46716. */
  46717. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46718. /**
  46719. * Binds the material data.
  46720. * @param uniformBuffer defines the Uniform buffer to fill in.
  46721. * @param scene defines the scene the material belongs to.
  46722. * @param isFrozen defines wether the material is frozen or not.
  46723. */
  46724. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46725. /**
  46726. * Checks to see if a texture is used in the material.
  46727. * @param texture - Base texture to use.
  46728. * @returns - Boolean specifying if a texture is used in the material.
  46729. */
  46730. hasTexture(texture: BaseTexture): boolean;
  46731. /**
  46732. * Returns an array of the actively used textures.
  46733. * @param activeTextures Array of BaseTextures
  46734. */
  46735. getActiveTextures(activeTextures: BaseTexture[]): void;
  46736. /**
  46737. * Returns the animatable textures.
  46738. * @param animatables Array of animatable textures.
  46739. */
  46740. getAnimatables(animatables: IAnimatable[]): void;
  46741. /**
  46742. * Disposes the resources of the material.
  46743. * @param forceDisposeTextures - Forces the disposal of all textures.
  46744. */
  46745. dispose(forceDisposeTextures?: boolean): void;
  46746. /**
  46747. * Get the current class name of the texture useful for serialization or dynamic coding.
  46748. * @returns "PBRAnisotropicConfiguration"
  46749. */
  46750. getClassName(): string;
  46751. /**
  46752. * Add fallbacks to the effect fallbacks list.
  46753. * @param defines defines the Base texture to use.
  46754. * @param fallbacks defines the current fallback list.
  46755. * @param currentRank defines the current fallback rank.
  46756. * @returns the new fallback rank.
  46757. */
  46758. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46759. /**
  46760. * Add the required uniforms to the current list.
  46761. * @param uniforms defines the current uniform list.
  46762. */
  46763. static AddUniforms(uniforms: string[]): void;
  46764. /**
  46765. * Add the required uniforms to the current buffer.
  46766. * @param uniformBuffer defines the current uniform buffer.
  46767. */
  46768. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46769. /**
  46770. * Add the required samplers to the current list.
  46771. * @param samplers defines the current sampler list.
  46772. */
  46773. static AddSamplers(samplers: string[]): void;
  46774. /**
  46775. * Makes a duplicate of the current configuration into another one.
  46776. * @param anisotropicConfiguration define the config where to copy the info
  46777. */
  46778. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46779. /**
  46780. * Serializes this anisotropy configuration.
  46781. * @returns - An object with the serialized config.
  46782. */
  46783. serialize(): any;
  46784. /**
  46785. * Parses a anisotropy Configuration from a serialized object.
  46786. * @param source - Serialized object.
  46787. * @param scene Defines the scene we are parsing for
  46788. * @param rootUrl Defines the rootUrl to load from
  46789. */
  46790. parse(source: any, scene: Scene, rootUrl: string): void;
  46791. }
  46792. }
  46793. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46794. import { Scene } from "babylonjs/scene";
  46795. /**
  46796. * @hidden
  46797. */
  46798. export interface IMaterialBRDFDefines {
  46799. BRDF_V_HEIGHT_CORRELATED: boolean;
  46800. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46801. SPHERICAL_HARMONICS: boolean;
  46802. /** @hidden */
  46803. _areMiscDirty: boolean;
  46804. }
  46805. /**
  46806. * Define the code related to the BRDF parameters of the pbr material.
  46807. */
  46808. export class PBRBRDFConfiguration {
  46809. /**
  46810. * Default value used for the energy conservation.
  46811. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46812. */
  46813. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46814. /**
  46815. * Default value used for the Smith Visibility Height Correlated mode.
  46816. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46817. */
  46818. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46819. /**
  46820. * Default value used for the IBL diffuse part.
  46821. * This can help switching back to the polynomials mode globally which is a tiny bit
  46822. * less GPU intensive at the drawback of a lower quality.
  46823. */
  46824. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46825. private _useEnergyConservation;
  46826. /**
  46827. * Defines if the material uses energy conservation.
  46828. */
  46829. useEnergyConservation: boolean;
  46830. private _useSmithVisibilityHeightCorrelated;
  46831. /**
  46832. * LEGACY Mode set to false
  46833. * Defines if the material uses height smith correlated visibility term.
  46834. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46835. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46836. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46837. * Not relying on height correlated will also disable energy conservation.
  46838. */
  46839. useSmithVisibilityHeightCorrelated: boolean;
  46840. private _useSphericalHarmonics;
  46841. /**
  46842. * LEGACY Mode set to false
  46843. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46844. * diffuse part of the IBL.
  46845. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46846. * to the ground truth.
  46847. */
  46848. useSphericalHarmonics: boolean;
  46849. /** @hidden */
  46850. private _internalMarkAllSubMeshesAsMiscDirty;
  46851. /** @hidden */
  46852. _markAllSubMeshesAsMiscDirty(): void;
  46853. /**
  46854. * Instantiate a new istance of clear coat configuration.
  46855. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46856. */
  46857. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46858. /**
  46859. * Checks to see if a texture is used in the material.
  46860. * @param defines the list of "defines" to update.
  46861. */
  46862. prepareDefines(defines: IMaterialBRDFDefines): void;
  46863. /**
  46864. * Get the current class name of the texture useful for serialization or dynamic coding.
  46865. * @returns "PBRClearCoatConfiguration"
  46866. */
  46867. getClassName(): string;
  46868. /**
  46869. * Makes a duplicate of the current configuration into another one.
  46870. * @param brdfConfiguration define the config where to copy the info
  46871. */
  46872. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46873. /**
  46874. * Serializes this BRDF configuration.
  46875. * @returns - An object with the serialized config.
  46876. */
  46877. serialize(): any;
  46878. /**
  46879. * Parses a anisotropy Configuration from a serialized object.
  46880. * @param source - Serialized object.
  46881. * @param scene Defines the scene we are parsing for
  46882. * @param rootUrl Defines the rootUrl to load from
  46883. */
  46884. parse(source: any, scene: Scene, rootUrl: string): void;
  46885. }
  46886. }
  46887. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46888. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46889. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46890. import { Color3 } from "babylonjs/Maths/math";
  46891. import { Scene } from "babylonjs/scene";
  46892. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46893. import { IAnimatable } from "babylonjs/Misc/tools";
  46894. import { Nullable } from "babylonjs/types";
  46895. /**
  46896. * @hidden
  46897. */
  46898. export interface IMaterialSheenDefines {
  46899. SHEEN: boolean;
  46900. SHEEN_TEXTURE: boolean;
  46901. SHEEN_TEXTUREDIRECTUV: number;
  46902. SHEEN_LINKWITHALBEDO: boolean;
  46903. /** @hidden */
  46904. _areTexturesDirty: boolean;
  46905. }
  46906. /**
  46907. * Define the code related to the Sheen parameters of the pbr material.
  46908. */
  46909. export class PBRSheenConfiguration {
  46910. private _isEnabled;
  46911. /**
  46912. * Defines if the material uses sheen.
  46913. */
  46914. isEnabled: boolean;
  46915. private _linkSheenWithAlbedo;
  46916. /**
  46917. * Defines if the sheen is linked to the sheen color.
  46918. */
  46919. linkSheenWithAlbedo: boolean;
  46920. /**
  46921. * Defines the sheen intensity.
  46922. */
  46923. intensity: number;
  46924. /**
  46925. * Defines the sheen color.
  46926. */
  46927. color: Color3;
  46928. private _texture;
  46929. /**
  46930. * Stores the sheen tint values in a texture.
  46931. * rgb is tint
  46932. * a is a intensity
  46933. */
  46934. texture: Nullable<BaseTexture>;
  46935. /** @hidden */
  46936. private _internalMarkAllSubMeshesAsTexturesDirty;
  46937. /** @hidden */
  46938. _markAllSubMeshesAsTexturesDirty(): void;
  46939. /**
  46940. * Instantiate a new istance of clear coat configuration.
  46941. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46942. */
  46943. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46944. /**
  46945. * Specifies that the submesh is ready to be used.
  46946. * @param defines the list of "defines" to update.
  46947. * @param scene defines the scene the material belongs to.
  46948. * @returns - boolean indicating that the submesh is ready or not.
  46949. */
  46950. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46951. /**
  46952. * Checks to see if a texture is used in the material.
  46953. * @param defines the list of "defines" to update.
  46954. * @param scene defines the scene the material belongs to.
  46955. */
  46956. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46957. /**
  46958. * Binds the material data.
  46959. * @param uniformBuffer defines the Uniform buffer to fill in.
  46960. * @param scene defines the scene the material belongs to.
  46961. * @param isFrozen defines wether the material is frozen or not.
  46962. */
  46963. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46964. /**
  46965. * Checks to see if a texture is used in the material.
  46966. * @param texture - Base texture to use.
  46967. * @returns - Boolean specifying if a texture is used in the material.
  46968. */
  46969. hasTexture(texture: BaseTexture): boolean;
  46970. /**
  46971. * Returns an array of the actively used textures.
  46972. * @param activeTextures Array of BaseTextures
  46973. */
  46974. getActiveTextures(activeTextures: BaseTexture[]): void;
  46975. /**
  46976. * Returns the animatable textures.
  46977. * @param animatables Array of animatable textures.
  46978. */
  46979. getAnimatables(animatables: IAnimatable[]): void;
  46980. /**
  46981. * Disposes the resources of the material.
  46982. * @param forceDisposeTextures - Forces the disposal of all textures.
  46983. */
  46984. dispose(forceDisposeTextures?: boolean): void;
  46985. /**
  46986. * Get the current class name of the texture useful for serialization or dynamic coding.
  46987. * @returns "PBRSheenConfiguration"
  46988. */
  46989. getClassName(): string;
  46990. /**
  46991. * Add fallbacks to the effect fallbacks list.
  46992. * @param defines defines the Base texture to use.
  46993. * @param fallbacks defines the current fallback list.
  46994. * @param currentRank defines the current fallback rank.
  46995. * @returns the new fallback rank.
  46996. */
  46997. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46998. /**
  46999. * Add the required uniforms to the current list.
  47000. * @param uniforms defines the current uniform list.
  47001. */
  47002. static AddUniforms(uniforms: string[]): void;
  47003. /**
  47004. * Add the required uniforms to the current buffer.
  47005. * @param uniformBuffer defines the current uniform buffer.
  47006. */
  47007. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47008. /**
  47009. * Add the required samplers to the current list.
  47010. * @param samplers defines the current sampler list.
  47011. */
  47012. static AddSamplers(samplers: string[]): void;
  47013. /**
  47014. * Makes a duplicate of the current configuration into another one.
  47015. * @param sheenConfiguration define the config where to copy the info
  47016. */
  47017. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47018. /**
  47019. * Serializes this BRDF configuration.
  47020. * @returns - An object with the serialized config.
  47021. */
  47022. serialize(): any;
  47023. /**
  47024. * Parses a anisotropy Configuration from a serialized object.
  47025. * @param source - Serialized object.
  47026. * @param scene Defines the scene we are parsing for
  47027. * @param rootUrl Defines the rootUrl to load from
  47028. */
  47029. parse(source: any, scene: Scene, rootUrl: string): void;
  47030. }
  47031. }
  47032. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47033. import { Nullable } from "babylonjs/types";
  47034. import { IAnimatable } from "babylonjs/Misc/tools";
  47035. import { Color3 } from "babylonjs/Maths/math";
  47036. import { SmartArray } from "babylonjs/Misc/smartArray";
  47037. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47038. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47039. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47040. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47041. import { Engine } from "babylonjs/Engines/engine";
  47042. import { Scene } from "babylonjs/scene";
  47043. /**
  47044. * @hidden
  47045. */
  47046. export interface IMaterialSubSurfaceDefines {
  47047. SUBSURFACE: boolean;
  47048. SS_REFRACTION: boolean;
  47049. SS_TRANSLUCENCY: boolean;
  47050. SS_SCATERRING: boolean;
  47051. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47052. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47053. SS_REFRACTIONMAP_3D: boolean;
  47054. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47055. SS_LODINREFRACTIONALPHA: boolean;
  47056. SS_GAMMAREFRACTION: boolean;
  47057. SS_RGBDREFRACTION: boolean;
  47058. SS_LINEARSPECULARREFRACTION: boolean;
  47059. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47060. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47061. /** @hidden */
  47062. _areTexturesDirty: boolean;
  47063. }
  47064. /**
  47065. * Define the code related to the sub surface parameters of the pbr material.
  47066. */
  47067. export class PBRSubSurfaceConfiguration {
  47068. private _isRefractionEnabled;
  47069. /**
  47070. * Defines if the refraction is enabled in the material.
  47071. */
  47072. isRefractionEnabled: boolean;
  47073. private _isTranslucencyEnabled;
  47074. /**
  47075. * Defines if the translucency is enabled in the material.
  47076. */
  47077. isTranslucencyEnabled: boolean;
  47078. private _isScatteringEnabled;
  47079. /**
  47080. * Defines the refraction intensity of the material.
  47081. * The refraction when enabled replaces the Diffuse part of the material.
  47082. * The intensity helps transitionning between diffuse and refraction.
  47083. */
  47084. refractionIntensity: number;
  47085. /**
  47086. * Defines the translucency intensity of the material.
  47087. * When translucency has been enabled, this defines how much of the "translucency"
  47088. * is addded to the diffuse part of the material.
  47089. */
  47090. translucencyIntensity: number;
  47091. /**
  47092. * Defines the scattering intensity of the material.
  47093. * When scattering has been enabled, this defines how much of the "scattered light"
  47094. * is addded to the diffuse part of the material.
  47095. */
  47096. scatteringIntensity: number;
  47097. private _thicknessTexture;
  47098. /**
  47099. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47100. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47101. * 0 would mean minimumThickness
  47102. * 1 would mean maximumThickness
  47103. * The other channels might be use as a mask to vary the different effects intensity.
  47104. */
  47105. thicknessTexture: Nullable<BaseTexture>;
  47106. private _refractionTexture;
  47107. /**
  47108. * Defines the texture to use for refraction.
  47109. */
  47110. refractionTexture: Nullable<BaseTexture>;
  47111. private _indexOfRefraction;
  47112. /**
  47113. * Defines the index of refraction used in the material.
  47114. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47115. */
  47116. indexOfRefraction: number;
  47117. private _invertRefractionY;
  47118. /**
  47119. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47120. */
  47121. invertRefractionY: boolean;
  47122. private _linkRefractionWithTransparency;
  47123. /**
  47124. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47125. * Materials half opaque for instance using refraction could benefit from this control.
  47126. */
  47127. linkRefractionWithTransparency: boolean;
  47128. /**
  47129. * Defines the minimum thickness stored in the thickness map.
  47130. * If no thickness map is defined, this value will be used to simulate thickness.
  47131. */
  47132. minimumThickness: number;
  47133. /**
  47134. * Defines the maximum thickness stored in the thickness map.
  47135. */
  47136. maximumThickness: number;
  47137. /**
  47138. * Defines the volume tint of the material.
  47139. * This is used for both translucency and scattering.
  47140. */
  47141. tintColor: Color3;
  47142. /**
  47143. * Defines the distance at which the tint color should be found in the media.
  47144. * This is used for refraction only.
  47145. */
  47146. tintColorAtDistance: number;
  47147. /**
  47148. * Defines how far each channel transmit through the media.
  47149. * It is defined as a color to simplify it selection.
  47150. */
  47151. diffusionDistance: Color3;
  47152. private _useMaskFromThicknessTexture;
  47153. /**
  47154. * Stores the intensity of the different subsurface effects in the thickness texture.
  47155. * * the green channel is the translucency intensity.
  47156. * * the blue channel is the scattering intensity.
  47157. * * the alpha channel is the refraction intensity.
  47158. */
  47159. useMaskFromThicknessTexture: boolean;
  47160. /** @hidden */
  47161. private _internalMarkAllSubMeshesAsTexturesDirty;
  47162. /** @hidden */
  47163. _markAllSubMeshesAsTexturesDirty(): void;
  47164. /**
  47165. * Instantiate a new istance of sub surface configuration.
  47166. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47167. */
  47168. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47169. /**
  47170. * Gets wehter the submesh is ready to be used or not.
  47171. * @param defines the list of "defines" to update.
  47172. * @param scene defines the scene the material belongs to.
  47173. * @returns - boolean indicating that the submesh is ready or not.
  47174. */
  47175. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47176. /**
  47177. * Checks to see if a texture is used in the material.
  47178. * @param defines the list of "defines" to update.
  47179. * @param scene defines the scene to the material belongs to.
  47180. */
  47181. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47182. /**
  47183. * Binds the material data.
  47184. * @param uniformBuffer defines the Uniform buffer to fill in.
  47185. * @param scene defines the scene the material belongs to.
  47186. * @param engine defines the engine the material belongs to.
  47187. * @param isFrozen defines wether the material is frozen or not.
  47188. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47189. */
  47190. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47191. /**
  47192. * Unbinds the material from the mesh.
  47193. * @param activeEffect defines the effect that should be unbound from.
  47194. * @returns true if unbound, otherwise false
  47195. */
  47196. unbind(activeEffect: Effect): boolean;
  47197. /**
  47198. * Returns the texture used for refraction or null if none is used.
  47199. * @param scene defines the scene the material belongs to.
  47200. * @returns - Refraction texture if present. If no refraction texture and refraction
  47201. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47202. */
  47203. private _getRefractionTexture;
  47204. /**
  47205. * Returns true if alpha blending should be disabled.
  47206. */
  47207. readonly disableAlphaBlending: boolean;
  47208. /**
  47209. * Fills the list of render target textures.
  47210. * @param renderTargets the list of render targets to update
  47211. */
  47212. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47213. /**
  47214. * Checks to see if a texture is used in the material.
  47215. * @param texture - Base texture to use.
  47216. * @returns - Boolean specifying if a texture is used in the material.
  47217. */
  47218. hasTexture(texture: BaseTexture): boolean;
  47219. /**
  47220. * Gets a boolean indicating that current material needs to register RTT
  47221. * @returns true if this uses a render target otherwise false.
  47222. */
  47223. hasRenderTargetTextures(): boolean;
  47224. /**
  47225. * Returns an array of the actively used textures.
  47226. * @param activeTextures Array of BaseTextures
  47227. */
  47228. getActiveTextures(activeTextures: BaseTexture[]): void;
  47229. /**
  47230. * Returns the animatable textures.
  47231. * @param animatables Array of animatable textures.
  47232. */
  47233. getAnimatables(animatables: IAnimatable[]): void;
  47234. /**
  47235. * Disposes the resources of the material.
  47236. * @param forceDisposeTextures - Forces the disposal of all textures.
  47237. */
  47238. dispose(forceDisposeTextures?: boolean): void;
  47239. /**
  47240. * Get the current class name of the texture useful for serialization or dynamic coding.
  47241. * @returns "PBRSubSurfaceConfiguration"
  47242. */
  47243. getClassName(): string;
  47244. /**
  47245. * Add fallbacks to the effect fallbacks list.
  47246. * @param defines defines the Base texture to use.
  47247. * @param fallbacks defines the current fallback list.
  47248. * @param currentRank defines the current fallback rank.
  47249. * @returns the new fallback rank.
  47250. */
  47251. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47252. /**
  47253. * Add the required uniforms to the current list.
  47254. * @param uniforms defines the current uniform list.
  47255. */
  47256. static AddUniforms(uniforms: string[]): void;
  47257. /**
  47258. * Add the required samplers to the current list.
  47259. * @param samplers defines the current sampler list.
  47260. */
  47261. static AddSamplers(samplers: string[]): void;
  47262. /**
  47263. * Add the required uniforms to the current buffer.
  47264. * @param uniformBuffer defines the current uniform buffer.
  47265. */
  47266. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47267. /**
  47268. * Makes a duplicate of the current configuration into another one.
  47269. * @param configuration define the config where to copy the info
  47270. */
  47271. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47272. /**
  47273. * Serializes this Sub Surface configuration.
  47274. * @returns - An object with the serialized config.
  47275. */
  47276. serialize(): any;
  47277. /**
  47278. * Parses a anisotropy Configuration from a serialized object.
  47279. * @param source - Serialized object.
  47280. * @param scene Defines the scene we are parsing for
  47281. * @param rootUrl Defines the rootUrl to load from
  47282. */
  47283. parse(source: any, scene: Scene, rootUrl: string): void;
  47284. }
  47285. }
  47286. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47287. /** @hidden */
  47288. export var pbrFragmentDeclaration: {
  47289. name: string;
  47290. shader: string;
  47291. };
  47292. }
  47293. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47294. /** @hidden */
  47295. export var pbrUboDeclaration: {
  47296. name: string;
  47297. shader: string;
  47298. };
  47299. }
  47300. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47301. /** @hidden */
  47302. export var pbrFragmentExtraDeclaration: {
  47303. name: string;
  47304. shader: string;
  47305. };
  47306. }
  47307. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47308. /** @hidden */
  47309. export var pbrFragmentSamplersDeclaration: {
  47310. name: string;
  47311. shader: string;
  47312. };
  47313. }
  47314. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47315. /** @hidden */
  47316. export var pbrHelperFunctions: {
  47317. name: string;
  47318. shader: string;
  47319. };
  47320. }
  47321. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47322. /** @hidden */
  47323. export var harmonicsFunctions: {
  47324. name: string;
  47325. shader: string;
  47326. };
  47327. }
  47328. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47329. /** @hidden */
  47330. export var pbrDirectLightingSetupFunctions: {
  47331. name: string;
  47332. shader: string;
  47333. };
  47334. }
  47335. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47336. /** @hidden */
  47337. export var pbrDirectLightingFalloffFunctions: {
  47338. name: string;
  47339. shader: string;
  47340. };
  47341. }
  47342. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47343. /** @hidden */
  47344. export var pbrBRDFFunctions: {
  47345. name: string;
  47346. shader: string;
  47347. };
  47348. }
  47349. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47350. /** @hidden */
  47351. export var pbrDirectLightingFunctions: {
  47352. name: string;
  47353. shader: string;
  47354. };
  47355. }
  47356. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47357. /** @hidden */
  47358. export var pbrIBLFunctions: {
  47359. name: string;
  47360. shader: string;
  47361. };
  47362. }
  47363. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47364. /** @hidden */
  47365. export var pbrDebug: {
  47366. name: string;
  47367. shader: string;
  47368. };
  47369. }
  47370. declare module "babylonjs/Shaders/pbr.fragment" {
  47371. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47372. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47373. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47374. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47375. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47376. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47377. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47378. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47379. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47380. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47381. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47382. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47383. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47384. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47385. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47386. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47387. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47388. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47389. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47390. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47391. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47392. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47393. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47394. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47395. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47396. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47397. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47398. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47399. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47400. /** @hidden */
  47401. export var pbrPixelShader: {
  47402. name: string;
  47403. shader: string;
  47404. };
  47405. }
  47406. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47407. /** @hidden */
  47408. export var pbrVertexDeclaration: {
  47409. name: string;
  47410. shader: string;
  47411. };
  47412. }
  47413. declare module "babylonjs/Shaders/pbr.vertex" {
  47414. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47415. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47416. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47417. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47418. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47419. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47420. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47421. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47422. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47423. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47424. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47425. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47427. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47428. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47429. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47430. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47431. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47432. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47433. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47434. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47435. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47436. /** @hidden */
  47437. export var pbrVertexShader: {
  47438. name: string;
  47439. shader: string;
  47440. };
  47441. }
  47442. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47443. import { IAnimatable } from "babylonjs/Misc/tools";
  47444. import { Nullable } from "babylonjs/types";
  47445. import { Scene } from "babylonjs/scene";
  47446. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47447. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47449. import { Mesh } from "babylonjs/Meshes/mesh";
  47450. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47451. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47452. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47453. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47454. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47455. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47456. import { Material } from "babylonjs/Materials/material";
  47457. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47458. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47460. import "babylonjs/Shaders/pbr.fragment";
  47461. import "babylonjs/Shaders/pbr.vertex";
  47462. /**
  47463. * Manages the defines for the PBR Material.
  47464. * @hidden
  47465. */
  47466. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47467. PBR: boolean;
  47468. MAINUV1: boolean;
  47469. MAINUV2: boolean;
  47470. UV1: boolean;
  47471. UV2: boolean;
  47472. ALBEDO: boolean;
  47473. ALBEDODIRECTUV: number;
  47474. VERTEXCOLOR: boolean;
  47475. AMBIENT: boolean;
  47476. AMBIENTDIRECTUV: number;
  47477. AMBIENTINGRAYSCALE: boolean;
  47478. OPACITY: boolean;
  47479. VERTEXALPHA: boolean;
  47480. OPACITYDIRECTUV: number;
  47481. OPACITYRGB: boolean;
  47482. ALPHATEST: boolean;
  47483. DEPTHPREPASS: boolean;
  47484. ALPHABLEND: boolean;
  47485. ALPHAFROMALBEDO: boolean;
  47486. ALPHATESTVALUE: string;
  47487. SPECULAROVERALPHA: boolean;
  47488. RADIANCEOVERALPHA: boolean;
  47489. ALPHAFRESNEL: boolean;
  47490. LINEARALPHAFRESNEL: boolean;
  47491. PREMULTIPLYALPHA: boolean;
  47492. EMISSIVE: boolean;
  47493. EMISSIVEDIRECTUV: number;
  47494. REFLECTIVITY: boolean;
  47495. REFLECTIVITYDIRECTUV: number;
  47496. SPECULARTERM: boolean;
  47497. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47498. MICROSURFACEAUTOMATIC: boolean;
  47499. LODBASEDMICROSFURACE: boolean;
  47500. MICROSURFACEMAP: boolean;
  47501. MICROSURFACEMAPDIRECTUV: number;
  47502. METALLICWORKFLOW: boolean;
  47503. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47504. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47505. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47506. AOSTOREINMETALMAPRED: boolean;
  47507. ENVIRONMENTBRDF: boolean;
  47508. ENVIRONMENTBRDF_RGBD: boolean;
  47509. NORMAL: boolean;
  47510. TANGENT: boolean;
  47511. BUMP: boolean;
  47512. BUMPDIRECTUV: number;
  47513. OBJECTSPACE_NORMALMAP: boolean;
  47514. PARALLAX: boolean;
  47515. PARALLAXOCCLUSION: boolean;
  47516. NORMALXYSCALE: boolean;
  47517. LIGHTMAP: boolean;
  47518. LIGHTMAPDIRECTUV: number;
  47519. USELIGHTMAPASSHADOWMAP: boolean;
  47520. GAMMALIGHTMAP: boolean;
  47521. REFLECTION: boolean;
  47522. REFLECTIONMAP_3D: boolean;
  47523. REFLECTIONMAP_SPHERICAL: boolean;
  47524. REFLECTIONMAP_PLANAR: boolean;
  47525. REFLECTIONMAP_CUBIC: boolean;
  47526. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47527. REFLECTIONMAP_PROJECTION: boolean;
  47528. REFLECTIONMAP_SKYBOX: boolean;
  47529. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47530. REFLECTIONMAP_EXPLICIT: boolean;
  47531. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47532. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47533. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47534. INVERTCUBICMAP: boolean;
  47535. USESPHERICALFROMREFLECTIONMAP: boolean;
  47536. USEIRRADIANCEMAP: boolean;
  47537. SPHERICAL_HARMONICS: boolean;
  47538. USESPHERICALINVERTEX: boolean;
  47539. REFLECTIONMAP_OPPOSITEZ: boolean;
  47540. LODINREFLECTIONALPHA: boolean;
  47541. GAMMAREFLECTION: boolean;
  47542. RGBDREFLECTION: boolean;
  47543. LINEARSPECULARREFLECTION: boolean;
  47544. RADIANCEOCCLUSION: boolean;
  47545. HORIZONOCCLUSION: boolean;
  47546. INSTANCES: boolean;
  47547. NUM_BONE_INFLUENCERS: number;
  47548. BonesPerMesh: number;
  47549. BONETEXTURE: boolean;
  47550. NONUNIFORMSCALING: boolean;
  47551. MORPHTARGETS: boolean;
  47552. MORPHTARGETS_NORMAL: boolean;
  47553. MORPHTARGETS_TANGENT: boolean;
  47554. MORPHTARGETS_UV: boolean;
  47555. NUM_MORPH_INFLUENCERS: number;
  47556. IMAGEPROCESSING: boolean;
  47557. VIGNETTE: boolean;
  47558. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47559. VIGNETTEBLENDMODEOPAQUE: boolean;
  47560. TONEMAPPING: boolean;
  47561. TONEMAPPING_ACES: boolean;
  47562. CONTRAST: boolean;
  47563. COLORCURVES: boolean;
  47564. COLORGRADING: boolean;
  47565. COLORGRADING3D: boolean;
  47566. SAMPLER3DGREENDEPTH: boolean;
  47567. SAMPLER3DBGRMAP: boolean;
  47568. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47569. EXPOSURE: boolean;
  47570. MULTIVIEW: boolean;
  47571. USEPHYSICALLIGHTFALLOFF: boolean;
  47572. USEGLTFLIGHTFALLOFF: boolean;
  47573. TWOSIDEDLIGHTING: boolean;
  47574. SHADOWFLOAT: boolean;
  47575. CLIPPLANE: boolean;
  47576. CLIPPLANE2: boolean;
  47577. CLIPPLANE3: boolean;
  47578. CLIPPLANE4: boolean;
  47579. POINTSIZE: boolean;
  47580. FOG: boolean;
  47581. LOGARITHMICDEPTH: boolean;
  47582. FORCENORMALFORWARD: boolean;
  47583. SPECULARAA: boolean;
  47584. CLEARCOAT: boolean;
  47585. CLEARCOAT_DEFAULTIOR: boolean;
  47586. CLEARCOAT_TEXTURE: boolean;
  47587. CLEARCOAT_TEXTUREDIRECTUV: number;
  47588. CLEARCOAT_BUMP: boolean;
  47589. CLEARCOAT_BUMPDIRECTUV: number;
  47590. CLEARCOAT_TINT: boolean;
  47591. CLEARCOAT_TINT_TEXTURE: boolean;
  47592. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47593. ANISOTROPIC: boolean;
  47594. ANISOTROPIC_TEXTURE: boolean;
  47595. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47596. BRDF_V_HEIGHT_CORRELATED: boolean;
  47597. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47598. SHEEN: boolean;
  47599. SHEEN_TEXTURE: boolean;
  47600. SHEEN_TEXTUREDIRECTUV: number;
  47601. SHEEN_LINKWITHALBEDO: boolean;
  47602. SUBSURFACE: boolean;
  47603. SS_REFRACTION: boolean;
  47604. SS_TRANSLUCENCY: boolean;
  47605. SS_SCATERRING: boolean;
  47606. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47607. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47608. SS_REFRACTIONMAP_3D: boolean;
  47609. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47610. SS_LODINREFRACTIONALPHA: boolean;
  47611. SS_GAMMAREFRACTION: boolean;
  47612. SS_RGBDREFRACTION: boolean;
  47613. SS_LINEARSPECULARREFRACTION: boolean;
  47614. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47615. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47616. UNLIT: boolean;
  47617. DEBUGMODE: number;
  47618. /**
  47619. * Initializes the PBR Material defines.
  47620. */
  47621. constructor();
  47622. /**
  47623. * Resets the PBR Material defines.
  47624. */
  47625. reset(): void;
  47626. }
  47627. /**
  47628. * The Physically based material base class of BJS.
  47629. *
  47630. * This offers the main features of a standard PBR material.
  47631. * For more information, please refer to the documentation :
  47632. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47633. */
  47634. export abstract class PBRBaseMaterial extends PushMaterial {
  47635. /**
  47636. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47637. */
  47638. static readonly PBRMATERIAL_OPAQUE: number;
  47639. /**
  47640. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47641. */
  47642. static readonly PBRMATERIAL_ALPHATEST: number;
  47643. /**
  47644. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47645. */
  47646. static readonly PBRMATERIAL_ALPHABLEND: number;
  47647. /**
  47648. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47649. * They are also discarded below the alpha cutoff threshold to improve performances.
  47650. */
  47651. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47652. /**
  47653. * Defines the default value of how much AO map is occluding the analytical lights
  47654. * (point spot...).
  47655. */
  47656. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47657. /**
  47658. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47659. */
  47660. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47661. /**
  47662. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47663. * to enhance interoperability with other engines.
  47664. */
  47665. static readonly LIGHTFALLOFF_GLTF: number;
  47666. /**
  47667. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47668. * to enhance interoperability with other materials.
  47669. */
  47670. static readonly LIGHTFALLOFF_STANDARD: number;
  47671. /**
  47672. * Intensity of the direct lights e.g. the four lights available in your scene.
  47673. * This impacts both the direct diffuse and specular highlights.
  47674. */
  47675. protected _directIntensity: number;
  47676. /**
  47677. * Intensity of the emissive part of the material.
  47678. * This helps controlling the emissive effect without modifying the emissive color.
  47679. */
  47680. protected _emissiveIntensity: number;
  47681. /**
  47682. * Intensity of the environment e.g. how much the environment will light the object
  47683. * either through harmonics for rough material or through the refelction for shiny ones.
  47684. */
  47685. protected _environmentIntensity: number;
  47686. /**
  47687. * This is a special control allowing the reduction of the specular highlights coming from the
  47688. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47689. */
  47690. protected _specularIntensity: number;
  47691. /**
  47692. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47693. */
  47694. private _lightingInfos;
  47695. /**
  47696. * Debug Control allowing disabling the bump map on this material.
  47697. */
  47698. protected _disableBumpMap: boolean;
  47699. /**
  47700. * AKA Diffuse Texture in standard nomenclature.
  47701. */
  47702. protected _albedoTexture: Nullable<BaseTexture>;
  47703. /**
  47704. * AKA Occlusion Texture in other nomenclature.
  47705. */
  47706. protected _ambientTexture: Nullable<BaseTexture>;
  47707. /**
  47708. * AKA Occlusion Texture Intensity in other nomenclature.
  47709. */
  47710. protected _ambientTextureStrength: number;
  47711. /**
  47712. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47713. * 1 means it completely occludes it
  47714. * 0 mean it has no impact
  47715. */
  47716. protected _ambientTextureImpactOnAnalyticalLights: number;
  47717. /**
  47718. * Stores the alpha values in a texture.
  47719. */
  47720. protected _opacityTexture: Nullable<BaseTexture>;
  47721. /**
  47722. * Stores the reflection values in a texture.
  47723. */
  47724. protected _reflectionTexture: Nullable<BaseTexture>;
  47725. /**
  47726. * Stores the emissive values in a texture.
  47727. */
  47728. protected _emissiveTexture: Nullable<BaseTexture>;
  47729. /**
  47730. * AKA Specular texture in other nomenclature.
  47731. */
  47732. protected _reflectivityTexture: Nullable<BaseTexture>;
  47733. /**
  47734. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47735. */
  47736. protected _metallicTexture: Nullable<BaseTexture>;
  47737. /**
  47738. * Specifies the metallic scalar of the metallic/roughness workflow.
  47739. * Can also be used to scale the metalness values of the metallic texture.
  47740. */
  47741. protected _metallic: Nullable<number>;
  47742. /**
  47743. * Specifies the roughness scalar of the metallic/roughness workflow.
  47744. * Can also be used to scale the roughness values of the metallic texture.
  47745. */
  47746. protected _roughness: Nullable<number>;
  47747. /**
  47748. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47749. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47750. */
  47751. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47752. /**
  47753. * Stores surface normal data used to displace a mesh in a texture.
  47754. */
  47755. protected _bumpTexture: Nullable<BaseTexture>;
  47756. /**
  47757. * Stores the pre-calculated light information of a mesh in a texture.
  47758. */
  47759. protected _lightmapTexture: Nullable<BaseTexture>;
  47760. /**
  47761. * The color of a material in ambient lighting.
  47762. */
  47763. protected _ambientColor: Color3;
  47764. /**
  47765. * AKA Diffuse Color in other nomenclature.
  47766. */
  47767. protected _albedoColor: Color3;
  47768. /**
  47769. * AKA Specular Color in other nomenclature.
  47770. */
  47771. protected _reflectivityColor: Color3;
  47772. /**
  47773. * The color applied when light is reflected from a material.
  47774. */
  47775. protected _reflectionColor: Color3;
  47776. /**
  47777. * The color applied when light is emitted from a material.
  47778. */
  47779. protected _emissiveColor: Color3;
  47780. /**
  47781. * AKA Glossiness in other nomenclature.
  47782. */
  47783. protected _microSurface: number;
  47784. /**
  47785. * Specifies that the material will use the light map as a show map.
  47786. */
  47787. protected _useLightmapAsShadowmap: boolean;
  47788. /**
  47789. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47790. * makes the reflect vector face the model (under horizon).
  47791. */
  47792. protected _useHorizonOcclusion: boolean;
  47793. /**
  47794. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47795. * too much the area relying on ambient texture to define their ambient occlusion.
  47796. */
  47797. protected _useRadianceOcclusion: boolean;
  47798. /**
  47799. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47800. */
  47801. protected _useAlphaFromAlbedoTexture: boolean;
  47802. /**
  47803. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47804. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47805. */
  47806. protected _useSpecularOverAlpha: boolean;
  47807. /**
  47808. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47809. */
  47810. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47811. /**
  47812. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47813. */
  47814. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47815. /**
  47816. * Specifies if the metallic texture contains the roughness information in its green channel.
  47817. */
  47818. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47819. /**
  47820. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47821. */
  47822. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47823. /**
  47824. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47825. */
  47826. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47827. /**
  47828. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47829. */
  47830. protected _useAmbientInGrayScale: boolean;
  47831. /**
  47832. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47833. * The material will try to infer what glossiness each pixel should be.
  47834. */
  47835. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47836. /**
  47837. * Defines the falloff type used in this material.
  47838. * It by default is Physical.
  47839. */
  47840. protected _lightFalloff: number;
  47841. /**
  47842. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47843. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47844. */
  47845. protected _useRadianceOverAlpha: boolean;
  47846. /**
  47847. * Allows using an object space normal map (instead of tangent space).
  47848. */
  47849. protected _useObjectSpaceNormalMap: boolean;
  47850. /**
  47851. * Allows using the bump map in parallax mode.
  47852. */
  47853. protected _useParallax: boolean;
  47854. /**
  47855. * Allows using the bump map in parallax occlusion mode.
  47856. */
  47857. protected _useParallaxOcclusion: boolean;
  47858. /**
  47859. * Controls the scale bias of the parallax mode.
  47860. */
  47861. protected _parallaxScaleBias: number;
  47862. /**
  47863. * If sets to true, disables all the lights affecting the material.
  47864. */
  47865. protected _disableLighting: boolean;
  47866. /**
  47867. * Number of Simultaneous lights allowed on the material.
  47868. */
  47869. protected _maxSimultaneousLights: number;
  47870. /**
  47871. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47872. */
  47873. protected _invertNormalMapX: boolean;
  47874. /**
  47875. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47876. */
  47877. protected _invertNormalMapY: boolean;
  47878. /**
  47879. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47880. */
  47881. protected _twoSidedLighting: boolean;
  47882. /**
  47883. * Defines the alpha limits in alpha test mode.
  47884. */
  47885. protected _alphaCutOff: number;
  47886. /**
  47887. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47888. */
  47889. protected _forceAlphaTest: boolean;
  47890. /**
  47891. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47892. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47893. */
  47894. protected _useAlphaFresnel: boolean;
  47895. /**
  47896. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47897. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47898. */
  47899. protected _useLinearAlphaFresnel: boolean;
  47900. /**
  47901. * The transparency mode of the material.
  47902. */
  47903. protected _transparencyMode: Nullable<number>;
  47904. /**
  47905. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47906. * from cos thetav and roughness:
  47907. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47908. */
  47909. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47910. /**
  47911. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47912. */
  47913. protected _forceIrradianceInFragment: boolean;
  47914. /**
  47915. * Force normal to face away from face.
  47916. */
  47917. protected _forceNormalForward: boolean;
  47918. /**
  47919. * Enables specular anti aliasing in the PBR shader.
  47920. * It will both interacts on the Geometry for analytical and IBL lighting.
  47921. * It also prefilter the roughness map based on the bump values.
  47922. */
  47923. protected _enableSpecularAntiAliasing: boolean;
  47924. /**
  47925. * Default configuration related to image processing available in the PBR Material.
  47926. */
  47927. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47928. /**
  47929. * Keep track of the image processing observer to allow dispose and replace.
  47930. */
  47931. private _imageProcessingObserver;
  47932. /**
  47933. * Attaches a new image processing configuration to the PBR Material.
  47934. * @param configuration
  47935. */
  47936. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47937. /**
  47938. * Stores the available render targets.
  47939. */
  47940. private _renderTargets;
  47941. /**
  47942. * Sets the global ambient color for the material used in lighting calculations.
  47943. */
  47944. private _globalAmbientColor;
  47945. /**
  47946. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47947. */
  47948. private _useLogarithmicDepth;
  47949. /**
  47950. * If set to true, no lighting calculations will be applied.
  47951. */
  47952. private _unlit;
  47953. private _debugMode;
  47954. /**
  47955. * @hidden
  47956. * This is reserved for the inspector.
  47957. * Defines the material debug mode.
  47958. * It helps seeing only some components of the material while troubleshooting.
  47959. */
  47960. debugMode: number;
  47961. /**
  47962. * @hidden
  47963. * This is reserved for the inspector.
  47964. * Specify from where on screen the debug mode should start.
  47965. * The value goes from -1 (full screen) to 1 (not visible)
  47966. * It helps with side by side comparison against the final render
  47967. * This defaults to -1
  47968. */
  47969. private debugLimit;
  47970. /**
  47971. * @hidden
  47972. * This is reserved for the inspector.
  47973. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47974. * You can use the factor to better multiply the final value.
  47975. */
  47976. private debugFactor;
  47977. /**
  47978. * Defines the clear coat layer parameters for the material.
  47979. */
  47980. readonly clearCoat: PBRClearCoatConfiguration;
  47981. /**
  47982. * Defines the anisotropic parameters for the material.
  47983. */
  47984. readonly anisotropy: PBRAnisotropicConfiguration;
  47985. /**
  47986. * Defines the BRDF parameters for the material.
  47987. */
  47988. readonly brdf: PBRBRDFConfiguration;
  47989. /**
  47990. * Defines the Sheen parameters for the material.
  47991. */
  47992. readonly sheen: PBRSheenConfiguration;
  47993. /**
  47994. * Defines the SubSurface parameters for the material.
  47995. */
  47996. readonly subSurface: PBRSubSurfaceConfiguration;
  47997. /**
  47998. * Custom callback helping to override the default shader used in the material.
  47999. */
  48000. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48001. /**
  48002. * Instantiates a new PBRMaterial instance.
  48003. *
  48004. * @param name The material name
  48005. * @param scene The scene the material will be use in.
  48006. */
  48007. constructor(name: string, scene: Scene);
  48008. /**
  48009. * Gets a boolean indicating that current material needs to register RTT
  48010. */
  48011. readonly hasRenderTargetTextures: boolean;
  48012. /**
  48013. * Gets the name of the material class.
  48014. */
  48015. getClassName(): string;
  48016. /**
  48017. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48018. */
  48019. /**
  48020. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48021. */
  48022. useLogarithmicDepth: boolean;
  48023. /**
  48024. * Gets the current transparency mode.
  48025. */
  48026. /**
  48027. * Sets the transparency mode of the material.
  48028. *
  48029. * | Value | Type | Description |
  48030. * | ----- | ----------------------------------- | ----------- |
  48031. * | 0 | OPAQUE | |
  48032. * | 1 | ALPHATEST | |
  48033. * | 2 | ALPHABLEND | |
  48034. * | 3 | ALPHATESTANDBLEND | |
  48035. *
  48036. */
  48037. transparencyMode: Nullable<number>;
  48038. /**
  48039. * Returns true if alpha blending should be disabled.
  48040. */
  48041. private readonly _disableAlphaBlending;
  48042. /**
  48043. * Specifies whether or not this material should be rendered in alpha blend mode.
  48044. */
  48045. needAlphaBlending(): boolean;
  48046. /**
  48047. * Specifies if the mesh will require alpha blending.
  48048. * @param mesh - BJS mesh.
  48049. */
  48050. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48051. /**
  48052. * Specifies whether or not this material should be rendered in alpha test mode.
  48053. */
  48054. needAlphaTesting(): boolean;
  48055. /**
  48056. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48057. */
  48058. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48059. /**
  48060. * Gets the texture used for the alpha test.
  48061. */
  48062. getAlphaTestTexture(): Nullable<BaseTexture>;
  48063. /**
  48064. * Specifies that the submesh is ready to be used.
  48065. * @param mesh - BJS mesh.
  48066. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48067. * @param useInstances - Specifies that instances should be used.
  48068. * @returns - boolean indicating that the submesh is ready or not.
  48069. */
  48070. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48071. /**
  48072. * Specifies if the material uses metallic roughness workflow.
  48073. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48074. */
  48075. isMetallicWorkflow(): boolean;
  48076. private _prepareEffect;
  48077. private _prepareDefines;
  48078. /**
  48079. * Force shader compilation
  48080. */
  48081. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48082. clipPlane: boolean;
  48083. }>): void;
  48084. /**
  48085. * Initializes the uniform buffer layout for the shader.
  48086. */
  48087. buildUniformLayout(): void;
  48088. /**
  48089. * Unbinds the material from the mesh
  48090. */
  48091. unbind(): void;
  48092. /**
  48093. * Binds the submesh data.
  48094. * @param world - The world matrix.
  48095. * @param mesh - The BJS mesh.
  48096. * @param subMesh - A submesh of the BJS mesh.
  48097. */
  48098. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48099. /**
  48100. * Returns the animatable textures.
  48101. * @returns - Array of animatable textures.
  48102. */
  48103. getAnimatables(): IAnimatable[];
  48104. /**
  48105. * Returns the texture used for reflections.
  48106. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48107. */
  48108. private _getReflectionTexture;
  48109. /**
  48110. * Returns an array of the actively used textures.
  48111. * @returns - Array of BaseTextures
  48112. */
  48113. getActiveTextures(): BaseTexture[];
  48114. /**
  48115. * Checks to see if a texture is used in the material.
  48116. * @param texture - Base texture to use.
  48117. * @returns - Boolean specifying if a texture is used in the material.
  48118. */
  48119. hasTexture(texture: BaseTexture): boolean;
  48120. /**
  48121. * Disposes the resources of the material.
  48122. * @param forceDisposeEffect - Forces the disposal of effects.
  48123. * @param forceDisposeTextures - Forces the disposal of all textures.
  48124. */
  48125. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48126. }
  48127. }
  48128. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48129. import { Nullable } from "babylonjs/types";
  48130. import { Scene } from "babylonjs/scene";
  48131. import { Color3 } from "babylonjs/Maths/math";
  48132. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48133. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48135. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48136. /**
  48137. * The Physically based material of BJS.
  48138. *
  48139. * This offers the main features of a standard PBR material.
  48140. * For more information, please refer to the documentation :
  48141. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48142. */
  48143. export class PBRMaterial extends PBRBaseMaterial {
  48144. /**
  48145. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48146. */
  48147. static readonly PBRMATERIAL_OPAQUE: number;
  48148. /**
  48149. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48150. */
  48151. static readonly PBRMATERIAL_ALPHATEST: number;
  48152. /**
  48153. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48154. */
  48155. static readonly PBRMATERIAL_ALPHABLEND: number;
  48156. /**
  48157. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48158. * They are also discarded below the alpha cutoff threshold to improve performances.
  48159. */
  48160. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48161. /**
  48162. * Defines the default value of how much AO map is occluding the analytical lights
  48163. * (point spot...).
  48164. */
  48165. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48166. /**
  48167. * Intensity of the direct lights e.g. the four lights available in your scene.
  48168. * This impacts both the direct diffuse and specular highlights.
  48169. */
  48170. directIntensity: number;
  48171. /**
  48172. * Intensity of the emissive part of the material.
  48173. * This helps controlling the emissive effect without modifying the emissive color.
  48174. */
  48175. emissiveIntensity: number;
  48176. /**
  48177. * Intensity of the environment e.g. how much the environment will light the object
  48178. * either through harmonics for rough material or through the refelction for shiny ones.
  48179. */
  48180. environmentIntensity: number;
  48181. /**
  48182. * This is a special control allowing the reduction of the specular highlights coming from the
  48183. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48184. */
  48185. specularIntensity: number;
  48186. /**
  48187. * Debug Control allowing disabling the bump map on this material.
  48188. */
  48189. disableBumpMap: boolean;
  48190. /**
  48191. * AKA Diffuse Texture in standard nomenclature.
  48192. */
  48193. albedoTexture: BaseTexture;
  48194. /**
  48195. * AKA Occlusion Texture in other nomenclature.
  48196. */
  48197. ambientTexture: BaseTexture;
  48198. /**
  48199. * AKA Occlusion Texture Intensity in other nomenclature.
  48200. */
  48201. ambientTextureStrength: number;
  48202. /**
  48203. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48204. * 1 means it completely occludes it
  48205. * 0 mean it has no impact
  48206. */
  48207. ambientTextureImpactOnAnalyticalLights: number;
  48208. /**
  48209. * Stores the alpha values in a texture.
  48210. */
  48211. opacityTexture: BaseTexture;
  48212. /**
  48213. * Stores the reflection values in a texture.
  48214. */
  48215. reflectionTexture: Nullable<BaseTexture>;
  48216. /**
  48217. * Stores the emissive values in a texture.
  48218. */
  48219. emissiveTexture: BaseTexture;
  48220. /**
  48221. * AKA Specular texture in other nomenclature.
  48222. */
  48223. reflectivityTexture: BaseTexture;
  48224. /**
  48225. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48226. */
  48227. metallicTexture: BaseTexture;
  48228. /**
  48229. * Specifies the metallic scalar of the metallic/roughness workflow.
  48230. * Can also be used to scale the metalness values of the metallic texture.
  48231. */
  48232. metallic: Nullable<number>;
  48233. /**
  48234. * Specifies the roughness scalar of the metallic/roughness workflow.
  48235. * Can also be used to scale the roughness values of the metallic texture.
  48236. */
  48237. roughness: Nullable<number>;
  48238. /**
  48239. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48240. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48241. */
  48242. microSurfaceTexture: BaseTexture;
  48243. /**
  48244. * Stores surface normal data used to displace a mesh in a texture.
  48245. */
  48246. bumpTexture: BaseTexture;
  48247. /**
  48248. * Stores the pre-calculated light information of a mesh in a texture.
  48249. */
  48250. lightmapTexture: BaseTexture;
  48251. /**
  48252. * Stores the refracted light information in a texture.
  48253. */
  48254. refractionTexture: Nullable<BaseTexture>;
  48255. /**
  48256. * The color of a material in ambient lighting.
  48257. */
  48258. ambientColor: Color3;
  48259. /**
  48260. * AKA Diffuse Color in other nomenclature.
  48261. */
  48262. albedoColor: Color3;
  48263. /**
  48264. * AKA Specular Color in other nomenclature.
  48265. */
  48266. reflectivityColor: Color3;
  48267. /**
  48268. * The color reflected from the material.
  48269. */
  48270. reflectionColor: Color3;
  48271. /**
  48272. * The color emitted from the material.
  48273. */
  48274. emissiveColor: Color3;
  48275. /**
  48276. * AKA Glossiness in other nomenclature.
  48277. */
  48278. microSurface: number;
  48279. /**
  48280. * source material index of refraction (IOR)' / 'destination material IOR.
  48281. */
  48282. indexOfRefraction: number;
  48283. /**
  48284. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48285. */
  48286. invertRefractionY: boolean;
  48287. /**
  48288. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48289. * Materials half opaque for instance using refraction could benefit from this control.
  48290. */
  48291. linkRefractionWithTransparency: boolean;
  48292. /**
  48293. * If true, the light map contains occlusion information instead of lighting info.
  48294. */
  48295. useLightmapAsShadowmap: boolean;
  48296. /**
  48297. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48298. */
  48299. useAlphaFromAlbedoTexture: boolean;
  48300. /**
  48301. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48302. */
  48303. forceAlphaTest: boolean;
  48304. /**
  48305. * Defines the alpha limits in alpha test mode.
  48306. */
  48307. alphaCutOff: number;
  48308. /**
  48309. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48310. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48311. */
  48312. useSpecularOverAlpha: boolean;
  48313. /**
  48314. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48315. */
  48316. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48317. /**
  48318. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48319. */
  48320. useRoughnessFromMetallicTextureAlpha: boolean;
  48321. /**
  48322. * Specifies if the metallic texture contains the roughness information in its green channel.
  48323. */
  48324. useRoughnessFromMetallicTextureGreen: boolean;
  48325. /**
  48326. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48327. */
  48328. useMetallnessFromMetallicTextureBlue: boolean;
  48329. /**
  48330. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48331. */
  48332. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48333. /**
  48334. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48335. */
  48336. useAmbientInGrayScale: boolean;
  48337. /**
  48338. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48339. * The material will try to infer what glossiness each pixel should be.
  48340. */
  48341. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48342. /**
  48343. * BJS is using an harcoded light falloff based on a manually sets up range.
  48344. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48345. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48346. */
  48347. /**
  48348. * BJS is using an harcoded light falloff based on a manually sets up range.
  48349. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48350. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48351. */
  48352. usePhysicalLightFalloff: boolean;
  48353. /**
  48354. * In order to support the falloff compatibility with gltf, a special mode has been added
  48355. * to reproduce the gltf light falloff.
  48356. */
  48357. /**
  48358. * In order to support the falloff compatibility with gltf, a special mode has been added
  48359. * to reproduce the gltf light falloff.
  48360. */
  48361. useGLTFLightFalloff: boolean;
  48362. /**
  48363. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48364. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48365. */
  48366. useRadianceOverAlpha: boolean;
  48367. /**
  48368. * Allows using an object space normal map (instead of tangent space).
  48369. */
  48370. useObjectSpaceNormalMap: boolean;
  48371. /**
  48372. * Allows using the bump map in parallax mode.
  48373. */
  48374. useParallax: boolean;
  48375. /**
  48376. * Allows using the bump map in parallax occlusion mode.
  48377. */
  48378. useParallaxOcclusion: boolean;
  48379. /**
  48380. * Controls the scale bias of the parallax mode.
  48381. */
  48382. parallaxScaleBias: number;
  48383. /**
  48384. * If sets to true, disables all the lights affecting the material.
  48385. */
  48386. disableLighting: boolean;
  48387. /**
  48388. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48389. */
  48390. forceIrradianceInFragment: boolean;
  48391. /**
  48392. * Number of Simultaneous lights allowed on the material.
  48393. */
  48394. maxSimultaneousLights: number;
  48395. /**
  48396. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48397. */
  48398. invertNormalMapX: boolean;
  48399. /**
  48400. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48401. */
  48402. invertNormalMapY: boolean;
  48403. /**
  48404. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48405. */
  48406. twoSidedLighting: boolean;
  48407. /**
  48408. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48409. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48410. */
  48411. useAlphaFresnel: boolean;
  48412. /**
  48413. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48414. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48415. */
  48416. useLinearAlphaFresnel: boolean;
  48417. /**
  48418. * Let user defines the brdf lookup texture used for IBL.
  48419. * A default 8bit version is embedded but you could point at :
  48420. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48421. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48422. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48423. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48424. */
  48425. environmentBRDFTexture: Nullable<BaseTexture>;
  48426. /**
  48427. * Force normal to face away from face.
  48428. */
  48429. forceNormalForward: boolean;
  48430. /**
  48431. * Enables specular anti aliasing in the PBR shader.
  48432. * It will both interacts on the Geometry for analytical and IBL lighting.
  48433. * It also prefilter the roughness map based on the bump values.
  48434. */
  48435. enableSpecularAntiAliasing: boolean;
  48436. /**
  48437. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48438. * makes the reflect vector face the model (under horizon).
  48439. */
  48440. useHorizonOcclusion: boolean;
  48441. /**
  48442. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48443. * too much the area relying on ambient texture to define their ambient occlusion.
  48444. */
  48445. useRadianceOcclusion: boolean;
  48446. /**
  48447. * If set to true, no lighting calculations will be applied.
  48448. */
  48449. unlit: boolean;
  48450. /**
  48451. * Gets the image processing configuration used either in this material.
  48452. */
  48453. /**
  48454. * Sets the Default image processing configuration used either in the this material.
  48455. *
  48456. * If sets to null, the scene one is in use.
  48457. */
  48458. imageProcessingConfiguration: ImageProcessingConfiguration;
  48459. /**
  48460. * Gets wether the color curves effect is enabled.
  48461. */
  48462. /**
  48463. * Sets wether the color curves effect is enabled.
  48464. */
  48465. cameraColorCurvesEnabled: boolean;
  48466. /**
  48467. * Gets wether the color grading effect is enabled.
  48468. */
  48469. /**
  48470. * Gets wether the color grading effect is enabled.
  48471. */
  48472. cameraColorGradingEnabled: boolean;
  48473. /**
  48474. * Gets wether tonemapping is enabled or not.
  48475. */
  48476. /**
  48477. * Sets wether tonemapping is enabled or not
  48478. */
  48479. cameraToneMappingEnabled: boolean;
  48480. /**
  48481. * The camera exposure used on this material.
  48482. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48483. * This corresponds to a photographic exposure.
  48484. */
  48485. /**
  48486. * The camera exposure used on this material.
  48487. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48488. * This corresponds to a photographic exposure.
  48489. */
  48490. cameraExposure: number;
  48491. /**
  48492. * Gets The camera contrast used on this material.
  48493. */
  48494. /**
  48495. * Sets The camera contrast used on this material.
  48496. */
  48497. cameraContrast: number;
  48498. /**
  48499. * Gets the Color Grading 2D Lookup Texture.
  48500. */
  48501. /**
  48502. * Sets the Color Grading 2D Lookup Texture.
  48503. */
  48504. cameraColorGradingTexture: Nullable<BaseTexture>;
  48505. /**
  48506. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48507. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48508. * 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;
  48509. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48510. */
  48511. /**
  48512. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48513. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48514. * 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;
  48515. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48516. */
  48517. cameraColorCurves: Nullable<ColorCurves>;
  48518. /**
  48519. * Instantiates a new PBRMaterial instance.
  48520. *
  48521. * @param name The material name
  48522. * @param scene The scene the material will be use in.
  48523. */
  48524. constructor(name: string, scene: Scene);
  48525. /**
  48526. * Returns the name of this material class.
  48527. */
  48528. getClassName(): string;
  48529. /**
  48530. * Makes a duplicate of the current material.
  48531. * @param name - name to use for the new material.
  48532. */
  48533. clone(name: string): PBRMaterial;
  48534. /**
  48535. * Serializes this PBR Material.
  48536. * @returns - An object with the serialized material.
  48537. */
  48538. serialize(): any;
  48539. /**
  48540. * Parses a PBR Material from a serialized object.
  48541. * @param source - Serialized object.
  48542. * @param scene - BJS scene instance.
  48543. * @param rootUrl - url for the scene object
  48544. * @returns - PBRMaterial
  48545. */
  48546. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48547. }
  48548. }
  48549. declare module "babylonjs/Misc/dds" {
  48550. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48551. import { Engine } from "babylonjs/Engines/engine";
  48552. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48553. import { Nullable } from "babylonjs/types";
  48554. import { Scene } from "babylonjs/scene";
  48555. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48556. /**
  48557. * Direct draw surface info
  48558. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48559. */
  48560. export interface DDSInfo {
  48561. /**
  48562. * Width of the texture
  48563. */
  48564. width: number;
  48565. /**
  48566. * Width of the texture
  48567. */
  48568. height: number;
  48569. /**
  48570. * Number of Mipmaps for the texture
  48571. * @see https://en.wikipedia.org/wiki/Mipmap
  48572. */
  48573. mipmapCount: number;
  48574. /**
  48575. * If the textures format is a known fourCC format
  48576. * @see https://www.fourcc.org/
  48577. */
  48578. isFourCC: boolean;
  48579. /**
  48580. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48581. */
  48582. isRGB: boolean;
  48583. /**
  48584. * If the texture is a lumincance format
  48585. */
  48586. isLuminance: boolean;
  48587. /**
  48588. * If this is a cube texture
  48589. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48590. */
  48591. isCube: boolean;
  48592. /**
  48593. * If the texture is a compressed format eg. FOURCC_DXT1
  48594. */
  48595. isCompressed: boolean;
  48596. /**
  48597. * The dxgiFormat of the texture
  48598. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48599. */
  48600. dxgiFormat: number;
  48601. /**
  48602. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48603. */
  48604. textureType: number;
  48605. /**
  48606. * Sphericle polynomial created for the dds texture
  48607. */
  48608. sphericalPolynomial?: SphericalPolynomial;
  48609. }
  48610. /**
  48611. * Class used to provide DDS decompression tools
  48612. */
  48613. export class DDSTools {
  48614. /**
  48615. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48616. */
  48617. static StoreLODInAlphaChannel: boolean;
  48618. /**
  48619. * Gets DDS information from an array buffer
  48620. * @param arrayBuffer defines the array buffer to read data from
  48621. * @returns the DDS information
  48622. */
  48623. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48624. private static _FloatView;
  48625. private static _Int32View;
  48626. private static _ToHalfFloat;
  48627. private static _FromHalfFloat;
  48628. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48629. private static _GetHalfFloatRGBAArrayBuffer;
  48630. private static _GetFloatRGBAArrayBuffer;
  48631. private static _GetFloatAsUIntRGBAArrayBuffer;
  48632. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48633. private static _GetRGBAArrayBuffer;
  48634. private static _ExtractLongWordOrder;
  48635. private static _GetRGBArrayBuffer;
  48636. private static _GetLuminanceArrayBuffer;
  48637. /**
  48638. * Uploads DDS Levels to a Babylon Texture
  48639. * @hidden
  48640. */
  48641. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48642. }
  48643. module "babylonjs/Engines/engine" {
  48644. interface Engine {
  48645. /**
  48646. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48647. * @param rootUrl defines the url where the file to load is located
  48648. * @param scene defines the current scene
  48649. * @param lodScale defines scale to apply to the mip map selection
  48650. * @param lodOffset defines offset to apply to the mip map selection
  48651. * @param onLoad defines an optional callback raised when the texture is loaded
  48652. * @param onError defines an optional callback raised if there is an issue to load the texture
  48653. * @param format defines the format of the data
  48654. * @param forcedExtension defines the extension to use to pick the right loader
  48655. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48656. * @returns the cube texture as an InternalTexture
  48657. */
  48658. 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;
  48659. }
  48660. }
  48661. }
  48662. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48663. import { Nullable } from "babylonjs/types";
  48664. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48665. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48666. /**
  48667. * Implementation of the DDS Texture Loader.
  48668. * @hidden
  48669. */
  48670. export class _DDSTextureLoader implements IInternalTextureLoader {
  48671. /**
  48672. * Defines wether the loader supports cascade loading the different faces.
  48673. */
  48674. readonly supportCascades: boolean;
  48675. /**
  48676. * This returns if the loader support the current file information.
  48677. * @param extension defines the file extension of the file being loaded
  48678. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48679. * @param fallback defines the fallback internal texture if any
  48680. * @param isBase64 defines whether the texture is encoded as a base64
  48681. * @param isBuffer defines whether the texture data are stored as a buffer
  48682. * @returns true if the loader can load the specified file
  48683. */
  48684. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48685. /**
  48686. * Transform the url before loading if required.
  48687. * @param rootUrl the url of the texture
  48688. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48689. * @returns the transformed texture
  48690. */
  48691. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48692. /**
  48693. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48694. * @param rootUrl the url of the texture
  48695. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48696. * @returns the fallback texture
  48697. */
  48698. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48699. /**
  48700. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48701. * @param data contains the texture data
  48702. * @param texture defines the BabylonJS internal texture
  48703. * @param createPolynomials will be true if polynomials have been requested
  48704. * @param onLoad defines the callback to trigger once the texture is ready
  48705. * @param onError defines the callback to trigger in case of error
  48706. */
  48707. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48708. /**
  48709. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48710. * @param data contains the texture data
  48711. * @param texture defines the BabylonJS internal texture
  48712. * @param callback defines the method to call once ready to upload
  48713. */
  48714. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48715. }
  48716. }
  48717. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48718. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48719. /** @hidden */
  48720. export var rgbdEncodePixelShader: {
  48721. name: string;
  48722. shader: string;
  48723. };
  48724. }
  48725. declare module "babylonjs/Misc/environmentTextureTools" {
  48726. import { Nullable } from "babylonjs/types";
  48727. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48728. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48729. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48730. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48731. import "babylonjs/Shaders/rgbdEncode.fragment";
  48732. import "babylonjs/Shaders/rgbdDecode.fragment";
  48733. /**
  48734. * Raw texture data and descriptor sufficient for WebGL texture upload
  48735. */
  48736. export interface EnvironmentTextureInfo {
  48737. /**
  48738. * Version of the environment map
  48739. */
  48740. version: number;
  48741. /**
  48742. * Width of image
  48743. */
  48744. width: number;
  48745. /**
  48746. * Irradiance information stored in the file.
  48747. */
  48748. irradiance: any;
  48749. /**
  48750. * Specular information stored in the file.
  48751. */
  48752. specular: any;
  48753. }
  48754. /**
  48755. * Sets of helpers addressing the serialization and deserialization of environment texture
  48756. * stored in a BabylonJS env file.
  48757. * Those files are usually stored as .env files.
  48758. */
  48759. export class EnvironmentTextureTools {
  48760. /**
  48761. * Magic number identifying the env file.
  48762. */
  48763. private static _MagicBytes;
  48764. /**
  48765. * Gets the environment info from an env file.
  48766. * @param data The array buffer containing the .env bytes.
  48767. * @returns the environment file info (the json header) if successfully parsed.
  48768. */
  48769. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48770. /**
  48771. * Creates an environment texture from a loaded cube texture.
  48772. * @param texture defines the cube texture to convert in env file
  48773. * @return a promise containing the environment data if succesfull.
  48774. */
  48775. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48776. /**
  48777. * Creates a JSON representation of the spherical data.
  48778. * @param texture defines the texture containing the polynomials
  48779. * @return the JSON representation of the spherical info
  48780. */
  48781. private static _CreateEnvTextureIrradiance;
  48782. /**
  48783. * Uploads the texture info contained in the env file to the GPU.
  48784. * @param texture defines the internal texture to upload to
  48785. * @param arrayBuffer defines the buffer cotaining the data to load
  48786. * @param info defines the texture info retrieved through the GetEnvInfo method
  48787. * @returns a promise
  48788. */
  48789. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48790. /**
  48791. * Uploads the levels of image data to the GPU.
  48792. * @param texture defines the internal texture to upload to
  48793. * @param imageData defines the array buffer views of image data [mipmap][face]
  48794. * @returns a promise
  48795. */
  48796. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48797. /**
  48798. * Uploads spherical polynomials information to the texture.
  48799. * @param texture defines the texture we are trying to upload the information to
  48800. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48801. */
  48802. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48803. /** @hidden */
  48804. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48805. }
  48806. }
  48807. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48808. import { Nullable } from "babylonjs/types";
  48809. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48810. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48811. /**
  48812. * Implementation of the ENV Texture Loader.
  48813. * @hidden
  48814. */
  48815. export class _ENVTextureLoader implements IInternalTextureLoader {
  48816. /**
  48817. * Defines wether the loader supports cascade loading the different faces.
  48818. */
  48819. readonly supportCascades: boolean;
  48820. /**
  48821. * This returns if the loader support the current file information.
  48822. * @param extension defines the file extension of the file being loaded
  48823. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48824. * @param fallback defines the fallback internal texture if any
  48825. * @param isBase64 defines whether the texture is encoded as a base64
  48826. * @param isBuffer defines whether the texture data are stored as a buffer
  48827. * @returns true if the loader can load the specified file
  48828. */
  48829. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48830. /**
  48831. * Transform the url before loading if required.
  48832. * @param rootUrl the url of the texture
  48833. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48834. * @returns the transformed texture
  48835. */
  48836. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48837. /**
  48838. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48839. * @param rootUrl the url of the texture
  48840. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48841. * @returns the fallback texture
  48842. */
  48843. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48844. /**
  48845. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48846. * @param data contains the texture data
  48847. * @param texture defines the BabylonJS internal texture
  48848. * @param createPolynomials will be true if polynomials have been requested
  48849. * @param onLoad defines the callback to trigger once the texture is ready
  48850. * @param onError defines the callback to trigger in case of error
  48851. */
  48852. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48853. /**
  48854. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48855. * @param data contains the texture data
  48856. * @param texture defines the BabylonJS internal texture
  48857. * @param callback defines the method to call once ready to upload
  48858. */
  48859. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48860. }
  48861. }
  48862. declare module "babylonjs/Misc/khronosTextureContainer" {
  48863. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48864. /**
  48865. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48866. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48867. */
  48868. export class KhronosTextureContainer {
  48869. /** contents of the KTX container file */
  48870. arrayBuffer: any;
  48871. private static HEADER_LEN;
  48872. private static COMPRESSED_2D;
  48873. private static COMPRESSED_3D;
  48874. private static TEX_2D;
  48875. private static TEX_3D;
  48876. /**
  48877. * Gets the openGL type
  48878. */
  48879. glType: number;
  48880. /**
  48881. * Gets the openGL type size
  48882. */
  48883. glTypeSize: number;
  48884. /**
  48885. * Gets the openGL format
  48886. */
  48887. glFormat: number;
  48888. /**
  48889. * Gets the openGL internal format
  48890. */
  48891. glInternalFormat: number;
  48892. /**
  48893. * Gets the base internal format
  48894. */
  48895. glBaseInternalFormat: number;
  48896. /**
  48897. * Gets image width in pixel
  48898. */
  48899. pixelWidth: number;
  48900. /**
  48901. * Gets image height in pixel
  48902. */
  48903. pixelHeight: number;
  48904. /**
  48905. * Gets image depth in pixels
  48906. */
  48907. pixelDepth: number;
  48908. /**
  48909. * Gets the number of array elements
  48910. */
  48911. numberOfArrayElements: number;
  48912. /**
  48913. * Gets the number of faces
  48914. */
  48915. numberOfFaces: number;
  48916. /**
  48917. * Gets the number of mipmap levels
  48918. */
  48919. numberOfMipmapLevels: number;
  48920. /**
  48921. * Gets the bytes of key value data
  48922. */
  48923. bytesOfKeyValueData: number;
  48924. /**
  48925. * Gets the load type
  48926. */
  48927. loadType: number;
  48928. /**
  48929. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48930. */
  48931. isInvalid: boolean;
  48932. /**
  48933. * Creates a new KhronosTextureContainer
  48934. * @param arrayBuffer contents of the KTX container file
  48935. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48936. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48937. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48938. */
  48939. constructor(
  48940. /** contents of the KTX container file */
  48941. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48942. /**
  48943. * Uploads KTX content to a Babylon Texture.
  48944. * It is assumed that the texture has already been created & is currently bound
  48945. * @hidden
  48946. */
  48947. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48948. private _upload2DCompressedLevels;
  48949. }
  48950. }
  48951. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48952. import { Nullable } from "babylonjs/types";
  48953. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48954. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48955. /**
  48956. * Implementation of the KTX Texture Loader.
  48957. * @hidden
  48958. */
  48959. export class _KTXTextureLoader implements IInternalTextureLoader {
  48960. /**
  48961. * Defines wether the loader supports cascade loading the different faces.
  48962. */
  48963. readonly supportCascades: boolean;
  48964. /**
  48965. * This returns if the loader support the current file information.
  48966. * @param extension defines the file extension of the file being loaded
  48967. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48968. * @param fallback defines the fallback internal texture if any
  48969. * @param isBase64 defines whether the texture is encoded as a base64
  48970. * @param isBuffer defines whether the texture data are stored as a buffer
  48971. * @returns true if the loader can load the specified file
  48972. */
  48973. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48974. /**
  48975. * Transform the url before loading if required.
  48976. * @param rootUrl the url of the texture
  48977. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48978. * @returns the transformed texture
  48979. */
  48980. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48981. /**
  48982. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48983. * @param rootUrl the url of the texture
  48984. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48985. * @returns the fallback texture
  48986. */
  48987. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48988. /**
  48989. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48990. * @param data contains the texture data
  48991. * @param texture defines the BabylonJS internal texture
  48992. * @param createPolynomials will be true if polynomials have been requested
  48993. * @param onLoad defines the callback to trigger once the texture is ready
  48994. * @param onError defines the callback to trigger in case of error
  48995. */
  48996. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48997. /**
  48998. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48999. * @param data contains the texture data
  49000. * @param texture defines the BabylonJS internal texture
  49001. * @param callback defines the method to call once ready to upload
  49002. */
  49003. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49004. }
  49005. }
  49006. declare module "babylonjs/Helpers/sceneHelpers" {
  49007. import { Nullable } from "babylonjs/types";
  49008. import { Mesh } from "babylonjs/Meshes/mesh";
  49009. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49010. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49011. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49012. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49013. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49014. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49015. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49016. import "babylonjs/Meshes/Builders/boxBuilder";
  49017. /** @hidden */
  49018. export var _forceSceneHelpersToBundle: boolean;
  49019. module "babylonjs/scene" {
  49020. interface Scene {
  49021. /**
  49022. * Creates a default light for the scene.
  49023. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49024. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49025. */
  49026. createDefaultLight(replace?: boolean): void;
  49027. /**
  49028. * Creates a default camera for the scene.
  49029. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49030. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49031. * @param replace has default false, when true replaces the active camera in the scene
  49032. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49033. */
  49034. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49035. /**
  49036. * Creates a default camera and a default light.
  49037. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49038. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49039. * @param replace has the default false, when true replaces the active camera/light in the scene
  49040. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49041. */
  49042. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49043. /**
  49044. * Creates a new sky box
  49045. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49046. * @param environmentTexture defines the texture to use as environment texture
  49047. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49048. * @param scale defines the overall scale of the skybox
  49049. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49050. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49051. * @returns a new mesh holding the sky box
  49052. */
  49053. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49054. /**
  49055. * Creates a new environment
  49056. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49057. * @param options defines the options you can use to configure the environment
  49058. * @returns the new EnvironmentHelper
  49059. */
  49060. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49061. /**
  49062. * Creates a new VREXperienceHelper
  49063. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49064. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49065. * @returns a new VREXperienceHelper
  49066. */
  49067. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49068. /**
  49069. * Creates a new XREXperienceHelper
  49070. * @see http://doc.babylonjs.com/how_to/webxr
  49071. * @returns a promise for a new XREXperienceHelper
  49072. */
  49073. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  49074. }
  49075. }
  49076. }
  49077. declare module "babylonjs/Helpers/videoDome" {
  49078. import { Scene } from "babylonjs/scene";
  49079. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49080. import { Mesh } from "babylonjs/Meshes/mesh";
  49081. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49082. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49083. import "babylonjs/Meshes/Builders/sphereBuilder";
  49084. /**
  49085. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49086. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49087. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49088. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49089. */
  49090. export class VideoDome extends TransformNode {
  49091. /**
  49092. * Define the video source as a Monoscopic panoramic 360 video.
  49093. */
  49094. static readonly MODE_MONOSCOPIC: number;
  49095. /**
  49096. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49097. */
  49098. static readonly MODE_TOPBOTTOM: number;
  49099. /**
  49100. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49101. */
  49102. static readonly MODE_SIDEBYSIDE: number;
  49103. private _useDirectMapping;
  49104. /**
  49105. * The video texture being displayed on the sphere
  49106. */
  49107. protected _videoTexture: VideoTexture;
  49108. /**
  49109. * Gets the video texture being displayed on the sphere
  49110. */
  49111. readonly videoTexture: VideoTexture;
  49112. /**
  49113. * The skybox material
  49114. */
  49115. protected _material: BackgroundMaterial;
  49116. /**
  49117. * The surface used for the skybox
  49118. */
  49119. protected _mesh: Mesh;
  49120. /**
  49121. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49122. * Also see the options.resolution property.
  49123. */
  49124. fovMultiplier: number;
  49125. private _videoMode;
  49126. /**
  49127. * Gets or set the current video mode for the video. It can be:
  49128. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49129. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49130. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49131. */
  49132. videoMode: number;
  49133. /**
  49134. * Oberserver used in Stereoscopic VR Mode.
  49135. */
  49136. private _onBeforeCameraRenderObserver;
  49137. /**
  49138. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49139. * @param name Element's name, child elements will append suffixes for their own names.
  49140. * @param urlsOrVideo defines the url(s) or the video element to use
  49141. * @param options An object containing optional or exposed sub element properties
  49142. */
  49143. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49144. resolution?: number;
  49145. clickToPlay?: boolean;
  49146. autoPlay?: boolean;
  49147. loop?: boolean;
  49148. size?: number;
  49149. poster?: string;
  49150. faceForward?: boolean;
  49151. useDirectMapping?: boolean;
  49152. }, scene: Scene);
  49153. private _changeVideoMode;
  49154. /**
  49155. * Releases resources associated with this node.
  49156. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49157. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49158. */
  49159. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49160. }
  49161. }
  49162. declare module "babylonjs/Helpers/index" {
  49163. export * from "babylonjs/Helpers/environmentHelper";
  49164. export * from "babylonjs/Helpers/photoDome";
  49165. export * from "babylonjs/Helpers/sceneHelpers";
  49166. export * from "babylonjs/Helpers/videoDome";
  49167. }
  49168. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49169. import { PerfCounter } from "babylonjs/Misc/tools";
  49170. import { IDisposable } from "babylonjs/scene";
  49171. import { Engine } from "babylonjs/Engines/engine";
  49172. /**
  49173. * This class can be used to get instrumentation data from a Babylon engine
  49174. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49175. */
  49176. export class EngineInstrumentation implements IDisposable {
  49177. /**
  49178. * Define the instrumented engine.
  49179. */
  49180. engine: Engine;
  49181. private _captureGPUFrameTime;
  49182. private _gpuFrameTimeToken;
  49183. private _gpuFrameTime;
  49184. private _captureShaderCompilationTime;
  49185. private _shaderCompilationTime;
  49186. private _onBeginFrameObserver;
  49187. private _onEndFrameObserver;
  49188. private _onBeforeShaderCompilationObserver;
  49189. private _onAfterShaderCompilationObserver;
  49190. /**
  49191. * Gets the perf counter used for GPU frame time
  49192. */
  49193. readonly gpuFrameTimeCounter: PerfCounter;
  49194. /**
  49195. * Gets the GPU frame time capture status
  49196. */
  49197. /**
  49198. * Enable or disable the GPU frame time capture
  49199. */
  49200. captureGPUFrameTime: boolean;
  49201. /**
  49202. * Gets the perf counter used for shader compilation time
  49203. */
  49204. readonly shaderCompilationTimeCounter: PerfCounter;
  49205. /**
  49206. * Gets the shader compilation time capture status
  49207. */
  49208. /**
  49209. * Enable or disable the shader compilation time capture
  49210. */
  49211. captureShaderCompilationTime: boolean;
  49212. /**
  49213. * Instantiates a new engine instrumentation.
  49214. * This class can be used to get instrumentation data from a Babylon engine
  49215. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49216. * @param engine Defines the engine to instrument
  49217. */
  49218. constructor(
  49219. /**
  49220. * Define the instrumented engine.
  49221. */
  49222. engine: Engine);
  49223. /**
  49224. * Dispose and release associated resources.
  49225. */
  49226. dispose(): void;
  49227. }
  49228. }
  49229. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49230. import { PerfCounter } from "babylonjs/Misc/tools";
  49231. import { Scene, IDisposable } from "babylonjs/scene";
  49232. /**
  49233. * This class can be used to get instrumentation data from a Babylon engine
  49234. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49235. */
  49236. export class SceneInstrumentation implements IDisposable {
  49237. /**
  49238. * Defines the scene to instrument
  49239. */
  49240. scene: Scene;
  49241. private _captureActiveMeshesEvaluationTime;
  49242. private _activeMeshesEvaluationTime;
  49243. private _captureRenderTargetsRenderTime;
  49244. private _renderTargetsRenderTime;
  49245. private _captureFrameTime;
  49246. private _frameTime;
  49247. private _captureRenderTime;
  49248. private _renderTime;
  49249. private _captureInterFrameTime;
  49250. private _interFrameTime;
  49251. private _captureParticlesRenderTime;
  49252. private _particlesRenderTime;
  49253. private _captureSpritesRenderTime;
  49254. private _spritesRenderTime;
  49255. private _capturePhysicsTime;
  49256. private _physicsTime;
  49257. private _captureAnimationsTime;
  49258. private _animationsTime;
  49259. private _captureCameraRenderTime;
  49260. private _cameraRenderTime;
  49261. private _onBeforeActiveMeshesEvaluationObserver;
  49262. private _onAfterActiveMeshesEvaluationObserver;
  49263. private _onBeforeRenderTargetsRenderObserver;
  49264. private _onAfterRenderTargetsRenderObserver;
  49265. private _onAfterRenderObserver;
  49266. private _onBeforeDrawPhaseObserver;
  49267. private _onAfterDrawPhaseObserver;
  49268. private _onBeforeAnimationsObserver;
  49269. private _onBeforeParticlesRenderingObserver;
  49270. private _onAfterParticlesRenderingObserver;
  49271. private _onBeforeSpritesRenderingObserver;
  49272. private _onAfterSpritesRenderingObserver;
  49273. private _onBeforePhysicsObserver;
  49274. private _onAfterPhysicsObserver;
  49275. private _onAfterAnimationsObserver;
  49276. private _onBeforeCameraRenderObserver;
  49277. private _onAfterCameraRenderObserver;
  49278. /**
  49279. * Gets the perf counter used for active meshes evaluation time
  49280. */
  49281. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49282. /**
  49283. * Gets the active meshes evaluation time capture status
  49284. */
  49285. /**
  49286. * Enable or disable the active meshes evaluation time capture
  49287. */
  49288. captureActiveMeshesEvaluationTime: boolean;
  49289. /**
  49290. * Gets the perf counter used for render targets render time
  49291. */
  49292. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49293. /**
  49294. * Gets the render targets render time capture status
  49295. */
  49296. /**
  49297. * Enable or disable the render targets render time capture
  49298. */
  49299. captureRenderTargetsRenderTime: boolean;
  49300. /**
  49301. * Gets the perf counter used for particles render time
  49302. */
  49303. readonly particlesRenderTimeCounter: PerfCounter;
  49304. /**
  49305. * Gets the particles render time capture status
  49306. */
  49307. /**
  49308. * Enable or disable the particles render time capture
  49309. */
  49310. captureParticlesRenderTime: boolean;
  49311. /**
  49312. * Gets the perf counter used for sprites render time
  49313. */
  49314. readonly spritesRenderTimeCounter: PerfCounter;
  49315. /**
  49316. * Gets the sprites render time capture status
  49317. */
  49318. /**
  49319. * Enable or disable the sprites render time capture
  49320. */
  49321. captureSpritesRenderTime: boolean;
  49322. /**
  49323. * Gets the perf counter used for physics time
  49324. */
  49325. readonly physicsTimeCounter: PerfCounter;
  49326. /**
  49327. * Gets the physics time capture status
  49328. */
  49329. /**
  49330. * Enable or disable the physics time capture
  49331. */
  49332. capturePhysicsTime: boolean;
  49333. /**
  49334. * Gets the perf counter used for animations time
  49335. */
  49336. readonly animationsTimeCounter: PerfCounter;
  49337. /**
  49338. * Gets the animations time capture status
  49339. */
  49340. /**
  49341. * Enable or disable the animations time capture
  49342. */
  49343. captureAnimationsTime: boolean;
  49344. /**
  49345. * Gets the perf counter used for frame time capture
  49346. */
  49347. readonly frameTimeCounter: PerfCounter;
  49348. /**
  49349. * Gets the frame time capture status
  49350. */
  49351. /**
  49352. * Enable or disable the frame time capture
  49353. */
  49354. captureFrameTime: boolean;
  49355. /**
  49356. * Gets the perf counter used for inter-frames time capture
  49357. */
  49358. readonly interFrameTimeCounter: PerfCounter;
  49359. /**
  49360. * Gets the inter-frames time capture status
  49361. */
  49362. /**
  49363. * Enable or disable the inter-frames time capture
  49364. */
  49365. captureInterFrameTime: boolean;
  49366. /**
  49367. * Gets the perf counter used for render time capture
  49368. */
  49369. readonly renderTimeCounter: PerfCounter;
  49370. /**
  49371. * Gets the render time capture status
  49372. */
  49373. /**
  49374. * Enable or disable the render time capture
  49375. */
  49376. captureRenderTime: boolean;
  49377. /**
  49378. * Gets the perf counter used for camera render time capture
  49379. */
  49380. readonly cameraRenderTimeCounter: PerfCounter;
  49381. /**
  49382. * Gets the camera render time capture status
  49383. */
  49384. /**
  49385. * Enable or disable the camera render time capture
  49386. */
  49387. captureCameraRenderTime: boolean;
  49388. /**
  49389. * Gets the perf counter used for draw calls
  49390. */
  49391. readonly drawCallsCounter: PerfCounter;
  49392. /**
  49393. * Instantiates a new scene instrumentation.
  49394. * This class can be used to get instrumentation data from a Babylon engine
  49395. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49396. * @param scene Defines the scene to instrument
  49397. */
  49398. constructor(
  49399. /**
  49400. * Defines the scene to instrument
  49401. */
  49402. scene: Scene);
  49403. /**
  49404. * Dispose and release associated resources.
  49405. */
  49406. dispose(): void;
  49407. }
  49408. }
  49409. declare module "babylonjs/Instrumentation/index" {
  49410. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49411. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49412. export * from "babylonjs/Instrumentation/timeToken";
  49413. }
  49414. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49415. /** @hidden */
  49416. export var glowMapGenerationPixelShader: {
  49417. name: string;
  49418. shader: string;
  49419. };
  49420. }
  49421. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49422. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49423. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49424. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49425. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49427. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49428. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49429. /** @hidden */
  49430. export var glowMapGenerationVertexShader: {
  49431. name: string;
  49432. shader: string;
  49433. };
  49434. }
  49435. declare module "babylonjs/Layers/effectLayer" {
  49436. import { Observable } from "babylonjs/Misc/observable";
  49437. import { Nullable } from "babylonjs/types";
  49438. import { Camera } from "babylonjs/Cameras/camera";
  49439. import { Scene } from "babylonjs/scene";
  49440. import { Color4, ISize } from "babylonjs/Maths/math";
  49441. import { Engine } from "babylonjs/Engines/engine";
  49442. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49444. import { Mesh } from "babylonjs/Meshes/mesh";
  49445. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49446. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49447. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49448. import { Effect } from "babylonjs/Materials/effect";
  49449. import { Material } from "babylonjs/Materials/material";
  49450. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49451. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49452. /**
  49453. * Effect layer options. This helps customizing the behaviour
  49454. * of the effect layer.
  49455. */
  49456. export interface IEffectLayerOptions {
  49457. /**
  49458. * Multiplication factor apply to the canvas size to compute the render target size
  49459. * used to generated the objects (the smaller the faster).
  49460. */
  49461. mainTextureRatio: number;
  49462. /**
  49463. * Enforces a fixed size texture to ensure effect stability across devices.
  49464. */
  49465. mainTextureFixedSize?: number;
  49466. /**
  49467. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49468. */
  49469. alphaBlendingMode: number;
  49470. /**
  49471. * The camera attached to the layer.
  49472. */
  49473. camera: Nullable<Camera>;
  49474. /**
  49475. * The rendering group to draw the layer in.
  49476. */
  49477. renderingGroupId: number;
  49478. }
  49479. /**
  49480. * The effect layer Helps adding post process effect blended with the main pass.
  49481. *
  49482. * This can be for instance use to generate glow or higlight effects on the scene.
  49483. *
  49484. * The effect layer class can not be used directly and is intented to inherited from to be
  49485. * customized per effects.
  49486. */
  49487. export abstract class EffectLayer {
  49488. private _vertexBuffers;
  49489. private _indexBuffer;
  49490. private _cachedDefines;
  49491. private _effectLayerMapGenerationEffect;
  49492. private _effectLayerOptions;
  49493. private _mergeEffect;
  49494. protected _scene: Scene;
  49495. protected _engine: Engine;
  49496. protected _maxSize: number;
  49497. protected _mainTextureDesiredSize: ISize;
  49498. protected _mainTexture: RenderTargetTexture;
  49499. protected _shouldRender: boolean;
  49500. protected _postProcesses: PostProcess[];
  49501. protected _textures: BaseTexture[];
  49502. protected _emissiveTextureAndColor: {
  49503. texture: Nullable<BaseTexture>;
  49504. color: Color4;
  49505. };
  49506. /**
  49507. * The name of the layer
  49508. */
  49509. name: string;
  49510. /**
  49511. * The clear color of the texture used to generate the glow map.
  49512. */
  49513. neutralColor: Color4;
  49514. /**
  49515. * Specifies wether the highlight layer is enabled or not.
  49516. */
  49517. isEnabled: boolean;
  49518. /**
  49519. * Gets the camera attached to the layer.
  49520. */
  49521. readonly camera: Nullable<Camera>;
  49522. /**
  49523. * Gets the rendering group id the layer should render in.
  49524. */
  49525. renderingGroupId: number;
  49526. /**
  49527. * An event triggered when the effect layer has been disposed.
  49528. */
  49529. onDisposeObservable: Observable<EffectLayer>;
  49530. /**
  49531. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49532. */
  49533. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49534. /**
  49535. * An event triggered when the generated texture is being merged in the scene.
  49536. */
  49537. onBeforeComposeObservable: Observable<EffectLayer>;
  49538. /**
  49539. * An event triggered when the generated texture has been merged in the scene.
  49540. */
  49541. onAfterComposeObservable: Observable<EffectLayer>;
  49542. /**
  49543. * An event triggered when the efffect layer changes its size.
  49544. */
  49545. onSizeChangedObservable: Observable<EffectLayer>;
  49546. /** @hidden */
  49547. static _SceneComponentInitialization: (scene: Scene) => void;
  49548. /**
  49549. * Instantiates a new effect Layer and references it in the scene.
  49550. * @param name The name of the layer
  49551. * @param scene The scene to use the layer in
  49552. */
  49553. constructor(
  49554. /** The Friendly of the effect in the scene */
  49555. name: string, scene: Scene);
  49556. /**
  49557. * Get the effect name of the layer.
  49558. * @return The effect name
  49559. */
  49560. abstract getEffectName(): string;
  49561. /**
  49562. * Checks for the readiness of the element composing the layer.
  49563. * @param subMesh the mesh to check for
  49564. * @param useInstances specify wether or not to use instances to render the mesh
  49565. * @return true if ready otherwise, false
  49566. */
  49567. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49568. /**
  49569. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49570. * @returns true if the effect requires stencil during the main canvas render pass.
  49571. */
  49572. abstract needStencil(): boolean;
  49573. /**
  49574. * Create the merge effect. This is the shader use to blit the information back
  49575. * to the main canvas at the end of the scene rendering.
  49576. * @returns The effect containing the shader used to merge the effect on the main canvas
  49577. */
  49578. protected abstract _createMergeEffect(): Effect;
  49579. /**
  49580. * Creates the render target textures and post processes used in the effect layer.
  49581. */
  49582. protected abstract _createTextureAndPostProcesses(): void;
  49583. /**
  49584. * Implementation specific of rendering the generating effect on the main canvas.
  49585. * @param effect The effect used to render through
  49586. */
  49587. protected abstract _internalRender(effect: Effect): void;
  49588. /**
  49589. * Sets the required values for both the emissive texture and and the main color.
  49590. */
  49591. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49592. /**
  49593. * Free any resources and references associated to a mesh.
  49594. * Internal use
  49595. * @param mesh The mesh to free.
  49596. */
  49597. abstract _disposeMesh(mesh: Mesh): void;
  49598. /**
  49599. * Serializes this layer (Glow or Highlight for example)
  49600. * @returns a serialized layer object
  49601. */
  49602. abstract serialize?(): any;
  49603. /**
  49604. * Initializes the effect layer with the required options.
  49605. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49606. */
  49607. protected _init(options: Partial<IEffectLayerOptions>): void;
  49608. /**
  49609. * Generates the index buffer of the full screen quad blending to the main canvas.
  49610. */
  49611. private _generateIndexBuffer;
  49612. /**
  49613. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49614. */
  49615. private _generateVertexBuffer;
  49616. /**
  49617. * Sets the main texture desired size which is the closest power of two
  49618. * of the engine canvas size.
  49619. */
  49620. private _setMainTextureSize;
  49621. /**
  49622. * Creates the main texture for the effect layer.
  49623. */
  49624. protected _createMainTexture(): void;
  49625. /**
  49626. * Adds specific effects defines.
  49627. * @param defines The defines to add specifics to.
  49628. */
  49629. protected _addCustomEffectDefines(defines: string[]): void;
  49630. /**
  49631. * Checks for the readiness of the element composing the layer.
  49632. * @param subMesh the mesh to check for
  49633. * @param useInstances specify wether or not to use instances to render the mesh
  49634. * @param emissiveTexture the associated emissive texture used to generate the glow
  49635. * @return true if ready otherwise, false
  49636. */
  49637. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49638. /**
  49639. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49640. */
  49641. render(): void;
  49642. /**
  49643. * Determine if a given mesh will be used in the current effect.
  49644. * @param mesh mesh to test
  49645. * @returns true if the mesh will be used
  49646. */
  49647. hasMesh(mesh: AbstractMesh): boolean;
  49648. /**
  49649. * Returns true if the layer contains information to display, otherwise false.
  49650. * @returns true if the glow layer should be rendered
  49651. */
  49652. shouldRender(): boolean;
  49653. /**
  49654. * Returns true if the mesh should render, otherwise false.
  49655. * @param mesh The mesh to render
  49656. * @returns true if it should render otherwise false
  49657. */
  49658. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49659. /**
  49660. * Returns true if the mesh can be rendered, otherwise false.
  49661. * @param mesh The mesh to render
  49662. * @param material The material used on the mesh
  49663. * @returns true if it can be rendered otherwise false
  49664. */
  49665. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49666. /**
  49667. * Returns true if the mesh should render, otherwise false.
  49668. * @param mesh The mesh to render
  49669. * @returns true if it should render otherwise false
  49670. */
  49671. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49672. /**
  49673. * Renders the submesh passed in parameter to the generation map.
  49674. */
  49675. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49676. /**
  49677. * Rebuild the required buffers.
  49678. * @hidden Internal use only.
  49679. */
  49680. _rebuild(): void;
  49681. /**
  49682. * Dispose only the render target textures and post process.
  49683. */
  49684. private _disposeTextureAndPostProcesses;
  49685. /**
  49686. * Dispose the highlight layer and free resources.
  49687. */
  49688. dispose(): void;
  49689. /**
  49690. * Gets the class name of the effect layer
  49691. * @returns the string with the class name of the effect layer
  49692. */
  49693. getClassName(): string;
  49694. /**
  49695. * Creates an effect layer from parsed effect layer data
  49696. * @param parsedEffectLayer defines effect layer data
  49697. * @param scene defines the current scene
  49698. * @param rootUrl defines the root URL containing the effect layer information
  49699. * @returns a parsed effect Layer
  49700. */
  49701. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49702. }
  49703. }
  49704. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49705. import { Scene } from "babylonjs/scene";
  49706. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49707. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49708. import { AbstractScene } from "babylonjs/abstractScene";
  49709. module "babylonjs/abstractScene" {
  49710. interface AbstractScene {
  49711. /**
  49712. * The list of effect layers (highlights/glow) added to the scene
  49713. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49714. * @see http://doc.babylonjs.com/how_to/glow_layer
  49715. */
  49716. effectLayers: Array<EffectLayer>;
  49717. /**
  49718. * Removes the given effect layer from this scene.
  49719. * @param toRemove defines the effect layer to remove
  49720. * @returns the index of the removed effect layer
  49721. */
  49722. removeEffectLayer(toRemove: EffectLayer): number;
  49723. /**
  49724. * Adds the given effect layer to this scene
  49725. * @param newEffectLayer defines the effect layer to add
  49726. */
  49727. addEffectLayer(newEffectLayer: EffectLayer): void;
  49728. }
  49729. }
  49730. /**
  49731. * Defines the layer scene component responsible to manage any effect layers
  49732. * in a given scene.
  49733. */
  49734. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49735. /**
  49736. * The component name helpfull to identify the component in the list of scene components.
  49737. */
  49738. readonly name: string;
  49739. /**
  49740. * The scene the component belongs to.
  49741. */
  49742. scene: Scene;
  49743. private _engine;
  49744. private _renderEffects;
  49745. private _needStencil;
  49746. private _previousStencilState;
  49747. /**
  49748. * Creates a new instance of the component for the given scene
  49749. * @param scene Defines the scene to register the component in
  49750. */
  49751. constructor(scene: Scene);
  49752. /**
  49753. * Registers the component in a given scene
  49754. */
  49755. register(): void;
  49756. /**
  49757. * Rebuilds the elements related to this component in case of
  49758. * context lost for instance.
  49759. */
  49760. rebuild(): void;
  49761. /**
  49762. * Serializes the component data to the specified json object
  49763. * @param serializationObject The object to serialize to
  49764. */
  49765. serialize(serializationObject: any): void;
  49766. /**
  49767. * Adds all the elements from the container to the scene
  49768. * @param container the container holding the elements
  49769. */
  49770. addFromContainer(container: AbstractScene): void;
  49771. /**
  49772. * Removes all the elements in the container from the scene
  49773. * @param container contains the elements to remove
  49774. * @param dispose if the removed element should be disposed (default: false)
  49775. */
  49776. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49777. /**
  49778. * Disposes the component and the associated ressources.
  49779. */
  49780. dispose(): void;
  49781. private _isReadyForMesh;
  49782. private _renderMainTexture;
  49783. private _setStencil;
  49784. private _setStencilBack;
  49785. private _draw;
  49786. private _drawCamera;
  49787. private _drawRenderingGroup;
  49788. }
  49789. }
  49790. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49791. /** @hidden */
  49792. export var glowMapMergePixelShader: {
  49793. name: string;
  49794. shader: string;
  49795. };
  49796. }
  49797. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49798. /** @hidden */
  49799. export var glowMapMergeVertexShader: {
  49800. name: string;
  49801. shader: string;
  49802. };
  49803. }
  49804. declare module "babylonjs/Layers/glowLayer" {
  49805. import { Nullable } from "babylonjs/types";
  49806. import { Camera } from "babylonjs/Cameras/camera";
  49807. import { Scene } from "babylonjs/scene";
  49808. import { Color4 } from "babylonjs/Maths/math";
  49809. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49811. import { Mesh } from "babylonjs/Meshes/mesh";
  49812. import { Texture } from "babylonjs/Materials/Textures/texture";
  49813. import { Effect } from "babylonjs/Materials/effect";
  49814. import { Material } from "babylonjs/Materials/material";
  49815. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49816. import "babylonjs/Shaders/glowMapMerge.fragment";
  49817. import "babylonjs/Shaders/glowMapMerge.vertex";
  49818. import "babylonjs/Layers/effectLayerSceneComponent";
  49819. module "babylonjs/abstractScene" {
  49820. interface AbstractScene {
  49821. /**
  49822. * Return a the first highlight layer of the scene with a given name.
  49823. * @param name The name of the highlight layer to look for.
  49824. * @return The highlight layer if found otherwise null.
  49825. */
  49826. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49827. }
  49828. }
  49829. /**
  49830. * Glow layer options. This helps customizing the behaviour
  49831. * of the glow layer.
  49832. */
  49833. export interface IGlowLayerOptions {
  49834. /**
  49835. * Multiplication factor apply to the canvas size to compute the render target size
  49836. * used to generated the glowing objects (the smaller the faster).
  49837. */
  49838. mainTextureRatio: number;
  49839. /**
  49840. * Enforces a fixed size texture to ensure resize independant blur.
  49841. */
  49842. mainTextureFixedSize?: number;
  49843. /**
  49844. * How big is the kernel of the blur texture.
  49845. */
  49846. blurKernelSize: number;
  49847. /**
  49848. * The camera attached to the layer.
  49849. */
  49850. camera: Nullable<Camera>;
  49851. /**
  49852. * Enable MSAA by chosing the number of samples.
  49853. */
  49854. mainTextureSamples?: number;
  49855. /**
  49856. * The rendering group to draw the layer in.
  49857. */
  49858. renderingGroupId: number;
  49859. }
  49860. /**
  49861. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49862. *
  49863. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49864. * glowy meshes to your scene.
  49865. *
  49866. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49867. */
  49868. export class GlowLayer extends EffectLayer {
  49869. /**
  49870. * Effect Name of the layer.
  49871. */
  49872. static readonly EffectName: string;
  49873. /**
  49874. * The default blur kernel size used for the glow.
  49875. */
  49876. static DefaultBlurKernelSize: number;
  49877. /**
  49878. * The default texture size ratio used for the glow.
  49879. */
  49880. static DefaultTextureRatio: number;
  49881. /**
  49882. * Sets the kernel size of the blur.
  49883. */
  49884. /**
  49885. * Gets the kernel size of the blur.
  49886. */
  49887. blurKernelSize: number;
  49888. /**
  49889. * Sets the glow intensity.
  49890. */
  49891. /**
  49892. * Gets the glow intensity.
  49893. */
  49894. intensity: number;
  49895. private _options;
  49896. private _intensity;
  49897. private _horizontalBlurPostprocess1;
  49898. private _verticalBlurPostprocess1;
  49899. private _horizontalBlurPostprocess2;
  49900. private _verticalBlurPostprocess2;
  49901. private _blurTexture1;
  49902. private _blurTexture2;
  49903. private _postProcesses1;
  49904. private _postProcesses2;
  49905. private _includedOnlyMeshes;
  49906. private _excludedMeshes;
  49907. /**
  49908. * Callback used to let the user override the color selection on a per mesh basis
  49909. */
  49910. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49911. /**
  49912. * Callback used to let the user override the texture selection on a per mesh basis
  49913. */
  49914. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49915. /**
  49916. * Instantiates a new glow Layer and references it to the scene.
  49917. * @param name The name of the layer
  49918. * @param scene The scene to use the layer in
  49919. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49920. */
  49921. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49922. /**
  49923. * Get the effect name of the layer.
  49924. * @return The effect name
  49925. */
  49926. getEffectName(): string;
  49927. /**
  49928. * Create the merge effect. This is the shader use to blit the information back
  49929. * to the main canvas at the end of the scene rendering.
  49930. */
  49931. protected _createMergeEffect(): Effect;
  49932. /**
  49933. * Creates the render target textures and post processes used in the glow layer.
  49934. */
  49935. protected _createTextureAndPostProcesses(): void;
  49936. /**
  49937. * Checks for the readiness of the element composing the layer.
  49938. * @param subMesh the mesh to check for
  49939. * @param useInstances specify wether or not to use instances to render the mesh
  49940. * @param emissiveTexture the associated emissive texture used to generate the glow
  49941. * @return true if ready otherwise, false
  49942. */
  49943. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49944. /**
  49945. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49946. */
  49947. needStencil(): boolean;
  49948. /**
  49949. * Returns true if the mesh can be rendered, otherwise false.
  49950. * @param mesh The mesh to render
  49951. * @param material The material used on the mesh
  49952. * @returns true if it can be rendered otherwise false
  49953. */
  49954. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49955. /**
  49956. * Implementation specific of rendering the generating effect on the main canvas.
  49957. * @param effect The effect used to render through
  49958. */
  49959. protected _internalRender(effect: Effect): void;
  49960. /**
  49961. * Sets the required values for both the emissive texture and and the main color.
  49962. */
  49963. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49964. /**
  49965. * Returns true if the mesh should render, otherwise false.
  49966. * @param mesh The mesh to render
  49967. * @returns true if it should render otherwise false
  49968. */
  49969. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49970. /**
  49971. * Adds specific effects defines.
  49972. * @param defines The defines to add specifics to.
  49973. */
  49974. protected _addCustomEffectDefines(defines: string[]): void;
  49975. /**
  49976. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49977. * @param mesh The mesh to exclude from the glow layer
  49978. */
  49979. addExcludedMesh(mesh: Mesh): void;
  49980. /**
  49981. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49982. * @param mesh The mesh to remove
  49983. */
  49984. removeExcludedMesh(mesh: Mesh): void;
  49985. /**
  49986. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49987. * @param mesh The mesh to include in the glow layer
  49988. */
  49989. addIncludedOnlyMesh(mesh: Mesh): void;
  49990. /**
  49991. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49992. * @param mesh The mesh to remove
  49993. */
  49994. removeIncludedOnlyMesh(mesh: Mesh): void;
  49995. /**
  49996. * Determine if a given mesh will be used in the glow layer
  49997. * @param mesh The mesh to test
  49998. * @returns true if the mesh will be highlighted by the current glow layer
  49999. */
  50000. hasMesh(mesh: AbstractMesh): boolean;
  50001. /**
  50002. * Free any resources and references associated to a mesh.
  50003. * Internal use
  50004. * @param mesh The mesh to free.
  50005. * @hidden
  50006. */
  50007. _disposeMesh(mesh: Mesh): void;
  50008. /**
  50009. * Gets the class name of the effect layer
  50010. * @returns the string with the class name of the effect layer
  50011. */
  50012. getClassName(): string;
  50013. /**
  50014. * Serializes this glow layer
  50015. * @returns a serialized glow layer object
  50016. */
  50017. serialize(): any;
  50018. /**
  50019. * Creates a Glow Layer from parsed glow layer data
  50020. * @param parsedGlowLayer defines glow layer data
  50021. * @param scene defines the current scene
  50022. * @param rootUrl defines the root URL containing the glow layer information
  50023. * @returns a parsed Glow Layer
  50024. */
  50025. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50026. }
  50027. }
  50028. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50029. /** @hidden */
  50030. export var glowBlurPostProcessPixelShader: {
  50031. name: string;
  50032. shader: string;
  50033. };
  50034. }
  50035. declare module "babylonjs/Layers/highlightLayer" {
  50036. import { Observable } from "babylonjs/Misc/observable";
  50037. import { Nullable } from "babylonjs/types";
  50038. import { Camera } from "babylonjs/Cameras/camera";
  50039. import { Scene } from "babylonjs/scene";
  50040. import { Color3, Color4 } from "babylonjs/Maths/math";
  50041. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50043. import { Mesh } from "babylonjs/Meshes/mesh";
  50044. import { Effect } from "babylonjs/Materials/effect";
  50045. import { Material } from "babylonjs/Materials/material";
  50046. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50047. import "babylonjs/Shaders/glowMapMerge.fragment";
  50048. import "babylonjs/Shaders/glowMapMerge.vertex";
  50049. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50050. module "babylonjs/abstractScene" {
  50051. interface AbstractScene {
  50052. /**
  50053. * Return a the first highlight layer of the scene with a given name.
  50054. * @param name The name of the highlight layer to look for.
  50055. * @return The highlight layer if found otherwise null.
  50056. */
  50057. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50058. }
  50059. }
  50060. /**
  50061. * Highlight layer options. This helps customizing the behaviour
  50062. * of the highlight layer.
  50063. */
  50064. export interface IHighlightLayerOptions {
  50065. /**
  50066. * Multiplication factor apply to the canvas size to compute the render target size
  50067. * used to generated the glowing objects (the smaller the faster).
  50068. */
  50069. mainTextureRatio: number;
  50070. /**
  50071. * Enforces a fixed size texture to ensure resize independant blur.
  50072. */
  50073. mainTextureFixedSize?: number;
  50074. /**
  50075. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50076. * of the picture to blur (the smaller the faster).
  50077. */
  50078. blurTextureSizeRatio: number;
  50079. /**
  50080. * How big in texel of the blur texture is the vertical blur.
  50081. */
  50082. blurVerticalSize: number;
  50083. /**
  50084. * How big in texel of the blur texture is the horizontal blur.
  50085. */
  50086. blurHorizontalSize: number;
  50087. /**
  50088. * Alpha blending mode used to apply the blur. Default is combine.
  50089. */
  50090. alphaBlendingMode: number;
  50091. /**
  50092. * The camera attached to the layer.
  50093. */
  50094. camera: Nullable<Camera>;
  50095. /**
  50096. * Should we display highlight as a solid stroke?
  50097. */
  50098. isStroke?: boolean;
  50099. /**
  50100. * The rendering group to draw the layer in.
  50101. */
  50102. renderingGroupId: number;
  50103. }
  50104. /**
  50105. * The highlight layer Helps adding a glow effect around a mesh.
  50106. *
  50107. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50108. * glowy meshes to your scene.
  50109. *
  50110. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50111. */
  50112. export class HighlightLayer extends EffectLayer {
  50113. name: string;
  50114. /**
  50115. * Effect Name of the highlight layer.
  50116. */
  50117. static readonly EffectName: string;
  50118. /**
  50119. * The neutral color used during the preparation of the glow effect.
  50120. * This is black by default as the blend operation is a blend operation.
  50121. */
  50122. static NeutralColor: Color4;
  50123. /**
  50124. * Stencil value used for glowing meshes.
  50125. */
  50126. static GlowingMeshStencilReference: number;
  50127. /**
  50128. * Stencil value used for the other meshes in the scene.
  50129. */
  50130. static NormalMeshStencilReference: number;
  50131. /**
  50132. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50133. */
  50134. innerGlow: boolean;
  50135. /**
  50136. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50137. */
  50138. outerGlow: boolean;
  50139. /**
  50140. * Specifies the horizontal size of the blur.
  50141. */
  50142. /**
  50143. * Gets the horizontal size of the blur.
  50144. */
  50145. blurHorizontalSize: number;
  50146. /**
  50147. * Specifies the vertical size of the blur.
  50148. */
  50149. /**
  50150. * Gets the vertical size of the blur.
  50151. */
  50152. blurVerticalSize: number;
  50153. /**
  50154. * An event triggered when the highlight layer is being blurred.
  50155. */
  50156. onBeforeBlurObservable: Observable<HighlightLayer>;
  50157. /**
  50158. * An event triggered when the highlight layer has been blurred.
  50159. */
  50160. onAfterBlurObservable: Observable<HighlightLayer>;
  50161. private _instanceGlowingMeshStencilReference;
  50162. private _options;
  50163. private _downSamplePostprocess;
  50164. private _horizontalBlurPostprocess;
  50165. private _verticalBlurPostprocess;
  50166. private _blurTexture;
  50167. private _meshes;
  50168. private _excludedMeshes;
  50169. /**
  50170. * Instantiates a new highlight Layer and references it to the scene..
  50171. * @param name The name of the layer
  50172. * @param scene The scene to use the layer in
  50173. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50174. */
  50175. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50176. /**
  50177. * Get the effect name of the layer.
  50178. * @return The effect name
  50179. */
  50180. getEffectName(): string;
  50181. /**
  50182. * Create the merge effect. This is the shader use to blit the information back
  50183. * to the main canvas at the end of the scene rendering.
  50184. */
  50185. protected _createMergeEffect(): Effect;
  50186. /**
  50187. * Creates the render target textures and post processes used in the highlight layer.
  50188. */
  50189. protected _createTextureAndPostProcesses(): void;
  50190. /**
  50191. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50192. */
  50193. needStencil(): boolean;
  50194. /**
  50195. * Checks for the readiness of the element composing the layer.
  50196. * @param subMesh the mesh to check for
  50197. * @param useInstances specify wether or not to use instances to render the mesh
  50198. * @param emissiveTexture the associated emissive texture used to generate the glow
  50199. * @return true if ready otherwise, false
  50200. */
  50201. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50202. /**
  50203. * Implementation specific of rendering the generating effect on the main canvas.
  50204. * @param effect The effect used to render through
  50205. */
  50206. protected _internalRender(effect: Effect): void;
  50207. /**
  50208. * Returns true if the layer contains information to display, otherwise false.
  50209. */
  50210. shouldRender(): boolean;
  50211. /**
  50212. * Returns true if the mesh should render, otherwise false.
  50213. * @param mesh The mesh to render
  50214. * @returns true if it should render otherwise false
  50215. */
  50216. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50217. /**
  50218. * Sets the required values for both the emissive texture and and the main color.
  50219. */
  50220. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50221. /**
  50222. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50223. * @param mesh The mesh to exclude from the highlight layer
  50224. */
  50225. addExcludedMesh(mesh: Mesh): void;
  50226. /**
  50227. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50228. * @param mesh The mesh to highlight
  50229. */
  50230. removeExcludedMesh(mesh: Mesh): void;
  50231. /**
  50232. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50233. * @param mesh mesh to test
  50234. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50235. */
  50236. hasMesh(mesh: AbstractMesh): boolean;
  50237. /**
  50238. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50239. * @param mesh The mesh to highlight
  50240. * @param color The color of the highlight
  50241. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50242. */
  50243. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50244. /**
  50245. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50246. * @param mesh The mesh to highlight
  50247. */
  50248. removeMesh(mesh: Mesh): void;
  50249. /**
  50250. * Force the stencil to the normal expected value for none glowing parts
  50251. */
  50252. private _defaultStencilReference;
  50253. /**
  50254. * Free any resources and references associated to a mesh.
  50255. * Internal use
  50256. * @param mesh The mesh to free.
  50257. * @hidden
  50258. */
  50259. _disposeMesh(mesh: Mesh): void;
  50260. /**
  50261. * Dispose the highlight layer and free resources.
  50262. */
  50263. dispose(): void;
  50264. /**
  50265. * Gets the class name of the effect layer
  50266. * @returns the string with the class name of the effect layer
  50267. */
  50268. getClassName(): string;
  50269. /**
  50270. * Serializes this Highlight layer
  50271. * @returns a serialized Highlight layer object
  50272. */
  50273. serialize(): any;
  50274. /**
  50275. * Creates a Highlight layer from parsed Highlight layer data
  50276. * @param parsedHightlightLayer defines the Highlight layer data
  50277. * @param scene defines the current scene
  50278. * @param rootUrl defines the root URL containing the Highlight layer information
  50279. * @returns a parsed Highlight layer
  50280. */
  50281. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50282. }
  50283. }
  50284. declare module "babylonjs/Layers/layerSceneComponent" {
  50285. import { Scene } from "babylonjs/scene";
  50286. import { ISceneComponent } from "babylonjs/sceneComponent";
  50287. import { Layer } from "babylonjs/Layers/layer";
  50288. import { AbstractScene } from "babylonjs/abstractScene";
  50289. module "babylonjs/abstractScene" {
  50290. interface AbstractScene {
  50291. /**
  50292. * The list of layers (background and foreground) of the scene
  50293. */
  50294. layers: Array<Layer>;
  50295. }
  50296. }
  50297. /**
  50298. * Defines the layer scene component responsible to manage any layers
  50299. * in a given scene.
  50300. */
  50301. export class LayerSceneComponent implements ISceneComponent {
  50302. /**
  50303. * The component name helpfull to identify the component in the list of scene components.
  50304. */
  50305. readonly name: string;
  50306. /**
  50307. * The scene the component belongs to.
  50308. */
  50309. scene: Scene;
  50310. private _engine;
  50311. /**
  50312. * Creates a new instance of the component for the given scene
  50313. * @param scene Defines the scene to register the component in
  50314. */
  50315. constructor(scene: Scene);
  50316. /**
  50317. * Registers the component in a given scene
  50318. */
  50319. register(): void;
  50320. /**
  50321. * Rebuilds the elements related to this component in case of
  50322. * context lost for instance.
  50323. */
  50324. rebuild(): void;
  50325. /**
  50326. * Disposes the component and the associated ressources.
  50327. */
  50328. dispose(): void;
  50329. private _draw;
  50330. private _drawCameraPredicate;
  50331. private _drawCameraBackground;
  50332. private _drawCameraForeground;
  50333. private _drawRenderTargetPredicate;
  50334. private _drawRenderTargetBackground;
  50335. private _drawRenderTargetForeground;
  50336. /**
  50337. * Adds all the elements from the container to the scene
  50338. * @param container the container holding the elements
  50339. */
  50340. addFromContainer(container: AbstractScene): void;
  50341. /**
  50342. * Removes all the elements in the container from the scene
  50343. * @param container contains the elements to remove
  50344. * @param dispose if the removed element should be disposed (default: false)
  50345. */
  50346. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50347. }
  50348. }
  50349. declare module "babylonjs/Shaders/layer.fragment" {
  50350. /** @hidden */
  50351. export var layerPixelShader: {
  50352. name: string;
  50353. shader: string;
  50354. };
  50355. }
  50356. declare module "babylonjs/Shaders/layer.vertex" {
  50357. /** @hidden */
  50358. export var layerVertexShader: {
  50359. name: string;
  50360. shader: string;
  50361. };
  50362. }
  50363. declare module "babylonjs/Layers/layer" {
  50364. import { Observable } from "babylonjs/Misc/observable";
  50365. import { Nullable } from "babylonjs/types";
  50366. import { Scene } from "babylonjs/scene";
  50367. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50368. import { Texture } from "babylonjs/Materials/Textures/texture";
  50369. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50370. import "babylonjs/Shaders/layer.fragment";
  50371. import "babylonjs/Shaders/layer.vertex";
  50372. /**
  50373. * This represents a full screen 2d layer.
  50374. * This can be useful to display a picture in the background of your scene for instance.
  50375. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50376. */
  50377. export class Layer {
  50378. /**
  50379. * Define the name of the layer.
  50380. */
  50381. name: string;
  50382. /**
  50383. * Define the texture the layer should display.
  50384. */
  50385. texture: Nullable<Texture>;
  50386. /**
  50387. * Is the layer in background or foreground.
  50388. */
  50389. isBackground: boolean;
  50390. /**
  50391. * Define the color of the layer (instead of texture).
  50392. */
  50393. color: Color4;
  50394. /**
  50395. * Define the scale of the layer in order to zoom in out of the texture.
  50396. */
  50397. scale: Vector2;
  50398. /**
  50399. * Define an offset for the layer in order to shift the texture.
  50400. */
  50401. offset: Vector2;
  50402. /**
  50403. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50404. */
  50405. alphaBlendingMode: number;
  50406. /**
  50407. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50408. * Alpha test will not mix with the background color in case of transparency.
  50409. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50410. */
  50411. alphaTest: boolean;
  50412. /**
  50413. * Define a mask to restrict the layer to only some of the scene cameras.
  50414. */
  50415. layerMask: number;
  50416. /**
  50417. * Define the list of render target the layer is visible into.
  50418. */
  50419. renderTargetTextures: RenderTargetTexture[];
  50420. /**
  50421. * Define if the layer is only used in renderTarget or if it also
  50422. * renders in the main frame buffer of the canvas.
  50423. */
  50424. renderOnlyInRenderTargetTextures: boolean;
  50425. private _scene;
  50426. private _vertexBuffers;
  50427. private _indexBuffer;
  50428. private _effect;
  50429. private _alphaTestEffect;
  50430. /**
  50431. * An event triggered when the layer is disposed.
  50432. */
  50433. onDisposeObservable: Observable<Layer>;
  50434. private _onDisposeObserver;
  50435. /**
  50436. * Back compatibility with callback before the onDisposeObservable existed.
  50437. * The set callback will be triggered when the layer has been disposed.
  50438. */
  50439. onDispose: () => void;
  50440. /**
  50441. * An event triggered before rendering the scene
  50442. */
  50443. onBeforeRenderObservable: Observable<Layer>;
  50444. private _onBeforeRenderObserver;
  50445. /**
  50446. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50447. * The set callback will be triggered just before rendering the layer.
  50448. */
  50449. onBeforeRender: () => void;
  50450. /**
  50451. * An event triggered after rendering the scene
  50452. */
  50453. onAfterRenderObservable: Observable<Layer>;
  50454. private _onAfterRenderObserver;
  50455. /**
  50456. * Back compatibility with callback before the onAfterRenderObservable existed.
  50457. * The set callback will be triggered just after rendering the layer.
  50458. */
  50459. onAfterRender: () => void;
  50460. /**
  50461. * Instantiates a new layer.
  50462. * This represents a full screen 2d layer.
  50463. * This can be useful to display a picture in the background of your scene for instance.
  50464. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50465. * @param name Define the name of the layer in the scene
  50466. * @param imgUrl Define the url of the texture to display in the layer
  50467. * @param scene Define the scene the layer belongs to
  50468. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50469. * @param color Defines a color for the layer
  50470. */
  50471. constructor(
  50472. /**
  50473. * Define the name of the layer.
  50474. */
  50475. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50476. private _createIndexBuffer;
  50477. /** @hidden */
  50478. _rebuild(): void;
  50479. /**
  50480. * Renders the layer in the scene.
  50481. */
  50482. render(): void;
  50483. /**
  50484. * Disposes and releases the associated ressources.
  50485. */
  50486. dispose(): void;
  50487. }
  50488. }
  50489. declare module "babylonjs/Layers/index" {
  50490. export * from "babylonjs/Layers/effectLayer";
  50491. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50492. export * from "babylonjs/Layers/glowLayer";
  50493. export * from "babylonjs/Layers/highlightLayer";
  50494. export * from "babylonjs/Layers/layer";
  50495. export * from "babylonjs/Layers/layerSceneComponent";
  50496. }
  50497. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50498. /** @hidden */
  50499. export var lensFlarePixelShader: {
  50500. name: string;
  50501. shader: string;
  50502. };
  50503. }
  50504. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50505. /** @hidden */
  50506. export var lensFlareVertexShader: {
  50507. name: string;
  50508. shader: string;
  50509. };
  50510. }
  50511. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50512. import { Scene } from "babylonjs/scene";
  50513. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50515. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50516. import "babylonjs/Shaders/lensFlare.fragment";
  50517. import "babylonjs/Shaders/lensFlare.vertex";
  50518. /**
  50519. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50520. * It is usually composed of several `lensFlare`.
  50521. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50522. */
  50523. export class LensFlareSystem {
  50524. /**
  50525. * Define the name of the lens flare system
  50526. */
  50527. name: string;
  50528. /**
  50529. * List of lens flares used in this system.
  50530. */
  50531. lensFlares: LensFlare[];
  50532. /**
  50533. * Define a limit from the border the lens flare can be visible.
  50534. */
  50535. borderLimit: number;
  50536. /**
  50537. * Define a viewport border we do not want to see the lens flare in.
  50538. */
  50539. viewportBorder: number;
  50540. /**
  50541. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50542. */
  50543. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50544. /**
  50545. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50546. */
  50547. layerMask: number;
  50548. /**
  50549. * Define the id of the lens flare system in the scene.
  50550. * (equal to name by default)
  50551. */
  50552. id: string;
  50553. private _scene;
  50554. private _emitter;
  50555. private _vertexBuffers;
  50556. private _indexBuffer;
  50557. private _effect;
  50558. private _positionX;
  50559. private _positionY;
  50560. private _isEnabled;
  50561. /** @hidden */
  50562. static _SceneComponentInitialization: (scene: Scene) => void;
  50563. /**
  50564. * Instantiates a lens flare system.
  50565. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50566. * It is usually composed of several `lensFlare`.
  50567. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50568. * @param name Define the name of the lens flare system in the scene
  50569. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50570. * @param scene Define the scene the lens flare system belongs to
  50571. */
  50572. constructor(
  50573. /**
  50574. * Define the name of the lens flare system
  50575. */
  50576. name: string, emitter: any, scene: Scene);
  50577. /**
  50578. * Define if the lens flare system is enabled.
  50579. */
  50580. isEnabled: boolean;
  50581. /**
  50582. * Get the scene the effects belongs to.
  50583. * @returns the scene holding the lens flare system
  50584. */
  50585. getScene(): Scene;
  50586. /**
  50587. * Get the emitter of the lens flare system.
  50588. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50589. * @returns the emitter of the lens flare system
  50590. */
  50591. getEmitter(): any;
  50592. /**
  50593. * Set the emitter of the lens flare system.
  50594. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50595. * @param newEmitter Define the new emitter of the system
  50596. */
  50597. setEmitter(newEmitter: any): void;
  50598. /**
  50599. * Get the lens flare system emitter position.
  50600. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50601. * @returns the position
  50602. */
  50603. getEmitterPosition(): Vector3;
  50604. /**
  50605. * @hidden
  50606. */
  50607. computeEffectivePosition(globalViewport: Viewport): boolean;
  50608. /** @hidden */
  50609. _isVisible(): boolean;
  50610. /**
  50611. * @hidden
  50612. */
  50613. render(): boolean;
  50614. /**
  50615. * Dispose and release the lens flare with its associated resources.
  50616. */
  50617. dispose(): void;
  50618. /**
  50619. * Parse a lens flare system from a JSON repressentation
  50620. * @param parsedLensFlareSystem Define the JSON to parse
  50621. * @param scene Define the scene the parsed system should be instantiated in
  50622. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50623. * @returns the parsed system
  50624. */
  50625. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50626. /**
  50627. * Serialize the current Lens Flare System into a JSON representation.
  50628. * @returns the serialized JSON
  50629. */
  50630. serialize(): any;
  50631. }
  50632. }
  50633. declare module "babylonjs/LensFlares/lensFlare" {
  50634. import { Nullable } from "babylonjs/types";
  50635. import { Color3 } from "babylonjs/Maths/math";
  50636. import { Texture } from "babylonjs/Materials/Textures/texture";
  50637. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50638. /**
  50639. * This represents one of the lens effect in a `lensFlareSystem`.
  50640. * It controls one of the indiviual texture used in the effect.
  50641. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50642. */
  50643. export class LensFlare {
  50644. /**
  50645. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50646. */
  50647. size: number;
  50648. /**
  50649. * 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.
  50650. */
  50651. position: number;
  50652. /**
  50653. * Define the lens color.
  50654. */
  50655. color: Color3;
  50656. /**
  50657. * Define the lens texture.
  50658. */
  50659. texture: Nullable<Texture>;
  50660. /**
  50661. * Define the alpha mode to render this particular lens.
  50662. */
  50663. alphaMode: number;
  50664. private _system;
  50665. /**
  50666. * Creates a new Lens Flare.
  50667. * This represents one of the lens effect in a `lensFlareSystem`.
  50668. * It controls one of the indiviual texture used in the effect.
  50669. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50670. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50671. * @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.
  50672. * @param color Define the lens color
  50673. * @param imgUrl Define the lens texture url
  50674. * @param system Define the `lensFlareSystem` this flare is part of
  50675. * @returns The newly created Lens Flare
  50676. */
  50677. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50678. /**
  50679. * Instantiates a new Lens Flare.
  50680. * This represents one of the lens effect in a `lensFlareSystem`.
  50681. * It controls one of the indiviual texture used in the effect.
  50682. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50683. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50684. * @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.
  50685. * @param color Define the lens color
  50686. * @param imgUrl Define the lens texture url
  50687. * @param system Define the `lensFlareSystem` this flare is part of
  50688. */
  50689. constructor(
  50690. /**
  50691. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50692. */
  50693. size: number,
  50694. /**
  50695. * 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.
  50696. */
  50697. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50698. /**
  50699. * Dispose and release the lens flare with its associated resources.
  50700. */
  50701. dispose(): void;
  50702. }
  50703. }
  50704. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50705. import { Nullable } from "babylonjs/types";
  50706. import { Scene } from "babylonjs/scene";
  50707. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50708. import { AbstractScene } from "babylonjs/abstractScene";
  50709. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50710. module "babylonjs/abstractScene" {
  50711. interface AbstractScene {
  50712. /**
  50713. * The list of lens flare system added to the scene
  50714. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50715. */
  50716. lensFlareSystems: Array<LensFlareSystem>;
  50717. /**
  50718. * Removes the given lens flare system from this scene.
  50719. * @param toRemove The lens flare system to remove
  50720. * @returns The index of the removed lens flare system
  50721. */
  50722. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50723. /**
  50724. * Adds the given lens flare system to this scene
  50725. * @param newLensFlareSystem The lens flare system to add
  50726. */
  50727. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50728. /**
  50729. * Gets a lens flare system using its name
  50730. * @param name defines the name to look for
  50731. * @returns the lens flare system or null if not found
  50732. */
  50733. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50734. /**
  50735. * Gets a lens flare system using its id
  50736. * @param id defines the id to look for
  50737. * @returns the lens flare system or null if not found
  50738. */
  50739. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50740. }
  50741. }
  50742. /**
  50743. * Defines the lens flare scene component responsible to manage any lens flares
  50744. * in a given scene.
  50745. */
  50746. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50747. /**
  50748. * The component name helpfull to identify the component in the list of scene components.
  50749. */
  50750. readonly name: string;
  50751. /**
  50752. * The scene the component belongs to.
  50753. */
  50754. scene: Scene;
  50755. /**
  50756. * Creates a new instance of the component for the given scene
  50757. * @param scene Defines the scene to register the component in
  50758. */
  50759. constructor(scene: Scene);
  50760. /**
  50761. * Registers the component in a given scene
  50762. */
  50763. register(): void;
  50764. /**
  50765. * Rebuilds the elements related to this component in case of
  50766. * context lost for instance.
  50767. */
  50768. rebuild(): void;
  50769. /**
  50770. * Adds all the elements from the container to the scene
  50771. * @param container the container holding the elements
  50772. */
  50773. addFromContainer(container: AbstractScene): void;
  50774. /**
  50775. * Removes all the elements in the container from the scene
  50776. * @param container contains the elements to remove
  50777. * @param dispose if the removed element should be disposed (default: false)
  50778. */
  50779. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50780. /**
  50781. * Serializes the component data to the specified json object
  50782. * @param serializationObject The object to serialize to
  50783. */
  50784. serialize(serializationObject: any): void;
  50785. /**
  50786. * Disposes the component and the associated ressources.
  50787. */
  50788. dispose(): void;
  50789. private _draw;
  50790. }
  50791. }
  50792. declare module "babylonjs/LensFlares/index" {
  50793. export * from "babylonjs/LensFlares/lensFlare";
  50794. export * from "babylonjs/LensFlares/lensFlareSystem";
  50795. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50796. }
  50797. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50798. import { Scene } from "babylonjs/scene";
  50799. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50800. import { AbstractScene } from "babylonjs/abstractScene";
  50801. /**
  50802. * Defines the shadow generator component responsible to manage any shadow generators
  50803. * in a given scene.
  50804. */
  50805. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50806. /**
  50807. * The component name helpfull to identify the component in the list of scene components.
  50808. */
  50809. readonly name: string;
  50810. /**
  50811. * The scene the component belongs to.
  50812. */
  50813. scene: Scene;
  50814. /**
  50815. * Creates a new instance of the component for the given scene
  50816. * @param scene Defines the scene to register the component in
  50817. */
  50818. constructor(scene: Scene);
  50819. /**
  50820. * Registers the component in a given scene
  50821. */
  50822. register(): void;
  50823. /**
  50824. * Rebuilds the elements related to this component in case of
  50825. * context lost for instance.
  50826. */
  50827. rebuild(): void;
  50828. /**
  50829. * Serializes the component data to the specified json object
  50830. * @param serializationObject The object to serialize to
  50831. */
  50832. serialize(serializationObject: any): void;
  50833. /**
  50834. * Adds all the elements from the container to the scene
  50835. * @param container the container holding the elements
  50836. */
  50837. addFromContainer(container: AbstractScene): void;
  50838. /**
  50839. * Removes all the elements in the container from the scene
  50840. * @param container contains the elements to remove
  50841. * @param dispose if the removed element should be disposed (default: false)
  50842. */
  50843. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50844. /**
  50845. * Rebuilds the elements related to this component in case of
  50846. * context lost for instance.
  50847. */
  50848. dispose(): void;
  50849. private _gatherRenderTargets;
  50850. }
  50851. }
  50852. declare module "babylonjs/Lights/Shadows/index" {
  50853. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50854. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50855. }
  50856. declare module "babylonjs/Lights/pointLight" {
  50857. import { Scene } from "babylonjs/scene";
  50858. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50860. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50861. import { Effect } from "babylonjs/Materials/effect";
  50862. /**
  50863. * A point light is a light defined by an unique point in world space.
  50864. * The light is emitted in every direction from this point.
  50865. * A good example of a point light is a standard light bulb.
  50866. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50867. */
  50868. export class PointLight extends ShadowLight {
  50869. private _shadowAngle;
  50870. /**
  50871. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50872. * This specifies what angle the shadow will use to be created.
  50873. *
  50874. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50875. */
  50876. /**
  50877. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50878. * This specifies what angle the shadow will use to be created.
  50879. *
  50880. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50881. */
  50882. shadowAngle: number;
  50883. /**
  50884. * Gets the direction if it has been set.
  50885. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50886. */
  50887. /**
  50888. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50889. */
  50890. direction: Vector3;
  50891. /**
  50892. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50893. * A PointLight emits the light in every direction.
  50894. * It can cast shadows.
  50895. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50896. * ```javascript
  50897. * var pointLight = new PointLight("pl", camera.position, scene);
  50898. * ```
  50899. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50900. * @param name The light friendly name
  50901. * @param position The position of the point light in the scene
  50902. * @param scene The scene the lights belongs to
  50903. */
  50904. constructor(name: string, position: Vector3, scene: Scene);
  50905. /**
  50906. * Returns the string "PointLight"
  50907. * @returns the class name
  50908. */
  50909. getClassName(): string;
  50910. /**
  50911. * Returns the integer 0.
  50912. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50913. */
  50914. getTypeID(): number;
  50915. /**
  50916. * Specifies wether or not the shadowmap should be a cube texture.
  50917. * @returns true if the shadowmap needs to be a cube texture.
  50918. */
  50919. needCube(): boolean;
  50920. /**
  50921. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50922. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50923. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50924. */
  50925. getShadowDirection(faceIndex?: number): Vector3;
  50926. /**
  50927. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50928. * - fov = PI / 2
  50929. * - aspect ratio : 1.0
  50930. * - z-near and far equal to the active camera minZ and maxZ.
  50931. * Returns the PointLight.
  50932. */
  50933. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50934. protected _buildUniformLayout(): void;
  50935. /**
  50936. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50937. * @param effect The effect to update
  50938. * @param lightIndex The index of the light in the effect to update
  50939. * @returns The point light
  50940. */
  50941. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50942. /**
  50943. * Prepares the list of defines specific to the light type.
  50944. * @param defines the list of defines
  50945. * @param lightIndex defines the index of the light for the effect
  50946. */
  50947. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50948. }
  50949. }
  50950. declare module "babylonjs/Lights/index" {
  50951. export * from "babylonjs/Lights/light";
  50952. export * from "babylonjs/Lights/shadowLight";
  50953. export * from "babylonjs/Lights/Shadows/index";
  50954. export * from "babylonjs/Lights/directionalLight";
  50955. export * from "babylonjs/Lights/hemisphericLight";
  50956. export * from "babylonjs/Lights/pointLight";
  50957. export * from "babylonjs/Lights/spotLight";
  50958. }
  50959. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50960. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50961. /**
  50962. * Header information of HDR texture files.
  50963. */
  50964. export interface HDRInfo {
  50965. /**
  50966. * The height of the texture in pixels.
  50967. */
  50968. height: number;
  50969. /**
  50970. * The width of the texture in pixels.
  50971. */
  50972. width: number;
  50973. /**
  50974. * The index of the beginning of the data in the binary file.
  50975. */
  50976. dataPosition: number;
  50977. }
  50978. /**
  50979. * This groups tools to convert HDR texture to native colors array.
  50980. */
  50981. export class HDRTools {
  50982. private static Ldexp;
  50983. private static Rgbe2float;
  50984. private static readStringLine;
  50985. /**
  50986. * Reads header information from an RGBE texture stored in a native array.
  50987. * More information on this format are available here:
  50988. * https://en.wikipedia.org/wiki/RGBE_image_format
  50989. *
  50990. * @param uint8array The binary file stored in native array.
  50991. * @return The header information.
  50992. */
  50993. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50994. /**
  50995. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50996. * This RGBE texture needs to store the information as a panorama.
  50997. *
  50998. * More information on this format are available here:
  50999. * https://en.wikipedia.org/wiki/RGBE_image_format
  51000. *
  51001. * @param buffer The binary file stored in an array buffer.
  51002. * @param size The expected size of the extracted cubemap.
  51003. * @return The Cube Map information.
  51004. */
  51005. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51006. /**
  51007. * Returns the pixels data extracted from an RGBE texture.
  51008. * This pixels will be stored left to right up to down in the R G B order in one array.
  51009. *
  51010. * More information on this format are available here:
  51011. * https://en.wikipedia.org/wiki/RGBE_image_format
  51012. *
  51013. * @param uint8array The binary file stored in an array buffer.
  51014. * @param hdrInfo The header information of the file.
  51015. * @return The pixels data in RGB right to left up to down order.
  51016. */
  51017. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51018. private static RGBE_ReadPixels_RLE;
  51019. }
  51020. }
  51021. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51022. import { Nullable } from "babylonjs/types";
  51023. import { Scene } from "babylonjs/scene";
  51024. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  51025. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51026. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51027. /**
  51028. * This represents a texture coming from an HDR input.
  51029. *
  51030. * The only supported format is currently panorama picture stored in RGBE format.
  51031. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51032. */
  51033. export class HDRCubeTexture extends BaseTexture {
  51034. private static _facesMapping;
  51035. private _generateHarmonics;
  51036. private _noMipmap;
  51037. private _textureMatrix;
  51038. private _size;
  51039. private _onLoad;
  51040. private _onError;
  51041. /**
  51042. * The texture URL.
  51043. */
  51044. url: string;
  51045. /**
  51046. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51047. */
  51048. coordinatesMode: number;
  51049. protected _isBlocking: boolean;
  51050. /**
  51051. * Sets wether or not the texture is blocking during loading.
  51052. */
  51053. /**
  51054. * Gets wether or not the texture is blocking during loading.
  51055. */
  51056. isBlocking: boolean;
  51057. protected _rotationY: number;
  51058. /**
  51059. * Sets texture matrix rotation angle around Y axis in radians.
  51060. */
  51061. /**
  51062. * Gets texture matrix rotation angle around Y axis radians.
  51063. */
  51064. rotationY: number;
  51065. /**
  51066. * Gets or sets the center of the bounding box associated with the cube texture
  51067. * It must define where the camera used to render the texture was set
  51068. */
  51069. boundingBoxPosition: Vector3;
  51070. private _boundingBoxSize;
  51071. /**
  51072. * Gets or sets the size of the bounding box associated with the cube texture
  51073. * When defined, the cubemap will switch to local mode
  51074. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51075. * @example https://www.babylonjs-playground.com/#RNASML
  51076. */
  51077. boundingBoxSize: Vector3;
  51078. /**
  51079. * Instantiates an HDRTexture from the following parameters.
  51080. *
  51081. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51082. * @param scene The scene the texture will be used in
  51083. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51084. * @param noMipmap Forces to not generate the mipmap if true
  51085. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51086. * @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)
  51087. * @param reserved Reserved flag for internal use.
  51088. */
  51089. 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>);
  51090. /**
  51091. * Get the current class name of the texture useful for serialization or dynamic coding.
  51092. * @returns "HDRCubeTexture"
  51093. */
  51094. getClassName(): string;
  51095. /**
  51096. * Occurs when the file is raw .hdr file.
  51097. */
  51098. private loadTexture;
  51099. clone(): HDRCubeTexture;
  51100. delayLoad(): void;
  51101. /**
  51102. * Get the texture reflection matrix used to rotate/transform the reflection.
  51103. * @returns the reflection matrix
  51104. */
  51105. getReflectionTextureMatrix(): Matrix;
  51106. /**
  51107. * Set the texture reflection matrix used to rotate/transform the reflection.
  51108. * @param value Define the reflection matrix to set
  51109. */
  51110. setReflectionTextureMatrix(value: Matrix): void;
  51111. /**
  51112. * Parses a JSON representation of an HDR Texture in order to create the texture
  51113. * @param parsedTexture Define the JSON representation
  51114. * @param scene Define the scene the texture should be created in
  51115. * @param rootUrl Define the root url in case we need to load relative dependencies
  51116. * @returns the newly created texture after parsing
  51117. */
  51118. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51119. serialize(): any;
  51120. }
  51121. }
  51122. declare module "babylonjs/Physics/physicsEngine" {
  51123. import { Nullable } from "babylonjs/types";
  51124. import { Vector3 } from "babylonjs/Maths/math";
  51125. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51126. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51127. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51128. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51129. /**
  51130. * Class used to control physics engine
  51131. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51132. */
  51133. export class PhysicsEngine implements IPhysicsEngine {
  51134. private _physicsPlugin;
  51135. /**
  51136. * Global value used to control the smallest number supported by the simulation
  51137. */
  51138. static Epsilon: number;
  51139. private _impostors;
  51140. private _joints;
  51141. /**
  51142. * Gets the gravity vector used by the simulation
  51143. */
  51144. gravity: Vector3;
  51145. /**
  51146. * Factory used to create the default physics plugin.
  51147. * @returns The default physics plugin
  51148. */
  51149. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51150. /**
  51151. * Creates a new Physics Engine
  51152. * @param gravity defines the gravity vector used by the simulation
  51153. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51154. */
  51155. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51156. /**
  51157. * Sets the gravity vector used by the simulation
  51158. * @param gravity defines the gravity vector to use
  51159. */
  51160. setGravity(gravity: Vector3): void;
  51161. /**
  51162. * Set the time step of the physics engine.
  51163. * Default is 1/60.
  51164. * To slow it down, enter 1/600 for example.
  51165. * To speed it up, 1/30
  51166. * @param newTimeStep defines the new timestep to apply to this world.
  51167. */
  51168. setTimeStep(newTimeStep?: number): void;
  51169. /**
  51170. * Get the time step of the physics engine.
  51171. * @returns the current time step
  51172. */
  51173. getTimeStep(): number;
  51174. /**
  51175. * Release all resources
  51176. */
  51177. dispose(): void;
  51178. /**
  51179. * Gets the name of the current physics plugin
  51180. * @returns the name of the plugin
  51181. */
  51182. getPhysicsPluginName(): string;
  51183. /**
  51184. * Adding a new impostor for the impostor tracking.
  51185. * This will be done by the impostor itself.
  51186. * @param impostor the impostor to add
  51187. */
  51188. addImpostor(impostor: PhysicsImpostor): void;
  51189. /**
  51190. * Remove an impostor from the engine.
  51191. * This impostor and its mesh will not longer be updated by the physics engine.
  51192. * @param impostor the impostor to remove
  51193. */
  51194. removeImpostor(impostor: PhysicsImpostor): void;
  51195. /**
  51196. * Add a joint to the physics engine
  51197. * @param mainImpostor defines the main impostor to which the joint is added.
  51198. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51199. * @param joint defines the joint that will connect both impostors.
  51200. */
  51201. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51202. /**
  51203. * Removes a joint from the simulation
  51204. * @param mainImpostor defines the impostor used with the joint
  51205. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51206. * @param joint defines the joint to remove
  51207. */
  51208. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51209. /**
  51210. * Called by the scene. No need to call it.
  51211. * @param delta defines the timespam between frames
  51212. */
  51213. _step(delta: number): void;
  51214. /**
  51215. * Gets the current plugin used to run the simulation
  51216. * @returns current plugin
  51217. */
  51218. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51219. /**
  51220. * Gets the list of physic impostors
  51221. * @returns an array of PhysicsImpostor
  51222. */
  51223. getImpostors(): Array<PhysicsImpostor>;
  51224. /**
  51225. * Gets the impostor for a physics enabled object
  51226. * @param object defines the object impersonated by the impostor
  51227. * @returns the PhysicsImpostor or null if not found
  51228. */
  51229. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51230. /**
  51231. * Gets the impostor for a physics body object
  51232. * @param body defines physics body used by the impostor
  51233. * @returns the PhysicsImpostor or null if not found
  51234. */
  51235. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51236. /**
  51237. * Does a raycast in the physics world
  51238. * @param from when should the ray start?
  51239. * @param to when should the ray end?
  51240. * @returns PhysicsRaycastResult
  51241. */
  51242. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51243. }
  51244. }
  51245. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51246. import { Nullable } from "babylonjs/types";
  51247. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51249. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51250. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51251. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51252. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51253. /** @hidden */
  51254. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51255. private _useDeltaForWorldStep;
  51256. world: any;
  51257. name: string;
  51258. private _physicsMaterials;
  51259. private _fixedTimeStep;
  51260. private _cannonRaycastResult;
  51261. private _raycastResult;
  51262. private _physicsBodysToRemoveAfterStep;
  51263. BJSCANNON: any;
  51264. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51265. setGravity(gravity: Vector3): void;
  51266. setTimeStep(timeStep: number): void;
  51267. getTimeStep(): number;
  51268. executeStep(delta: number): void;
  51269. private _removeMarkedPhysicsBodiesFromWorld;
  51270. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51271. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51272. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51273. private _processChildMeshes;
  51274. removePhysicsBody(impostor: PhysicsImpostor): void;
  51275. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51276. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51277. private _addMaterial;
  51278. private _checkWithEpsilon;
  51279. private _createShape;
  51280. private _createHeightmap;
  51281. private _minus90X;
  51282. private _plus90X;
  51283. private _tmpPosition;
  51284. private _tmpDeltaPosition;
  51285. private _tmpUnityRotation;
  51286. private _updatePhysicsBodyTransformation;
  51287. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51288. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51289. isSupported(): boolean;
  51290. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51291. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51292. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51293. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51294. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51295. getBodyMass(impostor: PhysicsImpostor): number;
  51296. getBodyFriction(impostor: PhysicsImpostor): number;
  51297. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51298. getBodyRestitution(impostor: PhysicsImpostor): number;
  51299. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51300. sleepBody(impostor: PhysicsImpostor): void;
  51301. wakeUpBody(impostor: PhysicsImpostor): void;
  51302. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51303. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51304. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51305. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51306. getRadius(impostor: PhysicsImpostor): number;
  51307. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51308. dispose(): void;
  51309. private _extendNamespace;
  51310. /**
  51311. * Does a raycast in the physics world
  51312. * @param from when should the ray start?
  51313. * @param to when should the ray end?
  51314. * @returns PhysicsRaycastResult
  51315. */
  51316. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51317. }
  51318. }
  51319. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51320. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51321. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51322. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51324. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51325. import { Nullable } from "babylonjs/types";
  51326. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51327. /** @hidden */
  51328. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51329. world: any;
  51330. name: string;
  51331. BJSOIMO: any;
  51332. private _raycastResult;
  51333. constructor(iterations?: number, oimoInjection?: any);
  51334. setGravity(gravity: Vector3): void;
  51335. setTimeStep(timeStep: number): void;
  51336. getTimeStep(): number;
  51337. private _tmpImpostorsArray;
  51338. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51339. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51340. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51341. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51342. private _tmpPositionVector;
  51343. removePhysicsBody(impostor: PhysicsImpostor): void;
  51344. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51345. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51346. isSupported(): boolean;
  51347. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51348. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51349. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51350. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51351. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51352. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51353. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51354. getBodyMass(impostor: PhysicsImpostor): number;
  51355. getBodyFriction(impostor: PhysicsImpostor): number;
  51356. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51357. getBodyRestitution(impostor: PhysicsImpostor): number;
  51358. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51359. sleepBody(impostor: PhysicsImpostor): void;
  51360. wakeUpBody(impostor: PhysicsImpostor): void;
  51361. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51362. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51363. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51364. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51365. getRadius(impostor: PhysicsImpostor): number;
  51366. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51367. dispose(): void;
  51368. /**
  51369. * Does a raycast in the physics world
  51370. * @param from when should the ray start?
  51371. * @param to when should the ray end?
  51372. * @returns PhysicsRaycastResult
  51373. */
  51374. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51375. }
  51376. }
  51377. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51378. import { Nullable } from "babylonjs/types";
  51379. import { Scene } from "babylonjs/scene";
  51380. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51381. import { Mesh } from "babylonjs/Meshes/mesh";
  51382. /**
  51383. * Class containing static functions to help procedurally build meshes
  51384. */
  51385. export class RibbonBuilder {
  51386. /**
  51387. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51388. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51389. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51390. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51391. * * 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
  51392. * * 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
  51393. * * 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
  51394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51396. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51397. * * 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
  51398. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51399. * * 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
  51400. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51402. * @param name defines the name of the mesh
  51403. * @param options defines the options used to create the mesh
  51404. * @param scene defines the hosting scene
  51405. * @returns the ribbon mesh
  51406. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51408. */
  51409. static CreateRibbon(name: string, options: {
  51410. pathArray: Vector3[][];
  51411. closeArray?: boolean;
  51412. closePath?: boolean;
  51413. offset?: number;
  51414. updatable?: boolean;
  51415. sideOrientation?: number;
  51416. frontUVs?: Vector4;
  51417. backUVs?: Vector4;
  51418. instance?: Mesh;
  51419. invertUV?: boolean;
  51420. uvs?: Vector2[];
  51421. colors?: Color4[];
  51422. }, scene?: Nullable<Scene>): Mesh;
  51423. }
  51424. }
  51425. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51426. import { Nullable } from "babylonjs/types";
  51427. import { Scene } from "babylonjs/scene";
  51428. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51429. import { Mesh } from "babylonjs/Meshes/mesh";
  51430. /**
  51431. * Class containing static functions to help procedurally build meshes
  51432. */
  51433. export class ShapeBuilder {
  51434. /**
  51435. * 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.
  51436. * * 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.
  51437. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51438. * * 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.
  51439. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51440. * * 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
  51441. * * 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
  51442. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51444. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51445. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51447. * @param name defines the name of the mesh
  51448. * @param options defines the options used to create the mesh
  51449. * @param scene defines the hosting scene
  51450. * @returns the extruded shape mesh
  51451. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51452. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51453. */
  51454. static ExtrudeShape(name: string, options: {
  51455. shape: Vector3[];
  51456. path: Vector3[];
  51457. scale?: number;
  51458. rotation?: number;
  51459. cap?: number;
  51460. updatable?: boolean;
  51461. sideOrientation?: number;
  51462. frontUVs?: Vector4;
  51463. backUVs?: Vector4;
  51464. instance?: Mesh;
  51465. invertUV?: boolean;
  51466. }, scene?: Nullable<Scene>): Mesh;
  51467. /**
  51468. * Creates an custom extruded shape mesh.
  51469. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51470. * * 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.
  51471. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51472. * * 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
  51473. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51474. * * 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
  51475. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51476. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51477. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51478. * * 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
  51479. * * 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
  51480. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51482. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51483. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51485. * @param name defines the name of the mesh
  51486. * @param options defines the options used to create the mesh
  51487. * @param scene defines the hosting scene
  51488. * @returns the custom extruded shape mesh
  51489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51491. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51492. */
  51493. static ExtrudeShapeCustom(name: string, options: {
  51494. shape: Vector3[];
  51495. path: Vector3[];
  51496. scaleFunction?: any;
  51497. rotationFunction?: any;
  51498. ribbonCloseArray?: boolean;
  51499. ribbonClosePath?: boolean;
  51500. cap?: number;
  51501. updatable?: boolean;
  51502. sideOrientation?: number;
  51503. frontUVs?: Vector4;
  51504. backUVs?: Vector4;
  51505. instance?: Mesh;
  51506. invertUV?: boolean;
  51507. }, scene?: Nullable<Scene>): Mesh;
  51508. private static _ExtrudeShapeGeneric;
  51509. }
  51510. }
  51511. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51512. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51513. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51514. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51515. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51516. import { Nullable } from "babylonjs/types";
  51517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51518. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51519. /**
  51520. * AmmoJS Physics plugin
  51521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51522. * @see https://github.com/kripken/ammo.js/
  51523. */
  51524. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51525. private _useDeltaForWorldStep;
  51526. /**
  51527. * Reference to the Ammo library
  51528. */
  51529. bjsAMMO: any;
  51530. /**
  51531. * Created ammoJS world which physics bodies are added to
  51532. */
  51533. world: any;
  51534. /**
  51535. * Name of the plugin
  51536. */
  51537. name: string;
  51538. private _timeStep;
  51539. private _fixedTimeStep;
  51540. private _maxSteps;
  51541. private _tmpQuaternion;
  51542. private _tmpAmmoTransform;
  51543. private _tmpAmmoQuaternion;
  51544. private _tmpAmmoConcreteContactResultCallback;
  51545. private _collisionConfiguration;
  51546. private _dispatcher;
  51547. private _overlappingPairCache;
  51548. private _solver;
  51549. private _softBodySolver;
  51550. private _tmpAmmoVectorA;
  51551. private _tmpAmmoVectorB;
  51552. private _tmpAmmoVectorC;
  51553. private _tmpAmmoVectorD;
  51554. private _tmpContactCallbackResult;
  51555. private _tmpAmmoVectorRCA;
  51556. private _tmpAmmoVectorRCB;
  51557. private _raycastResult;
  51558. private static readonly DISABLE_COLLISION_FLAG;
  51559. private static readonly KINEMATIC_FLAG;
  51560. private static readonly DISABLE_DEACTIVATION_FLAG;
  51561. /**
  51562. * Initializes the ammoJS plugin
  51563. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51564. * @param ammoInjection can be used to inject your own ammo reference
  51565. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51566. */
  51567. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51568. /**
  51569. * Sets the gravity of the physics world (m/(s^2))
  51570. * @param gravity Gravity to set
  51571. */
  51572. setGravity(gravity: Vector3): void;
  51573. /**
  51574. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51575. * @param timeStep timestep to use in seconds
  51576. */
  51577. setTimeStep(timeStep: number): void;
  51578. /**
  51579. * 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)
  51580. * @param fixedTimeStep fixedTimeStep to use in seconds
  51581. */
  51582. setFixedTimeStep(fixedTimeStep: number): void;
  51583. /**
  51584. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51585. * @param maxSteps the maximum number of steps by the physics engine per frame
  51586. */
  51587. setMaxSteps(maxSteps: number): void;
  51588. /**
  51589. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51590. * @returns the current timestep in seconds
  51591. */
  51592. getTimeStep(): number;
  51593. private _isImpostorInContact;
  51594. private _isImpostorPairInContact;
  51595. private _stepSimulation;
  51596. /**
  51597. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51598. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51599. * After the step the babylon meshes are set to the position of the physics imposters
  51600. * @param delta amount of time to step forward
  51601. * @param impostors array of imposters to update before/after the step
  51602. */
  51603. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51604. /**
  51605. * Update babylon mesh to match physics world object
  51606. * @param impostor imposter to match
  51607. */
  51608. private _afterSoftStep;
  51609. /**
  51610. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51611. * @param impostor imposter to match
  51612. */
  51613. private _ropeStep;
  51614. /**
  51615. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51616. * @param impostor imposter to match
  51617. */
  51618. private _softbodyOrClothStep;
  51619. private _tmpVector;
  51620. private _tmpMatrix;
  51621. /**
  51622. * Applies an impulse on the imposter
  51623. * @param impostor imposter to apply impulse to
  51624. * @param force amount of force to be applied to the imposter
  51625. * @param contactPoint the location to apply the impulse on the imposter
  51626. */
  51627. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51628. /**
  51629. * Applies a force on the imposter
  51630. * @param impostor imposter to apply force
  51631. * @param force amount of force to be applied to the imposter
  51632. * @param contactPoint the location to apply the force on the imposter
  51633. */
  51634. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51635. /**
  51636. * Creates a physics body using the plugin
  51637. * @param impostor the imposter to create the physics body on
  51638. */
  51639. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51640. /**
  51641. * Removes the physics body from the imposter and disposes of the body's memory
  51642. * @param impostor imposter to remove the physics body from
  51643. */
  51644. removePhysicsBody(impostor: PhysicsImpostor): void;
  51645. /**
  51646. * Generates a joint
  51647. * @param impostorJoint the imposter joint to create the joint with
  51648. */
  51649. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51650. /**
  51651. * Removes a joint
  51652. * @param impostorJoint the imposter joint to remove the joint from
  51653. */
  51654. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51655. private _addMeshVerts;
  51656. /**
  51657. * Initialise the soft body vertices to match its object's (mesh) vertices
  51658. * Softbody vertices (nodes) are in world space and to match this
  51659. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51660. * @param impostor to create the softbody for
  51661. */
  51662. private _softVertexData;
  51663. /**
  51664. * Create an impostor's soft body
  51665. * @param impostor to create the softbody for
  51666. */
  51667. private _createSoftbody;
  51668. /**
  51669. * Create cloth for an impostor
  51670. * @param impostor to create the softbody for
  51671. */
  51672. private _createCloth;
  51673. /**
  51674. * Create rope for an impostor
  51675. * @param impostor to create the softbody for
  51676. */
  51677. private _createRope;
  51678. private _addHullVerts;
  51679. private _createShape;
  51680. /**
  51681. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51682. * @param impostor imposter containing the physics body and babylon object
  51683. */
  51684. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51685. /**
  51686. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51687. * @param impostor imposter containing the physics body and babylon object
  51688. * @param newPosition new position
  51689. * @param newRotation new rotation
  51690. */
  51691. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51692. /**
  51693. * If this plugin is supported
  51694. * @returns true if its supported
  51695. */
  51696. isSupported(): boolean;
  51697. /**
  51698. * Sets the linear velocity of the physics body
  51699. * @param impostor imposter to set the velocity on
  51700. * @param velocity velocity to set
  51701. */
  51702. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51703. /**
  51704. * Sets the angular velocity of the physics body
  51705. * @param impostor imposter to set the velocity on
  51706. * @param velocity velocity to set
  51707. */
  51708. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51709. /**
  51710. * gets the linear velocity
  51711. * @param impostor imposter to get linear velocity from
  51712. * @returns linear velocity
  51713. */
  51714. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51715. /**
  51716. * gets the angular velocity
  51717. * @param impostor imposter to get angular velocity from
  51718. * @returns angular velocity
  51719. */
  51720. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51721. /**
  51722. * Sets the mass of physics body
  51723. * @param impostor imposter to set the mass on
  51724. * @param mass mass to set
  51725. */
  51726. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51727. /**
  51728. * Gets the mass of the physics body
  51729. * @param impostor imposter to get the mass from
  51730. * @returns mass
  51731. */
  51732. getBodyMass(impostor: PhysicsImpostor): number;
  51733. /**
  51734. * Gets friction of the impostor
  51735. * @param impostor impostor to get friction from
  51736. * @returns friction value
  51737. */
  51738. getBodyFriction(impostor: PhysicsImpostor): number;
  51739. /**
  51740. * Sets friction of the impostor
  51741. * @param impostor impostor to set friction on
  51742. * @param friction friction value
  51743. */
  51744. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51745. /**
  51746. * Gets restitution of the impostor
  51747. * @param impostor impostor to get restitution from
  51748. * @returns restitution value
  51749. */
  51750. getBodyRestitution(impostor: PhysicsImpostor): number;
  51751. /**
  51752. * Sets resitution of the impostor
  51753. * @param impostor impostor to set resitution on
  51754. * @param restitution resitution value
  51755. */
  51756. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51757. /**
  51758. * Gets pressure inside the impostor
  51759. * @param impostor impostor to get pressure from
  51760. * @returns pressure value
  51761. */
  51762. getBodyPressure(impostor: PhysicsImpostor): number;
  51763. /**
  51764. * Sets pressure inside a soft body impostor
  51765. * Cloth and rope must remain 0 pressure
  51766. * @param impostor impostor to set pressure on
  51767. * @param pressure pressure value
  51768. */
  51769. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51770. /**
  51771. * Gets stiffness of the impostor
  51772. * @param impostor impostor to get stiffness from
  51773. * @returns pressure value
  51774. */
  51775. getBodyStiffness(impostor: PhysicsImpostor): number;
  51776. /**
  51777. * Sets stiffness of the impostor
  51778. * @param impostor impostor to set stiffness on
  51779. * @param stiffness stiffness value from 0 to 1
  51780. */
  51781. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51782. /**
  51783. * Gets velocityIterations of the impostor
  51784. * @param impostor impostor to get velocity iterations from
  51785. * @returns velocityIterations value
  51786. */
  51787. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51788. /**
  51789. * Sets velocityIterations of the impostor
  51790. * @param impostor impostor to set velocity iterations on
  51791. * @param velocityIterations velocityIterations value
  51792. */
  51793. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51794. /**
  51795. * Gets positionIterations of the impostor
  51796. * @param impostor impostor to get position iterations from
  51797. * @returns positionIterations value
  51798. */
  51799. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51800. /**
  51801. * Sets positionIterations of the impostor
  51802. * @param impostor impostor to set position on
  51803. * @param positionIterations positionIterations value
  51804. */
  51805. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51806. /**
  51807. * Append an anchor to a cloth object
  51808. * @param impostor is the cloth impostor to add anchor to
  51809. * @param otherImpostor is the rigid impostor to anchor to
  51810. * @param width ratio across width from 0 to 1
  51811. * @param height ratio up height from 0 to 1
  51812. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51813. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51814. */
  51815. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51816. /**
  51817. * Append an hook to a rope object
  51818. * @param impostor is the rope impostor to add hook to
  51819. * @param otherImpostor is the rigid impostor to hook to
  51820. * @param length ratio along the rope from 0 to 1
  51821. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51822. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51823. */
  51824. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51825. /**
  51826. * Sleeps the physics body and stops it from being active
  51827. * @param impostor impostor to sleep
  51828. */
  51829. sleepBody(impostor: PhysicsImpostor): void;
  51830. /**
  51831. * Activates the physics body
  51832. * @param impostor impostor to activate
  51833. */
  51834. wakeUpBody(impostor: PhysicsImpostor): void;
  51835. /**
  51836. * Updates the distance parameters of the joint
  51837. * @param joint joint to update
  51838. * @param maxDistance maximum distance of the joint
  51839. * @param minDistance minimum distance of the joint
  51840. */
  51841. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51842. /**
  51843. * Sets a motor on the joint
  51844. * @param joint joint to set motor on
  51845. * @param speed speed of the motor
  51846. * @param maxForce maximum force of the motor
  51847. * @param motorIndex index of the motor
  51848. */
  51849. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51850. /**
  51851. * Sets the motors limit
  51852. * @param joint joint to set limit on
  51853. * @param upperLimit upper limit
  51854. * @param lowerLimit lower limit
  51855. */
  51856. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51857. /**
  51858. * Syncs the position and rotation of a mesh with the impostor
  51859. * @param mesh mesh to sync
  51860. * @param impostor impostor to update the mesh with
  51861. */
  51862. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51863. /**
  51864. * Gets the radius of the impostor
  51865. * @param impostor impostor to get radius from
  51866. * @returns the radius
  51867. */
  51868. getRadius(impostor: PhysicsImpostor): number;
  51869. /**
  51870. * Gets the box size of the impostor
  51871. * @param impostor impostor to get box size from
  51872. * @param result the resulting box size
  51873. */
  51874. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51875. /**
  51876. * Disposes of the impostor
  51877. */
  51878. dispose(): void;
  51879. /**
  51880. * Does a raycast in the physics world
  51881. * @param from when should the ray start?
  51882. * @param to when should the ray end?
  51883. * @returns PhysicsRaycastResult
  51884. */
  51885. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51886. }
  51887. }
  51888. declare module "babylonjs/Probes/reflectionProbe" {
  51889. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51890. import { Vector3 } from "babylonjs/Maths/math";
  51891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51892. import { Nullable } from "babylonjs/types";
  51893. import { Scene } from "babylonjs/scene";
  51894. module "babylonjs/abstractScene" {
  51895. interface AbstractScene {
  51896. /**
  51897. * The list of reflection probes added to the scene
  51898. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51899. */
  51900. reflectionProbes: Array<ReflectionProbe>;
  51901. /**
  51902. * Removes the given reflection probe from this scene.
  51903. * @param toRemove The reflection probe to remove
  51904. * @returns The index of the removed reflection probe
  51905. */
  51906. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51907. /**
  51908. * Adds the given reflection probe to this scene.
  51909. * @param newReflectionProbe The reflection probe to add
  51910. */
  51911. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51912. }
  51913. }
  51914. /**
  51915. * Class used to generate realtime reflection / refraction cube textures
  51916. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51917. */
  51918. export class ReflectionProbe {
  51919. /** defines the name of the probe */
  51920. name: string;
  51921. private _scene;
  51922. private _renderTargetTexture;
  51923. private _projectionMatrix;
  51924. private _viewMatrix;
  51925. private _target;
  51926. private _add;
  51927. private _attachedMesh;
  51928. private _invertYAxis;
  51929. /** Gets or sets probe position (center of the cube map) */
  51930. position: Vector3;
  51931. /**
  51932. * Creates a new reflection probe
  51933. * @param name defines the name of the probe
  51934. * @param size defines the texture resolution (for each face)
  51935. * @param scene defines the hosting scene
  51936. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51937. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51938. */
  51939. constructor(
  51940. /** defines the name of the probe */
  51941. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51942. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51943. samples: number;
  51944. /** Gets or sets the refresh rate to use (on every frame by default) */
  51945. refreshRate: number;
  51946. /**
  51947. * Gets the hosting scene
  51948. * @returns a Scene
  51949. */
  51950. getScene(): Scene;
  51951. /** Gets the internal CubeTexture used to render to */
  51952. readonly cubeTexture: RenderTargetTexture;
  51953. /** Gets the list of meshes to render */
  51954. readonly renderList: Nullable<AbstractMesh[]>;
  51955. /**
  51956. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51957. * @param mesh defines the mesh to attach to
  51958. */
  51959. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51960. /**
  51961. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51962. * @param renderingGroupId The rendering group id corresponding to its index
  51963. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51964. */
  51965. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51966. /**
  51967. * Clean all associated resources
  51968. */
  51969. dispose(): void;
  51970. /**
  51971. * Converts the reflection probe information to a readable string for debug purpose.
  51972. * @param fullDetails Supports for multiple levels of logging within scene loading
  51973. * @returns the human readable reflection probe info
  51974. */
  51975. toString(fullDetails?: boolean): string;
  51976. /**
  51977. * Get the class name of the relfection probe.
  51978. * @returns "ReflectionProbe"
  51979. */
  51980. getClassName(): string;
  51981. /**
  51982. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51983. * @returns The JSON representation of the texture
  51984. */
  51985. serialize(): any;
  51986. /**
  51987. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51988. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51989. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51990. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51991. * @returns The parsed reflection probe if successful
  51992. */
  51993. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51994. }
  51995. }
  51996. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51997. /** @hidden */
  51998. export var _BabylonLoaderRegistered: boolean;
  51999. }
  52000. declare module "babylonjs/Loading/Plugins/index" {
  52001. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52002. }
  52003. declare module "babylonjs/Loading/index" {
  52004. export * from "babylonjs/Loading/loadingScreen";
  52005. export * from "babylonjs/Loading/Plugins/index";
  52006. export * from "babylonjs/Loading/sceneLoader";
  52007. export * from "babylonjs/Loading/sceneLoaderFlags";
  52008. }
  52009. declare module "babylonjs/Materials/Background/index" {
  52010. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52011. }
  52012. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52013. import { Scene } from "babylonjs/scene";
  52014. import { Color3 } from "babylonjs/Maths/math";
  52015. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52016. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52017. /**
  52018. * The Physically based simple base material of BJS.
  52019. *
  52020. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52021. * It is used as the base class for both the specGloss and metalRough conventions.
  52022. */
  52023. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52024. /**
  52025. * Number of Simultaneous lights allowed on the material.
  52026. */
  52027. maxSimultaneousLights: number;
  52028. /**
  52029. * If sets to true, disables all the lights affecting the material.
  52030. */
  52031. disableLighting: boolean;
  52032. /**
  52033. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52034. */
  52035. environmentTexture: BaseTexture;
  52036. /**
  52037. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52038. */
  52039. invertNormalMapX: boolean;
  52040. /**
  52041. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52042. */
  52043. invertNormalMapY: boolean;
  52044. /**
  52045. * Normal map used in the model.
  52046. */
  52047. normalTexture: BaseTexture;
  52048. /**
  52049. * Emissivie color used to self-illuminate the model.
  52050. */
  52051. emissiveColor: Color3;
  52052. /**
  52053. * Emissivie texture used to self-illuminate the model.
  52054. */
  52055. emissiveTexture: BaseTexture;
  52056. /**
  52057. * Occlusion Channel Strenght.
  52058. */
  52059. occlusionStrength: number;
  52060. /**
  52061. * Occlusion Texture of the material (adding extra occlusion effects).
  52062. */
  52063. occlusionTexture: BaseTexture;
  52064. /**
  52065. * Defines the alpha limits in alpha test mode.
  52066. */
  52067. alphaCutOff: number;
  52068. /**
  52069. * Gets the current double sided mode.
  52070. */
  52071. /**
  52072. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52073. */
  52074. doubleSided: boolean;
  52075. /**
  52076. * Stores the pre-calculated light information of a mesh in a texture.
  52077. */
  52078. lightmapTexture: BaseTexture;
  52079. /**
  52080. * If true, the light map contains occlusion information instead of lighting info.
  52081. */
  52082. useLightmapAsShadowmap: boolean;
  52083. /**
  52084. * Instantiates a new PBRMaterial instance.
  52085. *
  52086. * @param name The material name
  52087. * @param scene The scene the material will be use in.
  52088. */
  52089. constructor(name: string, scene: Scene);
  52090. getClassName(): string;
  52091. }
  52092. }
  52093. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52094. import { Scene } from "babylonjs/scene";
  52095. import { Color3 } from "babylonjs/Maths/math";
  52096. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52097. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52098. /**
  52099. * The PBR material of BJS following the metal roughness convention.
  52100. *
  52101. * This fits to the PBR convention in the GLTF definition:
  52102. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52103. */
  52104. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52105. /**
  52106. * The base color has two different interpretations depending on the value of metalness.
  52107. * When the material is a metal, the base color is the specific measured reflectance value
  52108. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52109. * of the material.
  52110. */
  52111. baseColor: Color3;
  52112. /**
  52113. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52114. * well as opacity information in the alpha channel.
  52115. */
  52116. baseTexture: BaseTexture;
  52117. /**
  52118. * Specifies the metallic scalar value of the material.
  52119. * Can also be used to scale the metalness values of the metallic texture.
  52120. */
  52121. metallic: number;
  52122. /**
  52123. * Specifies the roughness scalar value of the material.
  52124. * Can also be used to scale the roughness values of the metallic texture.
  52125. */
  52126. roughness: number;
  52127. /**
  52128. * Texture containing both the metallic value in the B channel and the
  52129. * roughness value in the G channel to keep better precision.
  52130. */
  52131. metallicRoughnessTexture: BaseTexture;
  52132. /**
  52133. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52134. *
  52135. * @param name The material name
  52136. * @param scene The scene the material will be use in.
  52137. */
  52138. constructor(name: string, scene: Scene);
  52139. /**
  52140. * Return the currrent class name of the material.
  52141. */
  52142. getClassName(): string;
  52143. /**
  52144. * Makes a duplicate of the current material.
  52145. * @param name - name to use for the new material.
  52146. */
  52147. clone(name: string): PBRMetallicRoughnessMaterial;
  52148. /**
  52149. * Serialize the material to a parsable JSON object.
  52150. */
  52151. serialize(): any;
  52152. /**
  52153. * Parses a JSON object correponding to the serialize function.
  52154. */
  52155. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52156. }
  52157. }
  52158. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52159. import { Scene } from "babylonjs/scene";
  52160. import { Color3 } from "babylonjs/Maths/math";
  52161. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52162. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52163. /**
  52164. * The PBR material of BJS following the specular glossiness convention.
  52165. *
  52166. * This fits to the PBR convention in the GLTF definition:
  52167. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52168. */
  52169. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52170. /**
  52171. * Specifies the diffuse color of the material.
  52172. */
  52173. diffuseColor: Color3;
  52174. /**
  52175. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52176. * channel.
  52177. */
  52178. diffuseTexture: BaseTexture;
  52179. /**
  52180. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52181. */
  52182. specularColor: Color3;
  52183. /**
  52184. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52185. */
  52186. glossiness: number;
  52187. /**
  52188. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52189. */
  52190. specularGlossinessTexture: BaseTexture;
  52191. /**
  52192. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52193. *
  52194. * @param name The material name
  52195. * @param scene The scene the material will be use in.
  52196. */
  52197. constructor(name: string, scene: Scene);
  52198. /**
  52199. * Return the currrent class name of the material.
  52200. */
  52201. getClassName(): string;
  52202. /**
  52203. * Makes a duplicate of the current material.
  52204. * @param name - name to use for the new material.
  52205. */
  52206. clone(name: string): PBRSpecularGlossinessMaterial;
  52207. /**
  52208. * Serialize the material to a parsable JSON object.
  52209. */
  52210. serialize(): any;
  52211. /**
  52212. * Parses a JSON object correponding to the serialize function.
  52213. */
  52214. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52215. }
  52216. }
  52217. declare module "babylonjs/Materials/PBR/index" {
  52218. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52219. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52220. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52221. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52222. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52223. }
  52224. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52225. import { Nullable } from "babylonjs/types";
  52226. import { Scene } from "babylonjs/scene";
  52227. import { Matrix } from "babylonjs/Maths/math";
  52228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52229. /**
  52230. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52231. * It can help converting any input color in a desired output one. This can then be used to create effects
  52232. * from sepia, black and white to sixties or futuristic rendering...
  52233. *
  52234. * The only supported format is currently 3dl.
  52235. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52236. */
  52237. export class ColorGradingTexture extends BaseTexture {
  52238. /**
  52239. * The current texture matrix. (will always be identity in color grading texture)
  52240. */
  52241. private _textureMatrix;
  52242. /**
  52243. * The texture URL.
  52244. */
  52245. url: string;
  52246. /**
  52247. * Empty line regex stored for GC.
  52248. */
  52249. private static _noneEmptyLineRegex;
  52250. private _engine;
  52251. /**
  52252. * Instantiates a ColorGradingTexture from the following parameters.
  52253. *
  52254. * @param url The location of the color gradind data (currently only supporting 3dl)
  52255. * @param scene The scene the texture will be used in
  52256. */
  52257. constructor(url: string, scene: Scene);
  52258. /**
  52259. * Returns the texture matrix used in most of the material.
  52260. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52261. */
  52262. getTextureMatrix(): Matrix;
  52263. /**
  52264. * Occurs when the file being loaded is a .3dl LUT file.
  52265. */
  52266. private load3dlTexture;
  52267. /**
  52268. * Starts the loading process of the texture.
  52269. */
  52270. private loadTexture;
  52271. /**
  52272. * Clones the color gradind texture.
  52273. */
  52274. clone(): ColorGradingTexture;
  52275. /**
  52276. * Called during delayed load for textures.
  52277. */
  52278. delayLoad(): void;
  52279. /**
  52280. * Parses a color grading texture serialized by Babylon.
  52281. * @param parsedTexture The texture information being parsedTexture
  52282. * @param scene The scene to load the texture in
  52283. * @param rootUrl The root url of the data assets to load
  52284. * @return A color gradind texture
  52285. */
  52286. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52287. /**
  52288. * Serializes the LUT texture to json format.
  52289. */
  52290. serialize(): any;
  52291. }
  52292. }
  52293. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52294. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52295. import { Scene } from "babylonjs/scene";
  52296. import { Nullable } from "babylonjs/types";
  52297. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52298. /**
  52299. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52300. */
  52301. export class EquiRectangularCubeTexture extends BaseTexture {
  52302. /** The six faces of the cube. */
  52303. private static _FacesMapping;
  52304. private _noMipmap;
  52305. private _onLoad;
  52306. private _onError;
  52307. /** The size of the cubemap. */
  52308. private _size;
  52309. /** The buffer of the image. */
  52310. private _buffer;
  52311. /** The width of the input image. */
  52312. private _width;
  52313. /** The height of the input image. */
  52314. private _height;
  52315. /** The URL to the image. */
  52316. url: string;
  52317. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52318. coordinatesMode: number;
  52319. /**
  52320. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52321. * @param url The location of the image
  52322. * @param scene The scene the texture will be used in
  52323. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52324. * @param noMipmap Forces to not generate the mipmap if true
  52325. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52326. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52327. * @param onLoad — defines a callback called when texture is loaded
  52328. * @param onError — defines a callback called if there is an error
  52329. */
  52330. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52331. /**
  52332. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52333. */
  52334. private loadImage;
  52335. /**
  52336. * Convert the image buffer into a cubemap and create a CubeTexture.
  52337. */
  52338. private loadTexture;
  52339. /**
  52340. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52341. * @param buffer The ArrayBuffer that should be converted.
  52342. * @returns The buffer as Float32Array.
  52343. */
  52344. private getFloat32ArrayFromArrayBuffer;
  52345. /**
  52346. * Get the current class name of the texture useful for serialization or dynamic coding.
  52347. * @returns "EquiRectangularCubeTexture"
  52348. */
  52349. getClassName(): string;
  52350. /**
  52351. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52352. * @returns A clone of the current EquiRectangularCubeTexture.
  52353. */
  52354. clone(): EquiRectangularCubeTexture;
  52355. }
  52356. }
  52357. declare module "babylonjs/Misc/tga" {
  52358. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52359. /**
  52360. * Based on jsTGALoader - Javascript loader for TGA file
  52361. * By Vincent Thibault
  52362. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52363. */
  52364. export class TGATools {
  52365. private static _TYPE_INDEXED;
  52366. private static _TYPE_RGB;
  52367. private static _TYPE_GREY;
  52368. private static _TYPE_RLE_INDEXED;
  52369. private static _TYPE_RLE_RGB;
  52370. private static _TYPE_RLE_GREY;
  52371. private static _ORIGIN_MASK;
  52372. private static _ORIGIN_SHIFT;
  52373. private static _ORIGIN_BL;
  52374. private static _ORIGIN_BR;
  52375. private static _ORIGIN_UL;
  52376. private static _ORIGIN_UR;
  52377. /**
  52378. * Gets the header of a TGA file
  52379. * @param data defines the TGA data
  52380. * @returns the header
  52381. */
  52382. static GetTGAHeader(data: Uint8Array): any;
  52383. /**
  52384. * Uploads TGA content to a Babylon Texture
  52385. * @hidden
  52386. */
  52387. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52388. /** @hidden */
  52389. 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;
  52390. /** @hidden */
  52391. 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;
  52392. /** @hidden */
  52393. 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;
  52394. /** @hidden */
  52395. 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;
  52396. /** @hidden */
  52397. 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;
  52398. /** @hidden */
  52399. 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;
  52400. }
  52401. }
  52402. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52403. import { Nullable } from "babylonjs/types";
  52404. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52405. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52406. /**
  52407. * Implementation of the TGA Texture Loader.
  52408. * @hidden
  52409. */
  52410. export class _TGATextureLoader implements IInternalTextureLoader {
  52411. /**
  52412. * Defines wether the loader supports cascade loading the different faces.
  52413. */
  52414. readonly supportCascades: boolean;
  52415. /**
  52416. * This returns if the loader support the current file information.
  52417. * @param extension defines the file extension of the file being loaded
  52418. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52419. * @param fallback defines the fallback internal texture if any
  52420. * @param isBase64 defines whether the texture is encoded as a base64
  52421. * @param isBuffer defines whether the texture data are stored as a buffer
  52422. * @returns true if the loader can load the specified file
  52423. */
  52424. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52425. /**
  52426. * Transform the url before loading if required.
  52427. * @param rootUrl the url of the texture
  52428. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52429. * @returns the transformed texture
  52430. */
  52431. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52432. /**
  52433. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52434. * @param rootUrl the url of the texture
  52435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52436. * @returns the fallback texture
  52437. */
  52438. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52439. /**
  52440. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52441. * @param data contains the texture data
  52442. * @param texture defines the BabylonJS internal texture
  52443. * @param createPolynomials will be true if polynomials have been requested
  52444. * @param onLoad defines the callback to trigger once the texture is ready
  52445. * @param onError defines the callback to trigger in case of error
  52446. */
  52447. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52448. /**
  52449. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52450. * @param data contains the texture data
  52451. * @param texture defines the BabylonJS internal texture
  52452. * @param callback defines the method to call once ready to upload
  52453. */
  52454. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52455. }
  52456. }
  52457. declare module "babylonjs/Misc/basis" {
  52458. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52459. /**
  52460. * Info about the .basis files
  52461. */
  52462. class BasisFileInfo {
  52463. /**
  52464. * If the file has alpha
  52465. */
  52466. hasAlpha: boolean;
  52467. /**
  52468. * Info about each image of the basis file
  52469. */
  52470. images: Array<{
  52471. levels: Array<{
  52472. width: number;
  52473. height: number;
  52474. transcodedPixels: ArrayBufferView;
  52475. }>;
  52476. }>;
  52477. }
  52478. /**
  52479. * Result of transcoding a basis file
  52480. */
  52481. class TranscodeResult {
  52482. /**
  52483. * Info about the .basis file
  52484. */
  52485. fileInfo: BasisFileInfo;
  52486. /**
  52487. * Format to use when loading the file
  52488. */
  52489. format: number;
  52490. }
  52491. /**
  52492. * Configuration options for the Basis transcoder
  52493. */
  52494. export class BasisTranscodeConfiguration {
  52495. /**
  52496. * Supported compression formats used to determine the supported output format of the transcoder
  52497. */
  52498. supportedCompressionFormats?: {
  52499. /**
  52500. * etc1 compression format
  52501. */
  52502. etc1?: boolean;
  52503. /**
  52504. * s3tc compression format
  52505. */
  52506. s3tc?: boolean;
  52507. /**
  52508. * pvrtc compression format
  52509. */
  52510. pvrtc?: boolean;
  52511. /**
  52512. * etc2 compression format
  52513. */
  52514. etc2?: boolean;
  52515. };
  52516. /**
  52517. * If mipmap levels should be loaded for transcoded images (Default: true)
  52518. */
  52519. loadMipmapLevels?: boolean;
  52520. /**
  52521. * Index of a single image to load (Default: all images)
  52522. */
  52523. loadSingleImage?: number;
  52524. }
  52525. /**
  52526. * Used to load .Basis files
  52527. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52528. */
  52529. export class BasisTools {
  52530. private static _IgnoreSupportedFormats;
  52531. /**
  52532. * URL to use when loading the basis transcoder
  52533. */
  52534. static JSModuleURL: string;
  52535. /**
  52536. * URL to use when loading the wasm module for the transcoder
  52537. */
  52538. static WasmModuleURL: string;
  52539. /**
  52540. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52541. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52542. * @returns internal format corresponding to the Basis format
  52543. */
  52544. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52545. private static _WorkerPromise;
  52546. private static _Worker;
  52547. private static _actionId;
  52548. private static _CreateWorkerAsync;
  52549. /**
  52550. * Transcodes a loaded image file to compressed pixel data
  52551. * @param imageData image data to transcode
  52552. * @param config configuration options for the transcoding
  52553. * @returns a promise resulting in the transcoded image
  52554. */
  52555. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52556. /**
  52557. * Loads a texture from the transcode result
  52558. * @param texture texture load to
  52559. * @param transcodeResult the result of transcoding the basis file to load from
  52560. */
  52561. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52562. }
  52563. }
  52564. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  52565. import { Nullable } from "babylonjs/types";
  52566. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52567. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52568. /**
  52569. * Loader for .basis file format
  52570. */
  52571. export class _BasisTextureLoader implements IInternalTextureLoader {
  52572. /**
  52573. * Defines whether the loader supports cascade loading the different faces.
  52574. */
  52575. readonly supportCascades: boolean;
  52576. /**
  52577. * This returns if the loader support the current file information.
  52578. * @param extension defines the file extension of the file being loaded
  52579. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52580. * @param fallback defines the fallback internal texture if any
  52581. * @param isBase64 defines whether the texture is encoded as a base64
  52582. * @param isBuffer defines whether the texture data are stored as a buffer
  52583. * @returns true if the loader can load the specified file
  52584. */
  52585. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52586. /**
  52587. * Transform the url before loading if required.
  52588. * @param rootUrl the url of the texture
  52589. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52590. * @returns the transformed texture
  52591. */
  52592. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52593. /**
  52594. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52595. * @param rootUrl the url of the texture
  52596. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52597. * @returns the fallback texture
  52598. */
  52599. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52600. /**
  52601. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52602. * @param data contains the texture data
  52603. * @param texture defines the BabylonJS internal texture
  52604. * @param createPolynomials will be true if polynomials have been requested
  52605. * @param onLoad defines the callback to trigger once the texture is ready
  52606. * @param onError defines the callback to trigger in case of error
  52607. */
  52608. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52609. /**
  52610. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52611. * @param data contains the texture data
  52612. * @param texture defines the BabylonJS internal texture
  52613. * @param callback defines the method to call once ready to upload
  52614. */
  52615. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52616. }
  52617. }
  52618. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52619. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52620. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52621. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52622. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52623. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  52624. }
  52625. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52626. import { Scene } from "babylonjs/scene";
  52627. import { Texture } from "babylonjs/Materials/Textures/texture";
  52628. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52629. /**
  52630. * 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.
  52631. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52632. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52633. */
  52634. export class CustomProceduralTexture extends ProceduralTexture {
  52635. private _animate;
  52636. private _time;
  52637. private _config;
  52638. private _texturePath;
  52639. /**
  52640. * Instantiates a new Custom Procedural Texture.
  52641. * 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.
  52642. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52643. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52644. * @param name Define the name of the texture
  52645. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52646. * @param size Define the size of the texture to create
  52647. * @param scene Define the scene the texture belongs to
  52648. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52649. * @param generateMipMaps Define if the texture should creates mip maps or not
  52650. */
  52651. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52652. private _loadJson;
  52653. /**
  52654. * Is the texture ready to be used ? (rendered at least once)
  52655. * @returns true if ready, otherwise, false.
  52656. */
  52657. isReady(): boolean;
  52658. /**
  52659. * Render the texture to its associated render target.
  52660. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52661. */
  52662. render(useCameraPostProcess?: boolean): void;
  52663. /**
  52664. * Update the list of dependant textures samplers in the shader.
  52665. */
  52666. updateTextures(): void;
  52667. /**
  52668. * Update the uniform values of the procedural texture in the shader.
  52669. */
  52670. updateShaderUniforms(): void;
  52671. /**
  52672. * Define if the texture animates or not.
  52673. */
  52674. animate: boolean;
  52675. }
  52676. }
  52677. declare module "babylonjs/Shaders/noise.fragment" {
  52678. /** @hidden */
  52679. export var noisePixelShader: {
  52680. name: string;
  52681. shader: string;
  52682. };
  52683. }
  52684. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52685. import { Nullable } from "babylonjs/types";
  52686. import { Scene } from "babylonjs/scene";
  52687. import { Texture } from "babylonjs/Materials/Textures/texture";
  52688. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52689. import "babylonjs/Shaders/noise.fragment";
  52690. /**
  52691. * Class used to generate noise procedural textures
  52692. */
  52693. export class NoiseProceduralTexture extends ProceduralTexture {
  52694. private _time;
  52695. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52696. brightness: number;
  52697. /** Defines the number of octaves to process */
  52698. octaves: number;
  52699. /** Defines the level of persistence (0.8 by default) */
  52700. persistence: number;
  52701. /** Gets or sets animation speed factor (default is 1) */
  52702. animationSpeedFactor: number;
  52703. /**
  52704. * Creates a new NoiseProceduralTexture
  52705. * @param name defines the name fo the texture
  52706. * @param size defines the size of the texture (default is 256)
  52707. * @param scene defines the hosting scene
  52708. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52709. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52710. */
  52711. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52712. private _updateShaderUniforms;
  52713. protected _getDefines(): string;
  52714. /** Generate the current state of the procedural texture */
  52715. render(useCameraPostProcess?: boolean): void;
  52716. /**
  52717. * Serializes this noise procedural texture
  52718. * @returns a serialized noise procedural texture object
  52719. */
  52720. serialize(): any;
  52721. /**
  52722. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52723. * @param parsedTexture defines parsed texture data
  52724. * @param scene defines the current scene
  52725. * @param rootUrl defines the root URL containing noise procedural texture information
  52726. * @returns a parsed NoiseProceduralTexture
  52727. */
  52728. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52729. }
  52730. }
  52731. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52732. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52733. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52734. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52735. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52736. }
  52737. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52738. import { Nullable } from "babylonjs/types";
  52739. import { Scene } from "babylonjs/scene";
  52740. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52741. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52742. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52743. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52744. /**
  52745. * Raw cube texture where the raw buffers are passed in
  52746. */
  52747. export class RawCubeTexture extends CubeTexture {
  52748. /**
  52749. * Creates a cube texture where the raw buffers are passed in.
  52750. * @param scene defines the scene the texture is attached to
  52751. * @param data defines the array of data to use to create each face
  52752. * @param size defines the size of the textures
  52753. * @param format defines the format of the data
  52754. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52755. * @param generateMipMaps defines if the engine should generate the mip levels
  52756. * @param invertY defines if data must be stored with Y axis inverted
  52757. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52758. * @param compression defines the compression used (null by default)
  52759. */
  52760. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52761. /**
  52762. * Updates the raw cube texture.
  52763. * @param data defines the data to store
  52764. * @param format defines the data format
  52765. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52766. * @param invertY defines if data must be stored with Y axis inverted
  52767. * @param compression defines the compression used (null by default)
  52768. * @param level defines which level of the texture to update
  52769. */
  52770. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52771. /**
  52772. * Updates a raw cube texture with RGBD encoded data.
  52773. * @param data defines the array of data [mipmap][face] to use to create each face
  52774. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52775. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52776. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52777. * @returns a promsie that resolves when the operation is complete
  52778. */
  52779. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52780. /**
  52781. * Clones the raw cube texture.
  52782. * @return a new cube texture
  52783. */
  52784. clone(): CubeTexture;
  52785. /** @hidden */
  52786. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52787. }
  52788. }
  52789. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52790. import { Scene } from "babylonjs/scene";
  52791. import { Texture } from "babylonjs/Materials/Textures/texture";
  52792. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52793. /**
  52794. * Class used to store 3D textures containing user data
  52795. */
  52796. export class RawTexture3D extends Texture {
  52797. /** Gets or sets the texture format to use */
  52798. format: number;
  52799. private _engine;
  52800. /**
  52801. * Create a new RawTexture3D
  52802. * @param data defines the data of the texture
  52803. * @param width defines the width of the texture
  52804. * @param height defines the height of the texture
  52805. * @param depth defines the depth of the texture
  52806. * @param format defines the texture format to use
  52807. * @param scene defines the hosting scene
  52808. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52809. * @param invertY defines if texture must be stored with Y axis inverted
  52810. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52811. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52812. */
  52813. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52814. /** Gets or sets the texture format to use */
  52815. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52816. /**
  52817. * Update the texture with new data
  52818. * @param data defines the data to store in the texture
  52819. */
  52820. update(data: ArrayBufferView): void;
  52821. }
  52822. }
  52823. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52824. import { Scene } from "babylonjs/scene";
  52825. import { Plane } from "babylonjs/Maths/math";
  52826. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52827. /**
  52828. * Creates a refraction texture used by refraction channel of the standard material.
  52829. * It is like a mirror but to see through a material.
  52830. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52831. */
  52832. export class RefractionTexture extends RenderTargetTexture {
  52833. /**
  52834. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52835. * 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.
  52836. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52837. */
  52838. refractionPlane: Plane;
  52839. /**
  52840. * Define how deep under the surface we should see.
  52841. */
  52842. depth: number;
  52843. /**
  52844. * Creates a refraction texture used by refraction channel of the standard material.
  52845. * It is like a mirror but to see through a material.
  52846. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52847. * @param name Define the texture name
  52848. * @param size Define the size of the underlying texture
  52849. * @param scene Define the scene the refraction belongs to
  52850. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52851. */
  52852. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52853. /**
  52854. * Clone the refraction texture.
  52855. * @returns the cloned texture
  52856. */
  52857. clone(): RefractionTexture;
  52858. /**
  52859. * Serialize the texture to a JSON representation you could use in Parse later on
  52860. * @returns the serialized JSON representation
  52861. */
  52862. serialize(): any;
  52863. }
  52864. }
  52865. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52866. import { Nullable } from "babylonjs/types";
  52867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52868. import { Matrix } from "babylonjs/Maths/math";
  52869. import { Engine } from "babylonjs/Engines/engine";
  52870. import { Scene } from "babylonjs/scene";
  52871. /**
  52872. * Defines the options related to the creation of an HtmlElementTexture
  52873. */
  52874. export interface IHtmlElementTextureOptions {
  52875. /**
  52876. * Defines wether mip maps should be created or not.
  52877. */
  52878. generateMipMaps?: boolean;
  52879. /**
  52880. * Defines the sampling mode of the texture.
  52881. */
  52882. samplingMode?: number;
  52883. /**
  52884. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52885. */
  52886. engine: Nullable<Engine>;
  52887. /**
  52888. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52889. */
  52890. scene: Nullable<Scene>;
  52891. }
  52892. /**
  52893. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52894. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52895. * is automatically managed.
  52896. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52897. * in your application.
  52898. *
  52899. * As the update is not automatic, you need to call them manually.
  52900. */
  52901. export class HtmlElementTexture extends BaseTexture {
  52902. /**
  52903. * The texture URL.
  52904. */
  52905. element: HTMLVideoElement | HTMLCanvasElement;
  52906. private static readonly DefaultOptions;
  52907. private _textureMatrix;
  52908. private _engine;
  52909. private _isVideo;
  52910. private _generateMipMaps;
  52911. private _samplingMode;
  52912. /**
  52913. * Instantiates a HtmlElementTexture from the following parameters.
  52914. *
  52915. * @param name Defines the name of the texture
  52916. * @param element Defines the video or canvas the texture is filled with
  52917. * @param options Defines the other none mandatory texture creation options
  52918. */
  52919. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52920. private _createInternalTexture;
  52921. /**
  52922. * Returns the texture matrix used in most of the material.
  52923. */
  52924. getTextureMatrix(): Matrix;
  52925. /**
  52926. * Updates the content of the texture.
  52927. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52928. */
  52929. update(invertY?: Nullable<boolean>): void;
  52930. }
  52931. }
  52932. declare module "babylonjs/Materials/Textures/index" {
  52933. export * from "babylonjs/Materials/Textures/baseTexture";
  52934. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52935. export * from "babylonjs/Materials/Textures/cubeTexture";
  52936. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52937. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52938. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52939. export * from "babylonjs/Materials/Textures/internalTexture";
  52940. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52941. export * from "babylonjs/Materials/Textures/Loaders/index";
  52942. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52943. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52944. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52945. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52946. export * from "babylonjs/Materials/Textures/rawTexture";
  52947. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52948. export * from "babylonjs/Materials/Textures/refractionTexture";
  52949. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  52950. export * from "babylonjs/Materials/Textures/texture";
  52951. export * from "babylonjs/Materials/Textures/videoTexture";
  52952. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  52953. }
  52954. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  52955. /**
  52956. * Enum used to define the target of a block
  52957. */
  52958. export enum NodeMaterialBlockTargets {
  52959. /** Vertex shader */
  52960. Vertex = 1,
  52961. /** Fragment shader */
  52962. Fragment = 2,
  52963. /** Vertex and Fragment */
  52964. VertexAndFragment = 3
  52965. }
  52966. }
  52967. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  52968. /**
  52969. * Defines the kind of connection point for node based material
  52970. */
  52971. export enum NodeMaterialBlockConnectionPointTypes {
  52972. /** Float */
  52973. Float = 1,
  52974. /** Int */
  52975. Int = 2,
  52976. /** Vector2 */
  52977. Vector2 = 4,
  52978. /** Vector3 */
  52979. Vector3 = 8,
  52980. /** Vector4 */
  52981. Vector4 = 16,
  52982. /** Color3 */
  52983. Color3 = 32,
  52984. /** Color4 */
  52985. Color4 = 64,
  52986. /** Matrix */
  52987. Matrix = 128,
  52988. /** Texture */
  52989. Texture = 256,
  52990. /** Texture3D */
  52991. Texture3D = 512,
  52992. /** Vector3 or Color3 */
  52993. Vector3OrColor3 = 40,
  52994. /** Vector3 or Vector4 */
  52995. Vector3OrVector4 = 24,
  52996. /** Vector4 or Color4 */
  52997. Vector4OrColor4 = 80,
  52998. /** Color3 or Color4 */
  52999. Color3OrColor4 = 96,
  53000. /** Vector3 or Color3 */
  53001. Vector3OrColor3OrVector4OrColor4 = 120,
  53002. /** Detect type based on connection */
  53003. AutoDetect = 1024,
  53004. /** Output type that will be defined by input type */
  53005. BasedOnInput = 2048,
  53006. /** Light */
  53007. Light = 4096
  53008. }
  53009. }
  53010. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  53011. /**
  53012. * Enum used to define well known values e.g. values automatically provided by the system
  53013. */
  53014. export enum NodeMaterialWellKnownValues {
  53015. /** World */
  53016. World = 1,
  53017. /** View */
  53018. View = 2,
  53019. /** Projection */
  53020. Projection = 3,
  53021. /** ViewProjection */
  53022. ViewProjection = 4,
  53023. /** WorldView */
  53024. WorldView = 5,
  53025. /** WorldViewProjection */
  53026. WorldViewProjection = 6,
  53027. /** CameraPosition */
  53028. CameraPosition = 7,
  53029. /** Will be filled by the block itself */
  53030. Automatic = 8
  53031. }
  53032. }
  53033. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  53034. /**
  53035. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53036. */
  53037. export enum NodeMaterialBlockConnectionPointMode {
  53038. /** Value is an uniform */
  53039. Uniform = 0,
  53040. /** Value is a mesh attribute */
  53041. Attribute = 1,
  53042. /** Value is a varying between vertex and fragment shaders */
  53043. Varying = 2,
  53044. /** Mode is undefined */
  53045. Undefined = 3
  53046. }
  53047. }
  53048. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  53049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53051. /**
  53052. * Class used to store shared data between 2 NodeMaterialBuildState
  53053. */
  53054. export class NodeMaterialBuildStateSharedData {
  53055. /**
  53056. * Gets the list of emitted varyings
  53057. */
  53058. varyings: string[];
  53059. /**
  53060. * Gets the varying declaration string
  53061. */
  53062. varyingDeclaration: string;
  53063. /**
  53064. * Uniform connection points
  53065. */
  53066. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  53067. /**
  53068. * Bindable blocks (Blocks that need to set data to the effect)
  53069. */
  53070. bindableBlocks: NodeMaterialBlock[];
  53071. /**
  53072. * List of blocks that can provide a compilation fallback
  53073. */
  53074. blocksWithFallbacks: NodeMaterialBlock[];
  53075. /**
  53076. * List of blocks that can provide a define update
  53077. */
  53078. blocksWithDefines: NodeMaterialBlock[];
  53079. /**
  53080. * List of blocks that can provide a repeatable content
  53081. */
  53082. repeatableContentBlocks: NodeMaterialBlock[];
  53083. /**
  53084. * List of blocks that can provide a dynamic list of uniforms
  53085. */
  53086. dynamicUniformBlocks: NodeMaterialBlock[];
  53087. /**
  53088. * List of blocks that can block the isReady function for the material
  53089. */
  53090. blockingBlocks: NodeMaterialBlock[];
  53091. /**
  53092. * Build Id used to avoid multiple recompilations
  53093. */
  53094. buildId: number;
  53095. /** List of emitted variables */
  53096. variableNames: {
  53097. [key: string]: number;
  53098. };
  53099. /** List of emitted defines */
  53100. defineNames: {
  53101. [key: string]: number;
  53102. };
  53103. /** Should emit comments? */
  53104. emitComments: boolean;
  53105. /** Emit build activity */
  53106. verbose: boolean;
  53107. /**
  53108. * Gets the compilation hints emitted at compilation time
  53109. */
  53110. hints: {
  53111. needWorldViewMatrix: boolean;
  53112. needWorldViewProjectionMatrix: boolean;
  53113. needAlphaBlending: boolean;
  53114. needAlphaTesting: boolean;
  53115. };
  53116. /**
  53117. * List of compilation checks
  53118. */
  53119. checks: {
  53120. emitVertex: boolean;
  53121. emitFragment: boolean;
  53122. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53123. };
  53124. /** Creates a new shared data */
  53125. constructor();
  53126. /**
  53127. * Emits console errors and exceptions if there is a failing check
  53128. */
  53129. emitErrors(): void;
  53130. }
  53131. }
  53132. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  53133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53134. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53135. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53136. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  53137. import { Nullable } from "babylonjs/types";
  53138. /**
  53139. * Class used to store node based material build state
  53140. */
  53141. export class NodeMaterialBuildState {
  53142. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53143. supportUniformBuffers: boolean;
  53144. /**
  53145. * Gets the list of emitted attributes
  53146. */
  53147. attributes: string[];
  53148. /**
  53149. * Gets the list of emitted uniforms
  53150. */
  53151. uniforms: string[];
  53152. /**
  53153. * Gets the list of emitted uniform buffers
  53154. */
  53155. uniformBuffers: string[];
  53156. /**
  53157. * Gets the list of emitted samplers
  53158. */
  53159. samplers: string[];
  53160. /**
  53161. * Gets the list of emitted functions
  53162. */
  53163. functions: {
  53164. [key: string]: string;
  53165. };
  53166. /**
  53167. * Gets the target of the compilation state
  53168. */
  53169. target: NodeMaterialBlockTargets;
  53170. /**
  53171. * Gets the list of emitted counters
  53172. */
  53173. counters: {
  53174. [key: string]: number;
  53175. };
  53176. /**
  53177. * Shared data between multiple NodeMaterialBuildState instances
  53178. */
  53179. sharedData: NodeMaterialBuildStateSharedData;
  53180. /** @hidden */
  53181. _vertexState: NodeMaterialBuildState;
  53182. private _attributeDeclaration;
  53183. private _uniformDeclaration;
  53184. private _samplerDeclaration;
  53185. private _varyingTransfer;
  53186. private _repeatableContentAnchorIndex;
  53187. /** @hidden */
  53188. _builtCompilationString: string;
  53189. /**
  53190. * Gets the emitted compilation strings
  53191. */
  53192. compilationString: string;
  53193. /**
  53194. * Finalize the compilation strings
  53195. * @param state defines the current compilation state
  53196. */
  53197. finalize(state: NodeMaterialBuildState): void;
  53198. /** @hidden */
  53199. readonly _repeatableContentAnchor: string;
  53200. /** @hidden */
  53201. _getFreeVariableName(prefix: string): string;
  53202. /** @hidden */
  53203. _getFreeDefineName(prefix: string): string;
  53204. /** @hidden */
  53205. _excludeVariableName(name: string): void;
  53206. /** @hidden */
  53207. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53208. /** @hidden */
  53209. _emitFunction(name: string, code: string, comments: string): void;
  53210. /** @hidden */
  53211. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53212. replaceStrings?: {
  53213. search: RegExp;
  53214. replace: string;
  53215. }[];
  53216. repeatKey?: string;
  53217. }): string;
  53218. /** @hidden */
  53219. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53220. repeatKey?: string;
  53221. removeAttributes?: boolean;
  53222. removeUniforms?: boolean;
  53223. removeVaryings?: boolean;
  53224. removeIfDef?: boolean;
  53225. replaceStrings?: {
  53226. search: RegExp;
  53227. replace: string;
  53228. }[];
  53229. }, storeKey?: string): void;
  53230. /** @hidden */
  53231. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  53232. private _emitDefine;
  53233. /** @hidden */
  53234. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  53235. }
  53236. }
  53237. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53238. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53239. /**
  53240. * Root class for all node material optimizers
  53241. */
  53242. export class NodeMaterialOptimizer {
  53243. /**
  53244. * Function used to optimize a NodeMaterial graph
  53245. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53246. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53247. */
  53248. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53249. }
  53250. }
  53251. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53252. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53253. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53254. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53255. /**
  53256. * Block used to transform a vector4 with a matrix
  53257. */
  53258. export class Vector4TransformBlock extends NodeMaterialBlock {
  53259. /**
  53260. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53261. */
  53262. complementW: number;
  53263. /**
  53264. * Creates a new Vector4TransformBlock
  53265. * @param name defines the block name
  53266. */
  53267. constructor(name: string);
  53268. /**
  53269. * Gets the current class name
  53270. * @returns the class name
  53271. */
  53272. getClassName(): string;
  53273. /**
  53274. * Gets the vector input
  53275. */
  53276. readonly vector: NodeMaterialConnectionPoint;
  53277. /**
  53278. * Gets the output component
  53279. */
  53280. readonly output: NodeMaterialConnectionPoint;
  53281. /**
  53282. * Gets the matrix transform input
  53283. */
  53284. readonly transform: NodeMaterialConnectionPoint;
  53285. protected _buildBlock(state: NodeMaterialBuildState): this;
  53286. }
  53287. }
  53288. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53289. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53290. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53291. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53292. /**
  53293. * Block used to output the vertex position
  53294. */
  53295. export class VertexOutputBlock extends NodeMaterialBlock {
  53296. /**
  53297. * Creates a new VertexOutputBlock
  53298. * @param name defines the block name
  53299. */
  53300. constructor(name: string);
  53301. /**
  53302. * Gets the current class name
  53303. * @returns the class name
  53304. */
  53305. getClassName(): string;
  53306. /**
  53307. * Gets the vector input component
  53308. */
  53309. readonly vector: NodeMaterialConnectionPoint;
  53310. protected _buildBlock(state: NodeMaterialBuildState): this;
  53311. }
  53312. }
  53313. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53314. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53315. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53316. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53317. /**
  53318. * Block used to output the final color
  53319. */
  53320. export class FragmentOutputBlock extends NodeMaterialBlock {
  53321. /**
  53322. * Gets or sets a boolean indicating if this block will output an alpha value
  53323. */
  53324. alphaBlendingEnabled: boolean;
  53325. /**
  53326. * Create a new FragmentOutputBlock
  53327. * @param name defines the block name
  53328. */
  53329. constructor(name: string);
  53330. /**
  53331. * Gets the current class name
  53332. * @returns the class name
  53333. */
  53334. getClassName(): string;
  53335. /**
  53336. * Gets the color input component
  53337. */
  53338. readonly color: NodeMaterialConnectionPoint;
  53339. protected _buildBlock(state: NodeMaterialBuildState): this;
  53340. }
  53341. }
  53342. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53343. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53344. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53345. import { Scene } from "babylonjs/scene";
  53346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53347. import { Matrix } from "babylonjs/Maths/math";
  53348. import { Mesh } from "babylonjs/Meshes/mesh";
  53349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53350. import { Observable } from "babylonjs/Misc/observable";
  53351. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53352. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53353. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53354. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53355. import { Nullable } from "babylonjs/types";
  53356. /**
  53357. * Interface used to configure the node material editor
  53358. */
  53359. export interface INodeMaterialEditorOptions {
  53360. /** Define the URl to load node editor script */
  53361. editorURL?: string;
  53362. }
  53363. /** @hidden */
  53364. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53365. /** BONES */
  53366. NUM_BONE_INFLUENCERS: number;
  53367. BonesPerMesh: number;
  53368. BONETEXTURE: boolean;
  53369. /** MORPH TARGETS */
  53370. MORPHTARGETS: boolean;
  53371. MORPHTARGETS_NORMAL: boolean;
  53372. MORPHTARGETS_TANGENT: boolean;
  53373. MORPHTARGETS_UV: boolean;
  53374. NUM_MORPH_INFLUENCERS: number;
  53375. /** IMAGE PROCESSING */
  53376. IMAGEPROCESSING: boolean;
  53377. VIGNETTE: boolean;
  53378. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53379. VIGNETTEBLENDMODEOPAQUE: boolean;
  53380. TONEMAPPING: boolean;
  53381. TONEMAPPING_ACES: boolean;
  53382. CONTRAST: boolean;
  53383. EXPOSURE: boolean;
  53384. COLORCURVES: boolean;
  53385. COLORGRADING: boolean;
  53386. COLORGRADING3D: boolean;
  53387. SAMPLER3DGREENDEPTH: boolean;
  53388. SAMPLER3DBGRMAP: boolean;
  53389. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53390. constructor();
  53391. setValue(name: string, value: boolean): void;
  53392. }
  53393. /**
  53394. * Class used to configure NodeMaterial
  53395. */
  53396. export interface INodeMaterialOptions {
  53397. /**
  53398. * Defines if blocks should emit comments
  53399. */
  53400. emitComments: boolean;
  53401. }
  53402. /**
  53403. * Class used to create a node based material built by assembling shader blocks
  53404. */
  53405. export class NodeMaterial extends PushMaterial {
  53406. private _options;
  53407. private _vertexCompilationState;
  53408. private _fragmentCompilationState;
  53409. private _sharedData;
  53410. private _buildId;
  53411. private _buildWasSuccessful;
  53412. private _cachedWorldViewMatrix;
  53413. private _cachedWorldViewProjectionMatrix;
  53414. private _textureConnectionPoints;
  53415. private _optimizers;
  53416. /** Define the URl to load node editor script */
  53417. static EditorURL: string;
  53418. private BJSNODEMATERIALEDITOR;
  53419. /** Get the inspector from bundle or global */
  53420. private _getGlobalNodeMaterialEditor;
  53421. /**
  53422. * Defines the maximum number of lights that can be used in the material
  53423. */
  53424. maxSimultaneousLights: number;
  53425. /**
  53426. * Observable raised when the material is built
  53427. */
  53428. onBuildObservable: Observable<NodeMaterial>;
  53429. /**
  53430. * Gets or sets the root nodes of the material vertex shader
  53431. */
  53432. _vertexOutputNodes: NodeMaterialBlock[];
  53433. /**
  53434. * Gets or sets the root nodes of the material fragment (pixel) shader
  53435. */
  53436. _fragmentOutputNodes: NodeMaterialBlock[];
  53437. /** Gets or sets options to control the node material overall behavior */
  53438. options: INodeMaterialOptions;
  53439. /**
  53440. * Default configuration related to image processing available in the standard Material.
  53441. */
  53442. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53443. /**
  53444. * Gets the image processing configuration used either in this material.
  53445. */
  53446. /**
  53447. * Sets the Default image processing configuration used either in the this material.
  53448. *
  53449. * If sets to null, the scene one is in use.
  53450. */
  53451. imageProcessingConfiguration: ImageProcessingConfiguration;
  53452. /**
  53453. * Create a new node based material
  53454. * @param name defines the material name
  53455. * @param scene defines the hosting scene
  53456. * @param options defines creation option
  53457. */
  53458. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53459. /**
  53460. * Gets the current class name of the material e.g. "NodeMaterial"
  53461. * @returns the class name
  53462. */
  53463. getClassName(): string;
  53464. /**
  53465. * Keep track of the image processing observer to allow dispose and replace.
  53466. */
  53467. private _imageProcessingObserver;
  53468. /**
  53469. * Attaches a new image processing configuration to the Standard Material.
  53470. * @param configuration
  53471. */
  53472. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53473. /**
  53474. * Adds a new optimizer to the list of optimizers
  53475. * @param optimizer defines the optimizers to add
  53476. * @returns the current material
  53477. */
  53478. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53479. /**
  53480. * Remove an optimizer from the list of optimizers
  53481. * @param optimizer defines the optimizers to remove
  53482. * @returns the current material
  53483. */
  53484. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53485. /**
  53486. * Add a new block to the list of output nodes
  53487. * @param node defines the node to add
  53488. * @returns the current material
  53489. */
  53490. addOutputNode(node: NodeMaterialBlock): this;
  53491. /**
  53492. * Remove a block from the list of root nodes
  53493. * @param node defines the node to remove
  53494. * @returns the current material
  53495. */
  53496. removeOutputNode(node: NodeMaterialBlock): this;
  53497. private _addVertexOutputNode;
  53498. private _removeVertexOutputNode;
  53499. private _addFragmentOutputNode;
  53500. private _removeFragmentOutputNode;
  53501. /**
  53502. * Specifies if the material will require alpha blending
  53503. * @returns a boolean specifying if alpha blending is needed
  53504. */
  53505. needAlphaBlending(): boolean;
  53506. /**
  53507. * Specifies if this material should be rendered in alpha test mode
  53508. * @returns a boolean specifying if an alpha test is needed.
  53509. */
  53510. needAlphaTesting(): boolean;
  53511. private _initializeBlock;
  53512. private _resetDualBlocks;
  53513. /**
  53514. * Build the material and generates the inner effect
  53515. * @param verbose defines if the build should log activity
  53516. */
  53517. build(verbose?: boolean): void;
  53518. /**
  53519. * Runs an otpimization phase to try to improve the shader code
  53520. */
  53521. optimize(): void;
  53522. private _prepareDefinesForAttributes;
  53523. /**
  53524. * Get if the submesh is ready to be used and all its information available.
  53525. * Child classes can use it to update shaders
  53526. * @param mesh defines the mesh to check
  53527. * @param subMesh defines which submesh to check
  53528. * @param useInstances specifies that instances should be used
  53529. * @returns a boolean indicating that the submesh is ready or not
  53530. */
  53531. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53532. /**
  53533. * Binds the world matrix to the material
  53534. * @param world defines the world transformation matrix
  53535. */
  53536. bindOnlyWorldMatrix(world: Matrix): void;
  53537. /**
  53538. * Binds the submesh to this material by preparing the effect and shader to draw
  53539. * @param world defines the world transformation matrix
  53540. * @param mesh defines the mesh containing the submesh
  53541. * @param subMesh defines the submesh to bind the material to
  53542. */
  53543. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53544. /**
  53545. * Gets the active textures from the material
  53546. * @returns an array of textures
  53547. */
  53548. getActiveTextures(): BaseTexture[];
  53549. /**
  53550. * Specifies if the material uses a texture
  53551. * @param texture defines the texture to check against the material
  53552. * @returns a boolean specifying if the material uses the texture
  53553. */
  53554. hasTexture(texture: BaseTexture): boolean;
  53555. /**
  53556. * Disposes the material
  53557. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53558. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53559. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53560. */
  53561. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53562. /** Creates the node editor window. */
  53563. private _createNodeEditor;
  53564. /**
  53565. * Launch the node material editor
  53566. * @param config Define the configuration of the editor
  53567. * @return a promise fulfilled when the node editor is visible
  53568. */
  53569. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53570. /**
  53571. * Clear the current material
  53572. */
  53573. clear(): void;
  53574. /**
  53575. * Clear the current material and set it to a default state
  53576. */
  53577. setToDefault(): void;
  53578. }
  53579. }
  53580. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53581. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53583. import { Nullable } from "babylonjs/types";
  53584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53585. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53586. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53588. import { Mesh } from "babylonjs/Meshes/mesh";
  53589. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53590. /**
  53591. * Defines a block that can be used inside a node based material
  53592. */
  53593. export class NodeMaterialBlock {
  53594. private _buildId;
  53595. private _target;
  53596. private _isFinalMerger;
  53597. /** @hidden */
  53598. _inputs: NodeMaterialConnectionPoint[];
  53599. /** @hidden */
  53600. _outputs: NodeMaterialConnectionPoint[];
  53601. /**
  53602. * Gets or sets the name of the block
  53603. */
  53604. name: string;
  53605. /**
  53606. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53607. */
  53608. readonly isFinalMerger: boolean;
  53609. /**
  53610. * Gets or sets the build Id
  53611. */
  53612. buildId: number;
  53613. /**
  53614. * Gets or sets the target of the block
  53615. */
  53616. target: NodeMaterialBlockTargets;
  53617. /**
  53618. * Gets the list of input points
  53619. */
  53620. readonly inputs: NodeMaterialConnectionPoint[];
  53621. /** Gets the list of output points */
  53622. readonly outputs: NodeMaterialConnectionPoint[];
  53623. /**
  53624. * Find an input by its name
  53625. * @param name defines the name of the input to look for
  53626. * @returns the input or null if not found
  53627. */
  53628. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53629. /**
  53630. * Find an output by its name
  53631. * @param name defines the name of the outputto look for
  53632. * @returns the output or null if not found
  53633. */
  53634. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53635. /**
  53636. * Creates a new NodeMaterialBlock
  53637. * @param name defines the block name
  53638. * @param target defines the target of that block (Vertex by default)
  53639. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53640. */
  53641. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  53642. /**
  53643. * Initialize the block and prepare the context for build
  53644. * @param state defines the state that will be used for the build
  53645. */
  53646. initialize(state: NodeMaterialBuildState): void;
  53647. /**
  53648. * Bind data to effect. Will only be called for blocks with isBindable === true
  53649. * @param effect defines the effect to bind data to
  53650. * @param nodeMaterial defines the hosting NodeMaterial
  53651. * @param mesh defines the mesh that will be rendered
  53652. */
  53653. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53654. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53655. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53656. protected _writeFloat(value: number): string;
  53657. /**
  53658. * Gets the current class name e.g. "NodeMaterialBlock"
  53659. * @returns the class name
  53660. */
  53661. getClassName(): string;
  53662. /**
  53663. * Register a new input. Must be called inside a block constructor
  53664. * @param name defines the connection point name
  53665. * @param type defines the connection point type
  53666. * @param isOptional defines a boolean indicating that this input can be omitted
  53667. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53668. * @returns the current block
  53669. */
  53670. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53671. /**
  53672. * Register a new output. Must be called inside a block constructor
  53673. * @param name defines the connection point name
  53674. * @param type defines the connection point type
  53675. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53676. * @returns the current block
  53677. */
  53678. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53679. /**
  53680. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53681. * @param forOutput defines an optional connection point to check compatibility with
  53682. * @returns the first available input or null
  53683. */
  53684. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53685. /**
  53686. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53687. * @param forBlock defines an optional block to check compatibility with
  53688. * @returns the first available input or null
  53689. */
  53690. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53691. /**
  53692. * Connect current block with another block
  53693. * @param other defines the block to connect with
  53694. * @param options define the various options to help pick the right connections
  53695. * @returns the current block
  53696. */
  53697. connectTo(other: NodeMaterialBlock, options?: {
  53698. input?: string;
  53699. output?: string;
  53700. outputSwizzle?: string;
  53701. }): this | undefined;
  53702. protected _buildBlock(state: NodeMaterialBuildState): void;
  53703. /**
  53704. * Add uniforms, samplers and uniform buffers at compilation time
  53705. * @param state defines the state to update
  53706. * @param nodeMaterial defines the node material requesting the update
  53707. * @param defines defines the material defines to update
  53708. */
  53709. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53710. /**
  53711. * Add potential fallbacks if shader compilation fails
  53712. * @param mesh defines the mesh to be rendered
  53713. * @param fallbacks defines the current prioritized list of fallbacks
  53714. */
  53715. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53716. /**
  53717. * Update defines for shader compilation
  53718. * @param mesh defines the mesh to be rendered
  53719. * @param nodeMaterial defines the node material requesting the update
  53720. * @param defines defines the material defines to update
  53721. * @param useInstances specifies that instances should be used
  53722. */
  53723. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53724. /**
  53725. * Lets the block try to connect some inputs automatically
  53726. */
  53727. autoConfigure(): void;
  53728. /**
  53729. * Function called when a block is declared as repeatable content generator
  53730. * @param vertexShaderState defines the current compilation state for the vertex shader
  53731. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53732. * @param mesh defines the mesh to be rendered
  53733. * @param defines defines the material defines to update
  53734. */
  53735. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53736. /**
  53737. * Checks if the block is ready
  53738. * @param mesh defines the mesh to be rendered
  53739. * @param nodeMaterial defines the node material requesting the update
  53740. * @param defines defines the material defines to update
  53741. * @param useInstances specifies that instances should be used
  53742. * @returns true if the block is ready
  53743. */
  53744. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53745. /**
  53746. * Compile the current node and generate the shader code
  53747. * @param state defines the current compilation state (uniforms, samplers, current string)
  53748. * @returns the current block
  53749. */
  53750. build(state: NodeMaterialBuildState): this | undefined;
  53751. }
  53752. }
  53753. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  53754. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53755. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53756. import { Nullable } from "babylonjs/types";
  53757. import { Effect } from "babylonjs/Materials/effect";
  53758. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53759. import { Scene } from "babylonjs/scene";
  53760. import { Matrix } from "babylonjs/Maths/math";
  53761. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53762. /**
  53763. * Defines a connection point for a block
  53764. */
  53765. export class NodeMaterialConnectionPoint {
  53766. /** @hidden */
  53767. _ownerBlock: NodeMaterialBlock;
  53768. /** @hidden */
  53769. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53770. private _associatedVariableName;
  53771. private _endpoints;
  53772. private _storedValue;
  53773. private _valueCallback;
  53774. private _mode;
  53775. /** @hidden */
  53776. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53777. /** @hidden */
  53778. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53779. /** @hidden */
  53780. _needToEmitVarying: boolean;
  53781. /** @hidden */
  53782. _forceUniformInVertexShaderOnly: boolean;
  53783. private _type;
  53784. /**
  53785. * Gets or sets the connection point type (default is float)
  53786. */
  53787. type: NodeMaterialBlockConnectionPointTypes;
  53788. /**
  53789. * Gets or sets the connection point name
  53790. */
  53791. name: string;
  53792. /**
  53793. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53794. */
  53795. swizzle: string;
  53796. /**
  53797. * Gets or sets a boolean indicating that this connection point can be omitted
  53798. */
  53799. isOptional: boolean;
  53800. /**
  53801. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53802. */
  53803. define: string;
  53804. /** Gets or sets the target of that connection point */
  53805. target: NodeMaterialBlockTargets;
  53806. /**
  53807. * Gets or sets the value of that point.
  53808. * Please note that this value will be ignored if valueCallback is defined
  53809. */
  53810. value: any;
  53811. /**
  53812. * Gets or sets a callback used to get the value of that point.
  53813. * Please note that setting this value will force the connection point to ignore the value property
  53814. */
  53815. valueCallback: () => any;
  53816. /**
  53817. * Gets or sets the associated variable name in the shader
  53818. */
  53819. associatedVariableName: string;
  53820. /**
  53821. * Gets a boolean indicating that this connection point not defined yet
  53822. */
  53823. readonly isUndefined: boolean;
  53824. /**
  53825. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53826. * In this case the connection point name must be the name of the uniform to use.
  53827. * Can only be set on inputs
  53828. */
  53829. isUniform: boolean;
  53830. /**
  53831. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53832. * In this case the connection point name must be the name of the attribute to use
  53833. * Can only be set on inputs
  53834. */
  53835. isAttribute: boolean;
  53836. /**
  53837. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53838. * Can only be set on exit points
  53839. */
  53840. isVarying: boolean;
  53841. /** Get the other side of the connection (if any) */
  53842. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53843. /** Get the block that owns this connection point */
  53844. readonly ownerBlock: NodeMaterialBlock;
  53845. /** Get the block connected on the other side of this connection (if any) */
  53846. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53847. /** Get the block connected on the endpoints of this connection (if any) */
  53848. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53849. /**
  53850. * Creates a new connection point
  53851. * @param name defines the connection point name
  53852. * @param ownerBlock defines the block hosting this connection point
  53853. */
  53854. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53855. /**
  53856. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53857. * @returns the class name
  53858. */
  53859. getClassName(): string;
  53860. /**
  53861. * Set the source of this connection point to a vertex attribute
  53862. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53863. * @returns the current connection point
  53864. */
  53865. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53866. /**
  53867. * Set the source of this connection point to a well known value
  53868. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53869. * @returns the current connection point
  53870. */
  53871. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53872. /**
  53873. * Gets a boolean indicating that the current connection point is a well known value
  53874. */
  53875. readonly isWellKnownValue: boolean;
  53876. /**
  53877. * Gets or sets the current well known value or null if not defined as well know value
  53878. */
  53879. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53880. private _getTypeLength;
  53881. /**
  53882. * Gets an boolean indicating if the current point can be connected to another point
  53883. * @param connectionPoint defines the other connection point
  53884. * @returns true if the connection is possible
  53885. */
  53886. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53887. /**
  53888. * Connect this point to another connection point
  53889. * @param connectionPoint defines the other connection point
  53890. * @returns the current connection point
  53891. */
  53892. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53893. /**
  53894. * Disconnect this point from one of his endpoint
  53895. * @param endpoint defines the other connection point
  53896. * @returns the current connection point
  53897. */
  53898. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53899. /**
  53900. * When connection point is an uniform, this function will send its value to the effect
  53901. * @param effect defines the effect to transmit value to
  53902. * @param world defines the world matrix
  53903. * @param worldView defines the worldxview matrix
  53904. * @param worldViewProjection defines the worldxviewxprojection matrix
  53905. */
  53906. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53907. /**
  53908. * When connection point is an uniform, this function will send its value to the effect
  53909. * @param effect defines the effect to transmit value to
  53910. * @param scene defines the hosting scene
  53911. */
  53912. transmit(effect: Effect, scene: Scene): void;
  53913. }
  53914. }
  53915. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53916. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53917. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53919. import { Mesh } from "babylonjs/Meshes/mesh";
  53920. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53921. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53922. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53923. /**
  53924. * Block used to add support for vertex skinning (bones)
  53925. */
  53926. export class BonesBlock extends NodeMaterialBlock {
  53927. /**
  53928. * Creates a new BonesBlock
  53929. * @param name defines the block name
  53930. */
  53931. constructor(name: string);
  53932. /**
  53933. * Initialize the block and prepare the context for build
  53934. * @param state defines the state that will be used for the build
  53935. */
  53936. initialize(state: NodeMaterialBuildState): void;
  53937. /**
  53938. * Gets the current class name
  53939. * @returns the class name
  53940. */
  53941. getClassName(): string;
  53942. /**
  53943. * Gets the matrix indices input component
  53944. */
  53945. readonly matricesIndices: NodeMaterialConnectionPoint;
  53946. /**
  53947. * Gets the matrix weights input component
  53948. */
  53949. readonly matricesWeights: NodeMaterialConnectionPoint;
  53950. /**
  53951. * Gets the extra matrix indices input component
  53952. */
  53953. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53954. /**
  53955. * Gets the extra matrix weights input component
  53956. */
  53957. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53958. /**
  53959. * Gets the world input component
  53960. */
  53961. readonly world: NodeMaterialConnectionPoint;
  53962. /**
  53963. * Gets the output component
  53964. */
  53965. readonly output: NodeMaterialConnectionPoint;
  53966. autoConfigure(): void;
  53967. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53968. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53969. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53970. protected _buildBlock(state: NodeMaterialBuildState): this;
  53971. }
  53972. }
  53973. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  53974. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53975. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53976. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53978. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53979. /**
  53980. * Block used to add support for instances
  53981. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53982. */
  53983. export class InstancesBlock extends NodeMaterialBlock {
  53984. /**
  53985. * Creates a new InstancesBlock
  53986. * @param name defines the block name
  53987. */
  53988. constructor(name: string);
  53989. /**
  53990. * Gets the current class name
  53991. * @returns the class name
  53992. */
  53993. getClassName(): string;
  53994. /**
  53995. * Gets the first world row input component
  53996. */
  53997. readonly world0: NodeMaterialConnectionPoint;
  53998. /**
  53999. * Gets the second world row input component
  54000. */
  54001. readonly world1: NodeMaterialConnectionPoint;
  54002. /**
  54003. * Gets the third world row input component
  54004. */
  54005. readonly world2: NodeMaterialConnectionPoint;
  54006. /**
  54007. * Gets the forth world row input component
  54008. */
  54009. readonly world3: NodeMaterialConnectionPoint;
  54010. /**
  54011. * Gets the world input component
  54012. */
  54013. readonly world: NodeMaterialConnectionPoint;
  54014. /**
  54015. * Gets the output component
  54016. */
  54017. readonly output: NodeMaterialConnectionPoint;
  54018. autoConfigure(): void;
  54019. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54020. protected _buildBlock(state: NodeMaterialBuildState): this;
  54021. }
  54022. }
  54023. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  54024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54028. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54029. import { Effect } from "babylonjs/Materials/effect";
  54030. import { Mesh } from "babylonjs/Meshes/mesh";
  54031. /**
  54032. * Block used to add morph targets support to vertex shader
  54033. */
  54034. export class MorphTargetsBlock extends NodeMaterialBlock {
  54035. private _repeatableContentAnchor;
  54036. private _repeatebleContentGenerated;
  54037. /**
  54038. * Create a new MorphTargetsBlock
  54039. * @param name defines the block name
  54040. */
  54041. constructor(name: string);
  54042. /**
  54043. * Gets the current class name
  54044. * @returns the class name
  54045. */
  54046. getClassName(): string;
  54047. /**
  54048. * Gets the position input component
  54049. */
  54050. readonly position: NodeMaterialConnectionPoint;
  54051. /**
  54052. * Gets the normal input component
  54053. */
  54054. readonly normal: NodeMaterialConnectionPoint;
  54055. /**
  54056. * Gets the tangent input component
  54057. */
  54058. readonly tangent: NodeMaterialConnectionPoint;
  54059. /**
  54060. * Gets the tangent input component
  54061. */
  54062. readonly uv: NodeMaterialConnectionPoint;
  54063. /**
  54064. * Gets the position output component
  54065. */
  54066. readonly positionOutput: NodeMaterialConnectionPoint;
  54067. /**
  54068. * Gets the normal output component
  54069. */
  54070. readonly normalOutput: NodeMaterialConnectionPoint;
  54071. /**
  54072. * Gets the tangent output component
  54073. */
  54074. readonly tangentOutput: NodeMaterialConnectionPoint;
  54075. /**
  54076. * Gets the tangent output component
  54077. */
  54078. readonly uvOutput: NodeMaterialConnectionPoint;
  54079. initialize(state: NodeMaterialBuildState): void;
  54080. autoConfigure(): void;
  54081. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54082. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54083. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54084. protected _buildBlock(state: NodeMaterialBuildState): this;
  54085. }
  54086. }
  54087. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54088. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54089. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54090. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54091. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54092. }
  54093. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54097. /**
  54098. * Block used to add an alpha test in the fragment shader
  54099. */
  54100. export class AlphaTestBlock extends NodeMaterialBlock {
  54101. /**
  54102. * Gets or sets the alpha value where alpha testing happens
  54103. */
  54104. alphaCutOff: number;
  54105. /**
  54106. * Create a new AlphaTestBlock
  54107. * @param name defines the block name
  54108. */
  54109. constructor(name: string);
  54110. /**
  54111. * Gets the current class name
  54112. * @returns the class name
  54113. */
  54114. getClassName(): string;
  54115. /**
  54116. * Gets the color input component
  54117. */
  54118. readonly color: NodeMaterialConnectionPoint;
  54119. protected _buildBlock(state: NodeMaterialBuildState): this;
  54120. }
  54121. }
  54122. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  54123. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54124. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54125. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54126. /**
  54127. * Block used to create a Color4 out of 4 inputs (one for each component)
  54128. */
  54129. export class RGBAMergerBlock extends NodeMaterialBlock {
  54130. /**
  54131. * Create a new RGBAMergerBlock
  54132. * @param name defines the block name
  54133. */
  54134. constructor(name: string);
  54135. /**
  54136. * Gets the current class name
  54137. * @returns the class name
  54138. */
  54139. getClassName(): string;
  54140. /**
  54141. * Gets the R input component
  54142. */
  54143. readonly r: NodeMaterialConnectionPoint;
  54144. /**
  54145. * Gets the G input component
  54146. */
  54147. readonly g: NodeMaterialConnectionPoint;
  54148. /**
  54149. * Gets the B input component
  54150. */
  54151. readonly b: NodeMaterialConnectionPoint;
  54152. /**
  54153. * Gets the RGB input component
  54154. */
  54155. readonly rgb: NodeMaterialConnectionPoint;
  54156. /**
  54157. * Gets the R input component
  54158. */
  54159. readonly a: NodeMaterialConnectionPoint;
  54160. /**
  54161. * Gets the output component
  54162. */
  54163. readonly output: NodeMaterialConnectionPoint;
  54164. protected _buildBlock(state: NodeMaterialBuildState): this;
  54165. }
  54166. }
  54167. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  54168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54171. /**
  54172. * Block used to create a Color3 out of 3 inputs (one for each component)
  54173. */
  54174. export class RGBMergerBlock extends NodeMaterialBlock {
  54175. /**
  54176. * Create a new RGBMergerBlock
  54177. * @param name defines the block name
  54178. */
  54179. constructor(name: string);
  54180. /**
  54181. * Gets the current class name
  54182. * @returns the class name
  54183. */
  54184. getClassName(): string;
  54185. /**
  54186. * Gets the R component input
  54187. */
  54188. readonly r: NodeMaterialConnectionPoint;
  54189. /**
  54190. * Gets the G component input
  54191. */
  54192. readonly g: NodeMaterialConnectionPoint;
  54193. /**
  54194. * Gets the B component input
  54195. */
  54196. readonly b: NodeMaterialConnectionPoint;
  54197. /**
  54198. * Gets the output component
  54199. */
  54200. readonly output: NodeMaterialConnectionPoint;
  54201. protected _buildBlock(state: NodeMaterialBuildState): this;
  54202. }
  54203. }
  54204. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  54205. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54206. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54207. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54208. /**
  54209. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  54210. */
  54211. export class RGBASplitterBlock extends NodeMaterialBlock {
  54212. /**
  54213. * Create a new RGBASplitterBlock
  54214. * @param name defines the block name
  54215. */
  54216. constructor(name: string);
  54217. /**
  54218. * Gets the current class name
  54219. * @returns the class name
  54220. */
  54221. getClassName(): string;
  54222. /**
  54223. * Gets the input component
  54224. */
  54225. readonly input: NodeMaterialConnectionPoint;
  54226. protected _buildBlock(state: NodeMaterialBuildState): this;
  54227. }
  54228. }
  54229. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  54230. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54231. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54232. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54233. /**
  54234. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  54235. */
  54236. export class RGBSplitterBlock extends NodeMaterialBlock {
  54237. /**
  54238. * Create a new RGBSplitterBlock
  54239. * @param name defines the block name
  54240. */
  54241. constructor(name: string);
  54242. /**
  54243. * Gets the current class name
  54244. * @returns the class name
  54245. */
  54246. getClassName(): string;
  54247. /**
  54248. * Gets the input component
  54249. */
  54250. readonly input: NodeMaterialConnectionPoint;
  54251. protected _buildBlock(state: NodeMaterialBuildState): this;
  54252. }
  54253. }
  54254. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  54255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54259. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54260. /**
  54261. * Block used to read a texture from a sampler
  54262. */
  54263. export class TextureBlock extends NodeMaterialBlock {
  54264. private _defineName;
  54265. /**
  54266. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  54267. */
  54268. autoConnectTextureMatrix: boolean;
  54269. /**
  54270. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  54271. */
  54272. autoSelectUV: boolean;
  54273. /**
  54274. * Create a new TextureBlock
  54275. * @param name defines the block name
  54276. */
  54277. constructor(name: string);
  54278. /**
  54279. * Gets the current class name
  54280. * @returns the class name
  54281. */
  54282. getClassName(): string;
  54283. /**
  54284. * Gets the uv input component
  54285. */
  54286. readonly uv: NodeMaterialConnectionPoint;
  54287. /**
  54288. * Gets the texture information input component
  54289. */
  54290. readonly textureInfo: NodeMaterialConnectionPoint;
  54291. /**
  54292. * Gets the transformed uv input component
  54293. */
  54294. readonly transformedUV: NodeMaterialConnectionPoint;
  54295. /**
  54296. * Gets the texture input component
  54297. */
  54298. readonly texture: NodeMaterialConnectionPoint;
  54299. /**
  54300. * Gets the texture transform input component
  54301. */
  54302. readonly textureTransform: NodeMaterialConnectionPoint;
  54303. /**
  54304. * Gets the output component
  54305. */
  54306. readonly output: NodeMaterialConnectionPoint;
  54307. autoConfigure(): void;
  54308. initialize(state: NodeMaterialBuildState): void;
  54309. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54310. isReady(): boolean;
  54311. private _injectVertexCode;
  54312. protected _buildBlock(state: NodeMaterialBuildState): this;
  54313. }
  54314. }
  54315. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  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. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54320. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54321. import { Effect } from "babylonjs/Materials/effect";
  54322. import { Mesh } from "babylonjs/Meshes/mesh";
  54323. /**
  54324. * Block used to add image processing support to fragment shader
  54325. */
  54326. export class ImageProcessingBlock extends NodeMaterialBlock {
  54327. /**
  54328. * Create a new ImageProcessingBlock
  54329. * @param name defines the block name
  54330. */
  54331. constructor(name: string);
  54332. /**
  54333. * Gets the current class name
  54334. * @returns the class name
  54335. */
  54336. getClassName(): string;
  54337. /**
  54338. * Gets the color input component
  54339. */
  54340. readonly color: NodeMaterialConnectionPoint;
  54341. /**
  54342. * Gets the output component
  54343. */
  54344. readonly output: NodeMaterialConnectionPoint;
  54345. /**
  54346. * Initialize the block and prepare the context for build
  54347. * @param state defines the state that will be used for the build
  54348. */
  54349. initialize(state: NodeMaterialBuildState): void;
  54350. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54351. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54352. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54353. protected _buildBlock(state: NodeMaterialBuildState): this;
  54354. }
  54355. }
  54356. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  54357. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  54358. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  54359. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  54360. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  54361. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  54362. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  54363. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  54364. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  54365. }
  54366. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  54367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54369. import { Mesh } from "babylonjs/Meshes/mesh";
  54370. import { Effect } from "babylonjs/Materials/effect";
  54371. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54373. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54374. /**
  54375. * Block used to add support for scene fog
  54376. */
  54377. export class FogBlock extends NodeMaterialBlock {
  54378. /**
  54379. * Create a new FogBlock
  54380. * @param name defines the block name
  54381. */
  54382. constructor(name: string);
  54383. /**
  54384. * Gets the current class name
  54385. * @returns the class name
  54386. */
  54387. getClassName(): string;
  54388. /**
  54389. * Gets the world position input component
  54390. */
  54391. readonly worldPosition: NodeMaterialConnectionPoint;
  54392. /**
  54393. * Gets the view input component
  54394. */
  54395. readonly view: NodeMaterialConnectionPoint;
  54396. /**
  54397. * Gets the color input component
  54398. */
  54399. readonly color: NodeMaterialConnectionPoint;
  54400. /**
  54401. * Gets the fog color input component
  54402. */
  54403. readonly fogColor: NodeMaterialConnectionPoint;
  54404. /**
  54405. * Gets the for parameter input component
  54406. */
  54407. readonly fogParameters: NodeMaterialConnectionPoint;
  54408. /**
  54409. * Gets the output component
  54410. */
  54411. readonly output: NodeMaterialConnectionPoint;
  54412. autoConfigure(): void;
  54413. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54414. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54415. protected _buildBlock(state: NodeMaterialBuildState): this;
  54416. }
  54417. }
  54418. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  54419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54423. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54424. import { Effect } from "babylonjs/Materials/effect";
  54425. import { Mesh } from "babylonjs/Meshes/mesh";
  54426. /**
  54427. * Block used to add light in the fragment shader
  54428. */
  54429. export class LightBlock extends NodeMaterialBlock {
  54430. private _lightId;
  54431. /**
  54432. * Create a new LightBlock
  54433. * @param name defines the block name
  54434. */
  54435. constructor(name: string);
  54436. /**
  54437. * Gets the current class name
  54438. * @returns the class name
  54439. */
  54440. getClassName(): string;
  54441. /**
  54442. * Gets the world position input component
  54443. */
  54444. readonly worldPosition: NodeMaterialConnectionPoint;
  54445. /**
  54446. * Gets the world normal input component
  54447. */
  54448. readonly worldNormal: NodeMaterialConnectionPoint;
  54449. /**
  54450. * Gets the light input component.
  54451. * If not defined, all lights will be considered
  54452. */
  54453. readonly light: NodeMaterialConnectionPoint;
  54454. /**
  54455. * Gets the camera (or eye) position component
  54456. */
  54457. readonly cameraPosition: NodeMaterialConnectionPoint;
  54458. /**
  54459. * Gets the diffuse output component
  54460. */
  54461. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54462. /**
  54463. * Gets the specular output component
  54464. */
  54465. readonly specularOutput: NodeMaterialConnectionPoint;
  54466. autoConfigure(): void;
  54467. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54468. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54469. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54470. private _injectVertexCode;
  54471. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54472. }
  54473. }
  54474. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  54475. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  54476. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  54477. }
  54478. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  54479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54480. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54482. /**
  54483. * Block used to multiply 2 vector4
  54484. */
  54485. export class MultiplyBlock extends NodeMaterialBlock {
  54486. /**
  54487. * Creates a new MultiplyBlock
  54488. * @param name defines the block name
  54489. */
  54490. constructor(name: string);
  54491. /**
  54492. * Gets the current class name
  54493. * @returns the class name
  54494. */
  54495. getClassName(): string;
  54496. /**
  54497. * Gets the left operand input component
  54498. */
  54499. readonly left: NodeMaterialConnectionPoint;
  54500. /**
  54501. * Gets the right operand input component
  54502. */
  54503. readonly right: NodeMaterialConnectionPoint;
  54504. /**
  54505. * Gets the output component
  54506. */
  54507. readonly output: NodeMaterialConnectionPoint;
  54508. protected _buildBlock(state: NodeMaterialBuildState): this;
  54509. }
  54510. }
  54511. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  54512. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54514. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54515. /**
  54516. * Block used to add 2 vector4
  54517. */
  54518. export class AddBlock extends NodeMaterialBlock {
  54519. /**
  54520. * Creates a new AddBlock
  54521. * @param name defines the block name
  54522. */
  54523. constructor(name: string);
  54524. /**
  54525. * Gets the current class name
  54526. * @returns the class name
  54527. */
  54528. getClassName(): string;
  54529. /**
  54530. * Gets the left operand input component
  54531. */
  54532. readonly left: NodeMaterialConnectionPoint;
  54533. /**
  54534. * Gets the right operand input component
  54535. */
  54536. readonly right: NodeMaterialConnectionPoint;
  54537. /**
  54538. * Gets the output component
  54539. */
  54540. readonly output: NodeMaterialConnectionPoint;
  54541. protected _buildBlock(state: NodeMaterialBuildState): this;
  54542. }
  54543. }
  54544. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  54545. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54546. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54547. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54548. /**
  54549. * Block used to clamp a float
  54550. */
  54551. export class ClampBlock extends NodeMaterialBlock {
  54552. /** Gets or sets the minimum range */
  54553. minimum: number;
  54554. /** Gets or sets the maximum range */
  54555. maximum: number;
  54556. /**
  54557. * Creates a new ClampBlock
  54558. * @param name defines the block name
  54559. */
  54560. constructor(name: string);
  54561. /**
  54562. * Gets the current class name
  54563. * @returns the class name
  54564. */
  54565. getClassName(): string;
  54566. /**
  54567. * Gets the value input component
  54568. */
  54569. readonly value: NodeMaterialConnectionPoint;
  54570. /**
  54571. * Gets the output component
  54572. */
  54573. readonly output: NodeMaterialConnectionPoint;
  54574. protected _buildBlock(state: NodeMaterialBuildState): this;
  54575. }
  54576. }
  54577. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  54578. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54580. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54581. /**
  54582. * Block used to scale a value
  54583. */
  54584. export class ScaleBlock extends NodeMaterialBlock {
  54585. /**
  54586. * Creates a new ScaleBlock
  54587. * @param name defines the block name
  54588. */
  54589. constructor(name: string);
  54590. /**
  54591. * Gets the current class name
  54592. * @returns the class name
  54593. */
  54594. getClassName(): string;
  54595. /**
  54596. * Gets the value operand input component
  54597. */
  54598. readonly value: NodeMaterialConnectionPoint;
  54599. /**
  54600. * Gets the scale operand input component
  54601. */
  54602. readonly scale: NodeMaterialConnectionPoint;
  54603. /**
  54604. * Gets the output component
  54605. */
  54606. readonly output: NodeMaterialConnectionPoint;
  54607. protected _buildBlock(state: NodeMaterialBuildState): this;
  54608. }
  54609. }
  54610. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  54611. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54612. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54613. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54614. /**
  54615. * Block used to transform a vector2 with a matrix
  54616. */
  54617. export class Vector2TransformBlock extends NodeMaterialBlock {
  54618. /**
  54619. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54620. */
  54621. complementZ: number;
  54622. /**
  54623. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54624. */
  54625. complementW: number;
  54626. /**
  54627. * Creates a new Vector2TransformBlock
  54628. * @param name defines the block name
  54629. */
  54630. constructor(name: string);
  54631. /**
  54632. * Gets the vector input
  54633. */
  54634. readonly vector: NodeMaterialConnectionPoint;
  54635. /**
  54636. * Gets the matrix transform input
  54637. */
  54638. readonly transform: NodeMaterialConnectionPoint;
  54639. /**
  54640. * Gets the output component
  54641. */
  54642. readonly output: NodeMaterialConnectionPoint;
  54643. /**
  54644. * Gets the current class name
  54645. * @returns the class name
  54646. */
  54647. getClassName(): string;
  54648. protected _buildBlock(state: NodeMaterialBuildState): this;
  54649. }
  54650. }
  54651. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54652. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54653. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54654. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54655. /**
  54656. * Block used to transform a vector3 with a matrix
  54657. */
  54658. export class Vector3TransformBlock extends NodeMaterialBlock {
  54659. /**
  54660. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54661. */
  54662. complement: number;
  54663. /**
  54664. * Creates a new Vector3TransformBlock
  54665. * @param name defines the block name
  54666. */
  54667. constructor(name: string);
  54668. /**
  54669. * Gets the vector input
  54670. */
  54671. readonly vector: NodeMaterialConnectionPoint;
  54672. /**
  54673. * Gets the matrix transform input
  54674. */
  54675. readonly transform: NodeMaterialConnectionPoint;
  54676. /**
  54677. * Gets the output component
  54678. */
  54679. readonly output: NodeMaterialConnectionPoint;
  54680. /**
  54681. * Gets the current class name
  54682. * @returns the class name
  54683. */
  54684. getClassName(): string;
  54685. protected _buildBlock(state: NodeMaterialBuildState): this;
  54686. }
  54687. }
  54688. declare module "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock" {
  54689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54692. /**
  54693. * Block used to multiply two matrices
  54694. */
  54695. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  54696. /**
  54697. * Creates a new MatrixMultiplicationBlock
  54698. * @param name defines the block name
  54699. */
  54700. constructor(name: string);
  54701. /**
  54702. * Gets the left operand
  54703. */
  54704. readonly left: NodeMaterialConnectionPoint;
  54705. /**
  54706. * Gets the right operand
  54707. */
  54708. readonly right: NodeMaterialConnectionPoint;
  54709. /**
  54710. * Gets the output component
  54711. */
  54712. readonly output: NodeMaterialConnectionPoint;
  54713. /**
  54714. * Gets the current class name
  54715. * @returns the class name
  54716. */
  54717. getClassName(): string;
  54718. protected _buildBlock(state: NodeMaterialBuildState): this;
  54719. }
  54720. }
  54721. declare module "babylonjs/Materials/Node/Blocks/index" {
  54722. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54723. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54724. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54725. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54726. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54727. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54728. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  54729. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54730. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54731. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54732. export * from "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock";
  54733. }
  54734. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54735. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54736. }
  54737. declare module "babylonjs/Materials/Node/index" {
  54738. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54739. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54740. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54741. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54742. export * from "babylonjs/Materials/Node/nodeMaterial";
  54743. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54744. export * from "babylonjs/Materials/Node/Blocks/index";
  54745. export * from "babylonjs/Materials/Node/Optimizers/index";
  54746. }
  54747. declare module "babylonjs/Materials/index" {
  54748. export * from "babylonjs/Materials/Background/index";
  54749. export * from "babylonjs/Materials/colorCurves";
  54750. export * from "babylonjs/Materials/effect";
  54751. export * from "babylonjs/Materials/fresnelParameters";
  54752. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54753. export * from "babylonjs/Materials/material";
  54754. export * from "babylonjs/Materials/materialDefines";
  54755. export * from "babylonjs/Materials/materialHelper";
  54756. export * from "babylonjs/Materials/multiMaterial";
  54757. export * from "babylonjs/Materials/PBR/index";
  54758. export * from "babylonjs/Materials/pushMaterial";
  54759. export * from "babylonjs/Materials/shaderMaterial";
  54760. export * from "babylonjs/Materials/standardMaterial";
  54761. export * from "babylonjs/Materials/Textures/index";
  54762. export * from "babylonjs/Materials/uniformBuffer";
  54763. export * from "babylonjs/Materials/materialFlags";
  54764. export * from "babylonjs/Materials/Node/index";
  54765. }
  54766. declare module "babylonjs/Maths/index" {
  54767. export * from "babylonjs/Maths/math.scalar";
  54768. export * from "babylonjs/Maths/math";
  54769. export * from "babylonjs/Maths/sphericalPolynomial";
  54770. }
  54771. declare module "babylonjs/Misc/workerPool" {
  54772. import { IDisposable } from "babylonjs/scene";
  54773. /**
  54774. * Helper class to push actions to a pool of workers.
  54775. */
  54776. export class WorkerPool implements IDisposable {
  54777. private _workerInfos;
  54778. private _pendingActions;
  54779. /**
  54780. * Constructor
  54781. * @param workers Array of workers to use for actions
  54782. */
  54783. constructor(workers: Array<Worker>);
  54784. /**
  54785. * Terminates all workers and clears any pending actions.
  54786. */
  54787. dispose(): void;
  54788. /**
  54789. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54790. * pended until a worker has completed its action.
  54791. * @param action The action to perform. Call onComplete when the action is complete.
  54792. */
  54793. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54794. private _execute;
  54795. }
  54796. }
  54797. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54798. import { IDisposable } from "babylonjs/scene";
  54799. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54800. /**
  54801. * Configuration for Draco compression
  54802. */
  54803. export interface IDracoCompressionConfiguration {
  54804. /**
  54805. * Configuration for the decoder.
  54806. */
  54807. decoder: {
  54808. /**
  54809. * The url to the WebAssembly module.
  54810. */
  54811. wasmUrl?: string;
  54812. /**
  54813. * The url to the WebAssembly binary.
  54814. */
  54815. wasmBinaryUrl?: string;
  54816. /**
  54817. * The url to the fallback JavaScript module.
  54818. */
  54819. fallbackUrl?: string;
  54820. };
  54821. }
  54822. /**
  54823. * Draco compression (https://google.github.io/draco/)
  54824. *
  54825. * This class wraps the Draco module.
  54826. *
  54827. * **Encoder**
  54828. *
  54829. * The encoder is not currently implemented.
  54830. *
  54831. * **Decoder**
  54832. *
  54833. * 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.
  54834. *
  54835. * To update the configuration, use the following code:
  54836. * ```javascript
  54837. * DracoCompression.Configuration = {
  54838. * decoder: {
  54839. * wasmUrl: "<url to the WebAssembly library>",
  54840. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54841. * fallbackUrl: "<url to the fallback JavaScript library>",
  54842. * }
  54843. * };
  54844. * ```
  54845. *
  54846. * 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.
  54847. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54848. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54849. *
  54850. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54851. * ```javascript
  54852. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54853. * ```
  54854. *
  54855. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54856. */
  54857. export class DracoCompression implements IDisposable {
  54858. private _workerPoolPromise?;
  54859. private _decoderModulePromise?;
  54860. /**
  54861. * The configuration. Defaults to the following urls:
  54862. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54863. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54864. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54865. */
  54866. static Configuration: IDracoCompressionConfiguration;
  54867. /**
  54868. * Returns true if the decoder configuration is available.
  54869. */
  54870. static readonly DecoderAvailable: boolean;
  54871. /**
  54872. * Default number of workers to create when creating the draco compression object.
  54873. */
  54874. static DefaultNumWorkers: number;
  54875. private static GetDefaultNumWorkers;
  54876. private static _Default;
  54877. /**
  54878. * Default instance for the draco compression object.
  54879. */
  54880. static readonly Default: DracoCompression;
  54881. /**
  54882. * Constructor
  54883. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54884. */
  54885. constructor(numWorkers?: number);
  54886. /**
  54887. * Stop all async operations and release resources.
  54888. */
  54889. dispose(): void;
  54890. /**
  54891. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54892. * @returns a promise that resolves when ready
  54893. */
  54894. whenReadyAsync(): Promise<void>;
  54895. /**
  54896. * Decode Draco compressed mesh data to vertex data.
  54897. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54898. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54899. * @returns A promise that resolves with the decoded vertex data
  54900. */
  54901. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54902. [kind: string]: number;
  54903. }): Promise<VertexData>;
  54904. }
  54905. }
  54906. declare module "babylonjs/Meshes/Compression/index" {
  54907. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54908. }
  54909. declare module "babylonjs/Meshes/csg" {
  54910. import { Nullable } from "babylonjs/types";
  54911. import { Scene } from "babylonjs/scene";
  54912. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54913. import { Mesh } from "babylonjs/Meshes/mesh";
  54914. import { Material } from "babylonjs/Materials/material";
  54915. /**
  54916. * Class for building Constructive Solid Geometry
  54917. */
  54918. export class CSG {
  54919. private polygons;
  54920. /**
  54921. * The world matrix
  54922. */
  54923. matrix: Matrix;
  54924. /**
  54925. * Stores the position
  54926. */
  54927. position: Vector3;
  54928. /**
  54929. * Stores the rotation
  54930. */
  54931. rotation: Vector3;
  54932. /**
  54933. * Stores the rotation quaternion
  54934. */
  54935. rotationQuaternion: Nullable<Quaternion>;
  54936. /**
  54937. * Stores the scaling vector
  54938. */
  54939. scaling: Vector3;
  54940. /**
  54941. * Convert the Mesh to CSG
  54942. * @param mesh The Mesh to convert to CSG
  54943. * @returns A new CSG from the Mesh
  54944. */
  54945. static FromMesh(mesh: Mesh): CSG;
  54946. /**
  54947. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54948. * @param polygons Polygons used to construct a CSG solid
  54949. */
  54950. private static FromPolygons;
  54951. /**
  54952. * Clones, or makes a deep copy, of the CSG
  54953. * @returns A new CSG
  54954. */
  54955. clone(): CSG;
  54956. /**
  54957. * Unions this CSG with another CSG
  54958. * @param csg The CSG to union against this CSG
  54959. * @returns The unioned CSG
  54960. */
  54961. union(csg: CSG): CSG;
  54962. /**
  54963. * Unions this CSG with another CSG in place
  54964. * @param csg The CSG to union against this CSG
  54965. */
  54966. unionInPlace(csg: CSG): void;
  54967. /**
  54968. * Subtracts this CSG with another CSG
  54969. * @param csg The CSG to subtract against this CSG
  54970. * @returns A new CSG
  54971. */
  54972. subtract(csg: CSG): CSG;
  54973. /**
  54974. * Subtracts this CSG with another CSG in place
  54975. * @param csg The CSG to subtact against this CSG
  54976. */
  54977. subtractInPlace(csg: CSG): void;
  54978. /**
  54979. * Intersect this CSG with another CSG
  54980. * @param csg The CSG to intersect against this CSG
  54981. * @returns A new CSG
  54982. */
  54983. intersect(csg: CSG): CSG;
  54984. /**
  54985. * Intersects this CSG with another CSG in place
  54986. * @param csg The CSG to intersect against this CSG
  54987. */
  54988. intersectInPlace(csg: CSG): void;
  54989. /**
  54990. * Return a new CSG solid with solid and empty space switched. This solid is
  54991. * not modified.
  54992. * @returns A new CSG solid with solid and empty space switched
  54993. */
  54994. inverse(): CSG;
  54995. /**
  54996. * Inverses the CSG in place
  54997. */
  54998. inverseInPlace(): void;
  54999. /**
  55000. * This is used to keep meshes transformations so they can be restored
  55001. * when we build back a Babylon Mesh
  55002. * NB : All CSG operations are performed in world coordinates
  55003. * @param csg The CSG to copy the transform attributes from
  55004. * @returns This CSG
  55005. */
  55006. copyTransformAttributes(csg: CSG): CSG;
  55007. /**
  55008. * Build Raw mesh from CSG
  55009. * Coordinates here are in world space
  55010. * @param name The name of the mesh geometry
  55011. * @param scene The Scene
  55012. * @param keepSubMeshes Specifies if the submeshes should be kept
  55013. * @returns A new Mesh
  55014. */
  55015. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  55016. /**
  55017. * Build Mesh from CSG taking material and transforms into account
  55018. * @param name The name of the Mesh
  55019. * @param material The material of the Mesh
  55020. * @param scene The Scene
  55021. * @param keepSubMeshes Specifies if submeshes should be kept
  55022. * @returns The new Mesh
  55023. */
  55024. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  55025. }
  55026. }
  55027. declare module "babylonjs/Meshes/trailMesh" {
  55028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55029. import { Mesh } from "babylonjs/Meshes/mesh";
  55030. import { Scene } from "babylonjs/scene";
  55031. /**
  55032. * Class used to create a trail following a mesh
  55033. */
  55034. export class TrailMesh extends Mesh {
  55035. private _generator;
  55036. private _autoStart;
  55037. private _running;
  55038. private _diameter;
  55039. private _length;
  55040. private _sectionPolygonPointsCount;
  55041. private _sectionVectors;
  55042. private _sectionNormalVectors;
  55043. private _beforeRenderObserver;
  55044. /**
  55045. * @constructor
  55046. * @param name The value used by scene.getMeshByName() to do a lookup.
  55047. * @param generator The mesh to generate a trail.
  55048. * @param scene The scene to add this mesh to.
  55049. * @param diameter Diameter of trailing mesh. Default is 1.
  55050. * @param length Length of trailing mesh. Default is 60.
  55051. * @param autoStart Automatically start trailing mesh. Default true.
  55052. */
  55053. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55054. /**
  55055. * "TrailMesh"
  55056. * @returns "TrailMesh"
  55057. */
  55058. getClassName(): string;
  55059. private _createMesh;
  55060. /**
  55061. * Start trailing mesh.
  55062. */
  55063. start(): void;
  55064. /**
  55065. * Stop trailing mesh.
  55066. */
  55067. stop(): void;
  55068. /**
  55069. * Update trailing mesh geometry.
  55070. */
  55071. update(): void;
  55072. /**
  55073. * Returns a new TrailMesh object.
  55074. * @param name is a string, the name given to the new mesh
  55075. * @param newGenerator use new generator object for cloned trail mesh
  55076. * @returns a new mesh
  55077. */
  55078. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55079. /**
  55080. * Serializes this trail mesh
  55081. * @param serializationObject object to write serialization to
  55082. */
  55083. serialize(serializationObject: any): void;
  55084. /**
  55085. * Parses a serialized trail mesh
  55086. * @param parsedMesh the serialized mesh
  55087. * @param scene the scene to create the trail mesh in
  55088. * @returns the created trail mesh
  55089. */
  55090. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55091. }
  55092. }
  55093. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  55094. import { Nullable } from "babylonjs/types";
  55095. import { Scene } from "babylonjs/scene";
  55096. import { Vector4, Color4 } from "babylonjs/Maths/math";
  55097. import { Mesh } from "babylonjs/Meshes/mesh";
  55098. /**
  55099. * Class containing static functions to help procedurally build meshes
  55100. */
  55101. export class TiledBoxBuilder {
  55102. /**
  55103. * Creates a box mesh
  55104. * 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)
  55105. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55109. * @param name defines the name of the mesh
  55110. * @param options defines the options used to create the mesh
  55111. * @param scene defines the hosting scene
  55112. * @returns the box mesh
  55113. */
  55114. static CreateTiledBox(name: string, options: {
  55115. pattern?: number;
  55116. width?: number;
  55117. height?: number;
  55118. depth?: number;
  55119. tileSize?: number;
  55120. tileWidth?: number;
  55121. tileHeight?: number;
  55122. alignHorizontal?: number;
  55123. alignVertical?: number;
  55124. faceUV?: Vector4[];
  55125. faceColors?: Color4[];
  55126. sideOrientation?: number;
  55127. updatable?: boolean;
  55128. }, scene?: Nullable<Scene>): Mesh;
  55129. }
  55130. }
  55131. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  55132. import { Vector4 } from "babylonjs/Maths/math";
  55133. import { Mesh } from "babylonjs/Meshes/mesh";
  55134. /**
  55135. * Class containing static functions to help procedurally build meshes
  55136. */
  55137. export class TorusKnotBuilder {
  55138. /**
  55139. * Creates a torus knot mesh
  55140. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55141. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55142. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55143. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55147. * @param name defines the name of the mesh
  55148. * @param options defines the options used to create the mesh
  55149. * @param scene defines the hosting scene
  55150. * @returns the torus knot mesh
  55151. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55152. */
  55153. static CreateTorusKnot(name: string, options: {
  55154. radius?: number;
  55155. tube?: number;
  55156. radialSegments?: number;
  55157. tubularSegments?: number;
  55158. p?: number;
  55159. q?: number;
  55160. updatable?: boolean;
  55161. sideOrientation?: number;
  55162. frontUVs?: Vector4;
  55163. backUVs?: Vector4;
  55164. }, scene: any): Mesh;
  55165. }
  55166. }
  55167. declare module "babylonjs/Meshes/polygonMesh" {
  55168. import { Scene } from "babylonjs/scene";
  55169. import { Vector2, Path2 } from "babylonjs/Maths/math";
  55170. import { Mesh } from "babylonjs/Meshes/mesh";
  55171. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55172. /**
  55173. * Polygon
  55174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55175. */
  55176. export class Polygon {
  55177. /**
  55178. * Creates a rectangle
  55179. * @param xmin bottom X coord
  55180. * @param ymin bottom Y coord
  55181. * @param xmax top X coord
  55182. * @param ymax top Y coord
  55183. * @returns points that make the resulting rectation
  55184. */
  55185. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55186. /**
  55187. * Creates a circle
  55188. * @param radius radius of circle
  55189. * @param cx scale in x
  55190. * @param cy scale in y
  55191. * @param numberOfSides number of sides that make up the circle
  55192. * @returns points that make the resulting circle
  55193. */
  55194. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55195. /**
  55196. * Creates a polygon from input string
  55197. * @param input Input polygon data
  55198. * @returns the parsed points
  55199. */
  55200. static Parse(input: string): Vector2[];
  55201. /**
  55202. * Starts building a polygon from x and y coordinates
  55203. * @param x x coordinate
  55204. * @param y y coordinate
  55205. * @returns the started path2
  55206. */
  55207. static StartingAt(x: number, y: number): Path2;
  55208. }
  55209. /**
  55210. * Builds a polygon
  55211. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55212. */
  55213. export class PolygonMeshBuilder {
  55214. private _points;
  55215. private _outlinepoints;
  55216. private _holes;
  55217. private _name;
  55218. private _scene;
  55219. private _epoints;
  55220. private _eholes;
  55221. private _addToepoint;
  55222. /**
  55223. * Babylon reference to the earcut plugin.
  55224. */
  55225. bjsEarcut: any;
  55226. /**
  55227. * Creates a PolygonMeshBuilder
  55228. * @param name name of the builder
  55229. * @param contours Path of the polygon
  55230. * @param scene scene to add to when creating the mesh
  55231. * @param earcutInjection can be used to inject your own earcut reference
  55232. */
  55233. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55234. /**
  55235. * Adds a whole within the polygon
  55236. * @param hole Array of points defining the hole
  55237. * @returns this
  55238. */
  55239. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55240. /**
  55241. * Creates the polygon
  55242. * @param updatable If the mesh should be updatable
  55243. * @param depth The depth of the mesh created
  55244. * @returns the created mesh
  55245. */
  55246. build(updatable?: boolean, depth?: number): Mesh;
  55247. /**
  55248. * Creates the polygon
  55249. * @param depth The depth of the mesh created
  55250. * @returns the created VertexData
  55251. */
  55252. buildVertexData(depth?: number): VertexData;
  55253. /**
  55254. * Adds a side to the polygon
  55255. * @param positions points that make the polygon
  55256. * @param normals normals of the polygon
  55257. * @param uvs uvs of the polygon
  55258. * @param indices indices of the polygon
  55259. * @param bounds bounds of the polygon
  55260. * @param points points of the polygon
  55261. * @param depth depth of the polygon
  55262. * @param flip flip of the polygon
  55263. */
  55264. private addSide;
  55265. }
  55266. }
  55267. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  55268. import { Scene } from "babylonjs/scene";
  55269. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  55270. import { Mesh } from "babylonjs/Meshes/mesh";
  55271. import { Nullable } from "babylonjs/types";
  55272. /**
  55273. * Class containing static functions to help procedurally build meshes
  55274. */
  55275. export class PolygonBuilder {
  55276. /**
  55277. * Creates a polygon mesh
  55278. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55279. * * 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
  55280. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55283. * * Remember you can only change the shape positions, not their number when updating a polygon
  55284. * @param name defines the name of the mesh
  55285. * @param options defines the options used to create the mesh
  55286. * @param scene defines the hosting scene
  55287. * @param earcutInjection can be used to inject your own earcut reference
  55288. * @returns the polygon mesh
  55289. */
  55290. static CreatePolygon(name: string, options: {
  55291. shape: Vector3[];
  55292. holes?: Vector3[][];
  55293. depth?: number;
  55294. faceUV?: Vector4[];
  55295. faceColors?: Color4[];
  55296. updatable?: boolean;
  55297. sideOrientation?: number;
  55298. frontUVs?: Vector4;
  55299. backUVs?: Vector4;
  55300. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55301. /**
  55302. * Creates an extruded polygon mesh, with depth in the Y direction.
  55303. * * 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)
  55304. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55305. * @param name defines the name of the mesh
  55306. * @param options defines the options used to create the mesh
  55307. * @param scene defines the hosting scene
  55308. * @param earcutInjection can be used to inject your own earcut reference
  55309. * @returns the polygon mesh
  55310. */
  55311. static ExtrudePolygon(name: string, options: {
  55312. shape: Vector3[];
  55313. holes?: Vector3[][];
  55314. depth?: number;
  55315. faceUV?: Vector4[];
  55316. faceColors?: Color4[];
  55317. updatable?: boolean;
  55318. sideOrientation?: number;
  55319. frontUVs?: Vector4;
  55320. backUVs?: Vector4;
  55321. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55322. }
  55323. }
  55324. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  55325. import { Scene } from "babylonjs/scene";
  55326. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55327. import { Mesh } from "babylonjs/Meshes/mesh";
  55328. import { Nullable } from "babylonjs/types";
  55329. /**
  55330. * Class containing static functions to help procedurally build meshes
  55331. */
  55332. export class LatheBuilder {
  55333. /**
  55334. * Creates lathe mesh.
  55335. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55336. * * 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
  55337. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55338. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55339. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55340. * * 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
  55341. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55342. * * 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
  55343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55345. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55347. * @param name defines the name of the mesh
  55348. * @param options defines the options used to create the mesh
  55349. * @param scene defines the hosting scene
  55350. * @returns the lathe mesh
  55351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55352. */
  55353. static CreateLathe(name: string, options: {
  55354. shape: Vector3[];
  55355. radius?: number;
  55356. tessellation?: number;
  55357. clip?: number;
  55358. arc?: number;
  55359. closed?: boolean;
  55360. updatable?: boolean;
  55361. sideOrientation?: number;
  55362. frontUVs?: Vector4;
  55363. backUVs?: Vector4;
  55364. cap?: number;
  55365. invertUV?: boolean;
  55366. }, scene?: Nullable<Scene>): Mesh;
  55367. }
  55368. }
  55369. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  55370. import { Nullable } from "babylonjs/types";
  55371. import { Scene } from "babylonjs/scene";
  55372. import { Vector4 } from "babylonjs/Maths/math";
  55373. import { Mesh } from "babylonjs/Meshes/mesh";
  55374. /**
  55375. * Class containing static functions to help procedurally build meshes
  55376. */
  55377. export class TiledPlaneBuilder {
  55378. /**
  55379. * Creates a tiled plane mesh
  55380. * * The parameter `pattern` will, depending on value, do nothing or
  55381. * * * flip (reflect about central vertical) alternate tiles across and up
  55382. * * * flip every tile on alternate rows
  55383. * * * rotate (180 degs) alternate tiles across and up
  55384. * * * rotate every tile on alternate rows
  55385. * * * flip and rotate alternate tiles across and up
  55386. * * * flip and rotate every tile on alternate rows
  55387. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55388. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55390. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55391. * * 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)
  55392. * * 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)
  55393. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55394. * @param name defines the name of the mesh
  55395. * @param options defines the options used to create the mesh
  55396. * @param scene defines the hosting scene
  55397. * @returns the box mesh
  55398. */
  55399. static CreateTiledPlane(name: string, options: {
  55400. pattern?: number;
  55401. tileSize?: number;
  55402. tileWidth?: number;
  55403. tileHeight?: number;
  55404. size?: number;
  55405. width?: number;
  55406. height?: number;
  55407. alignHorizontal?: number;
  55408. alignVertical?: number;
  55409. sideOrientation?: number;
  55410. frontUVs?: Vector4;
  55411. backUVs?: Vector4;
  55412. updatable?: boolean;
  55413. }, scene?: Nullable<Scene>): Mesh;
  55414. }
  55415. }
  55416. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  55417. import { Nullable } from "babylonjs/types";
  55418. import { Scene } from "babylonjs/scene";
  55419. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55420. import { Mesh } from "babylonjs/Meshes/mesh";
  55421. /**
  55422. * Class containing static functions to help procedurally build meshes
  55423. */
  55424. export class TubeBuilder {
  55425. /**
  55426. * Creates a tube mesh.
  55427. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55428. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55429. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55430. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55431. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55432. * * 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)
  55433. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55434. * * 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
  55435. * * 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
  55436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55438. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55440. * @param name defines the name of the mesh
  55441. * @param options defines the options used to create the mesh
  55442. * @param scene defines the hosting scene
  55443. * @returns the tube mesh
  55444. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55445. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55446. */
  55447. static CreateTube(name: string, options: {
  55448. path: Vector3[];
  55449. radius?: number;
  55450. tessellation?: number;
  55451. radiusFunction?: {
  55452. (i: number, distance: number): number;
  55453. };
  55454. cap?: number;
  55455. arc?: number;
  55456. updatable?: boolean;
  55457. sideOrientation?: number;
  55458. frontUVs?: Vector4;
  55459. backUVs?: Vector4;
  55460. instance?: Mesh;
  55461. invertUV?: boolean;
  55462. }, scene?: Nullable<Scene>): Mesh;
  55463. }
  55464. }
  55465. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  55466. import { Scene } from "babylonjs/scene";
  55467. import { Vector4 } from "babylonjs/Maths/math";
  55468. import { Mesh } from "babylonjs/Meshes/mesh";
  55469. import { Nullable } from "babylonjs/types";
  55470. /**
  55471. * Class containing static functions to help procedurally build meshes
  55472. */
  55473. export class IcoSphereBuilder {
  55474. /**
  55475. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55476. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55477. * * 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`)
  55478. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55479. * * 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
  55480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55483. * @param name defines the name of the mesh
  55484. * @param options defines the options used to create the mesh
  55485. * @param scene defines the hosting scene
  55486. * @returns the icosahedron mesh
  55487. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55488. */
  55489. static CreateIcoSphere(name: string, options: {
  55490. radius?: number;
  55491. radiusX?: number;
  55492. radiusY?: number;
  55493. radiusZ?: number;
  55494. flat?: boolean;
  55495. subdivisions?: number;
  55496. sideOrientation?: number;
  55497. frontUVs?: Vector4;
  55498. backUVs?: Vector4;
  55499. updatable?: boolean;
  55500. }, scene?: Nullable<Scene>): Mesh;
  55501. }
  55502. }
  55503. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  55504. import { Vector3 } from "babylonjs/Maths/math";
  55505. import { Mesh } from "babylonjs/Meshes/mesh";
  55506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55507. /**
  55508. * Class containing static functions to help procedurally build meshes
  55509. */
  55510. export class DecalBuilder {
  55511. /**
  55512. * Creates a decal mesh.
  55513. * 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
  55514. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55515. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55516. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55517. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55518. * @param name defines the name of the mesh
  55519. * @param sourceMesh defines the mesh where the decal must be applied
  55520. * @param options defines the options used to create the mesh
  55521. * @param scene defines the hosting scene
  55522. * @returns the decal mesh
  55523. * @see https://doc.babylonjs.com/how_to/decals
  55524. */
  55525. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55526. position?: Vector3;
  55527. normal?: Vector3;
  55528. size?: Vector3;
  55529. angle?: number;
  55530. }): Mesh;
  55531. }
  55532. }
  55533. declare module "babylonjs/Meshes/meshBuilder" {
  55534. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  55535. import { Nullable } from "babylonjs/types";
  55536. import { Scene } from "babylonjs/scene";
  55537. import { Mesh } from "babylonjs/Meshes/mesh";
  55538. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  55539. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55541. /**
  55542. * Class containing static functions to help procedurally build meshes
  55543. */
  55544. export class MeshBuilder {
  55545. /**
  55546. * Creates a box mesh
  55547. * * The parameter `size` sets the size (float) of each box side (default 1)
  55548. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55549. * * 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)
  55550. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55554. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  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 box mesh
  55559. */
  55560. static CreateBox(name: string, options: {
  55561. size?: number;
  55562. width?: number;
  55563. height?: number;
  55564. depth?: number;
  55565. faceUV?: Vector4[];
  55566. faceColors?: Color4[];
  55567. sideOrientation?: number;
  55568. frontUVs?: Vector4;
  55569. backUVs?: Vector4;
  55570. updatable?: boolean;
  55571. }, scene?: Nullable<Scene>): Mesh;
  55572. /**
  55573. * Creates a tiled box mesh
  55574. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55576. * @param name defines the name of the mesh
  55577. * @param options defines the options used to create the mesh
  55578. * @param scene defines the hosting scene
  55579. * @returns the tiled box mesh
  55580. */
  55581. static CreateTiledBox(name: string, options: {
  55582. pattern?: number;
  55583. size?: number;
  55584. width?: number;
  55585. height?: number;
  55586. depth: number;
  55587. tileSize?: number;
  55588. tileWidth?: number;
  55589. tileHeight?: number;
  55590. faceUV?: Vector4[];
  55591. faceColors?: Color4[];
  55592. alignHorizontal?: number;
  55593. alignVertical?: number;
  55594. sideOrientation?: number;
  55595. updatable?: boolean;
  55596. }, scene?: Nullable<Scene>): Mesh;
  55597. /**
  55598. * Creates a sphere mesh
  55599. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55600. * * 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`)
  55601. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55602. * * 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
  55603. * * 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)
  55604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55607. * @param name defines the name of the mesh
  55608. * @param options defines the options used to create the mesh
  55609. * @param scene defines the hosting scene
  55610. * @returns the sphere mesh
  55611. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55612. */
  55613. static CreateSphere(name: string, options: {
  55614. segments?: number;
  55615. diameter?: number;
  55616. diameterX?: number;
  55617. diameterY?: number;
  55618. diameterZ?: number;
  55619. arc?: number;
  55620. slice?: number;
  55621. sideOrientation?: number;
  55622. frontUVs?: Vector4;
  55623. backUVs?: Vector4;
  55624. updatable?: boolean;
  55625. }, scene?: Nullable<Scene>): Mesh;
  55626. /**
  55627. * Creates a plane polygonal mesh. By default, this is a disc
  55628. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55629. * * 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
  55630. * * 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
  55631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55634. * @param name defines the name of the mesh
  55635. * @param options defines the options used to create the mesh
  55636. * @param scene defines the hosting scene
  55637. * @returns the plane polygonal mesh
  55638. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55639. */
  55640. static CreateDisc(name: string, options: {
  55641. radius?: number;
  55642. tessellation?: number;
  55643. arc?: number;
  55644. updatable?: boolean;
  55645. sideOrientation?: number;
  55646. frontUVs?: Vector4;
  55647. backUVs?: Vector4;
  55648. }, scene?: Nullable<Scene>): Mesh;
  55649. /**
  55650. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55651. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55652. * * 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`)
  55653. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55654. * * 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
  55655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55658. * @param name defines the name of the mesh
  55659. * @param options defines the options used to create the mesh
  55660. * @param scene defines the hosting scene
  55661. * @returns the icosahedron mesh
  55662. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55663. */
  55664. static CreateIcoSphere(name: string, options: {
  55665. radius?: number;
  55666. radiusX?: number;
  55667. radiusY?: number;
  55668. radiusZ?: number;
  55669. flat?: boolean;
  55670. subdivisions?: number;
  55671. sideOrientation?: number;
  55672. frontUVs?: Vector4;
  55673. backUVs?: Vector4;
  55674. updatable?: boolean;
  55675. }, scene?: Nullable<Scene>): Mesh;
  55676. /**
  55677. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55678. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55679. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55680. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55681. * * 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
  55682. * * 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
  55683. * * 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
  55684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55686. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55687. * * 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
  55688. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55689. * * 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
  55690. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55692. * @param name defines the name of the mesh
  55693. * @param options defines the options used to create the mesh
  55694. * @param scene defines the hosting scene
  55695. * @returns the ribbon mesh
  55696. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55697. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55698. */
  55699. static CreateRibbon(name: string, options: {
  55700. pathArray: Vector3[][];
  55701. closeArray?: boolean;
  55702. closePath?: boolean;
  55703. offset?: number;
  55704. updatable?: boolean;
  55705. sideOrientation?: number;
  55706. frontUVs?: Vector4;
  55707. backUVs?: Vector4;
  55708. instance?: Mesh;
  55709. invertUV?: boolean;
  55710. uvs?: Vector2[];
  55711. colors?: Color4[];
  55712. }, scene?: Nullable<Scene>): Mesh;
  55713. /**
  55714. * Creates a cylinder or a cone mesh
  55715. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55716. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55717. * * 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.
  55718. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55719. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55720. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55721. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55722. * * 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).
  55723. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55724. * * 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).
  55725. * * 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
  55726. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55727. * * 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
  55728. * * 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.
  55729. * * If `enclose` is false, a ring surface is one element.
  55730. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55731. * * 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
  55732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55735. * @param name defines the name of the mesh
  55736. * @param options defines the options used to create the mesh
  55737. * @param scene defines the hosting scene
  55738. * @returns the cylinder mesh
  55739. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55740. */
  55741. static CreateCylinder(name: string, options: {
  55742. height?: number;
  55743. diameterTop?: number;
  55744. diameterBottom?: number;
  55745. diameter?: number;
  55746. tessellation?: number;
  55747. subdivisions?: number;
  55748. arc?: number;
  55749. faceColors?: Color4[];
  55750. faceUV?: Vector4[];
  55751. updatable?: boolean;
  55752. hasRings?: boolean;
  55753. enclose?: boolean;
  55754. cap?: number;
  55755. sideOrientation?: number;
  55756. frontUVs?: Vector4;
  55757. backUVs?: Vector4;
  55758. }, scene?: Nullable<Scene>): Mesh;
  55759. /**
  55760. * Creates a torus mesh
  55761. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55762. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55763. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55767. * @param name defines the name of the mesh
  55768. * @param options defines the options used to create the mesh
  55769. * @param scene defines the hosting scene
  55770. * @returns the torus mesh
  55771. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55772. */
  55773. static CreateTorus(name: string, options: {
  55774. diameter?: number;
  55775. thickness?: number;
  55776. tessellation?: number;
  55777. updatable?: boolean;
  55778. sideOrientation?: number;
  55779. frontUVs?: Vector4;
  55780. backUVs?: Vector4;
  55781. }, scene?: Nullable<Scene>): Mesh;
  55782. /**
  55783. * Creates a torus knot mesh
  55784. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55785. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55786. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55787. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55791. * @param name defines the name of the mesh
  55792. * @param options defines the options used to create the mesh
  55793. * @param scene defines the hosting scene
  55794. * @returns the torus knot mesh
  55795. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55796. */
  55797. static CreateTorusKnot(name: string, options: {
  55798. radius?: number;
  55799. tube?: number;
  55800. radialSegments?: number;
  55801. tubularSegments?: number;
  55802. p?: number;
  55803. q?: number;
  55804. updatable?: boolean;
  55805. sideOrientation?: number;
  55806. frontUVs?: Vector4;
  55807. backUVs?: Vector4;
  55808. }, scene?: Nullable<Scene>): Mesh;
  55809. /**
  55810. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55811. * * 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
  55812. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55813. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55814. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55815. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55816. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55817. * * 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
  55818. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55821. * @param name defines the name of the new line system
  55822. * @param options defines the options used to create the line system
  55823. * @param scene defines the hosting scene
  55824. * @returns a new line system mesh
  55825. */
  55826. static CreateLineSystem(name: string, options: {
  55827. lines: Vector3[][];
  55828. updatable?: boolean;
  55829. instance?: Nullable<LinesMesh>;
  55830. colors?: Nullable<Color4[][]>;
  55831. useVertexAlpha?: boolean;
  55832. }, scene: Nullable<Scene>): LinesMesh;
  55833. /**
  55834. * Creates a line mesh
  55835. * 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
  55836. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55837. * * The parameter `points` is an array successive Vector3
  55838. * * 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
  55839. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55840. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55841. * * When updating an instance, remember that only point positions can change, not the number of points
  55842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55844. * @param name defines the name of the new line system
  55845. * @param options defines the options used to create the line system
  55846. * @param scene defines the hosting scene
  55847. * @returns a new line mesh
  55848. */
  55849. static CreateLines(name: string, options: {
  55850. points: Vector3[];
  55851. updatable?: boolean;
  55852. instance?: Nullable<LinesMesh>;
  55853. colors?: Color4[];
  55854. useVertexAlpha?: boolean;
  55855. }, scene?: Nullable<Scene>): LinesMesh;
  55856. /**
  55857. * Creates a dashed line mesh
  55858. * * 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
  55859. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55860. * * The parameter `points` is an array successive Vector3
  55861. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55862. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55863. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55864. * * 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
  55865. * * When updating an instance, remember that only point positions can change, not the number of points
  55866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55867. * @param name defines the name of the mesh
  55868. * @param options defines the options used to create the mesh
  55869. * @param scene defines the hosting scene
  55870. * @returns the dashed line mesh
  55871. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55872. */
  55873. static CreateDashedLines(name: string, options: {
  55874. points: Vector3[];
  55875. dashSize?: number;
  55876. gapSize?: number;
  55877. dashNb?: number;
  55878. updatable?: boolean;
  55879. instance?: LinesMesh;
  55880. }, scene?: Nullable<Scene>): LinesMesh;
  55881. /**
  55882. * 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.
  55883. * * 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.
  55884. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55885. * * 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.
  55886. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55887. * * 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
  55888. * * 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
  55889. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55892. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55894. * @param name defines the name of the mesh
  55895. * @param options defines the options used to create the mesh
  55896. * @param scene defines the hosting scene
  55897. * @returns the extruded shape mesh
  55898. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55899. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55900. */
  55901. static ExtrudeShape(name: string, options: {
  55902. shape: Vector3[];
  55903. path: Vector3[];
  55904. scale?: number;
  55905. rotation?: number;
  55906. cap?: number;
  55907. updatable?: boolean;
  55908. sideOrientation?: number;
  55909. frontUVs?: Vector4;
  55910. backUVs?: Vector4;
  55911. instance?: Mesh;
  55912. invertUV?: boolean;
  55913. }, scene?: Nullable<Scene>): Mesh;
  55914. /**
  55915. * Creates an custom extruded shape mesh.
  55916. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55917. * * 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.
  55918. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55919. * * 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
  55920. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55921. * * 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
  55922. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55923. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55924. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55925. * * 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
  55926. * * 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
  55927. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55930. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55932. * @param name defines the name of the mesh
  55933. * @param options defines the options used to create the mesh
  55934. * @param scene defines the hosting scene
  55935. * @returns the custom extruded shape mesh
  55936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55937. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55939. */
  55940. static ExtrudeShapeCustom(name: string, options: {
  55941. shape: Vector3[];
  55942. path: Vector3[];
  55943. scaleFunction?: any;
  55944. rotationFunction?: any;
  55945. ribbonCloseArray?: boolean;
  55946. ribbonClosePath?: boolean;
  55947. cap?: number;
  55948. updatable?: boolean;
  55949. sideOrientation?: number;
  55950. frontUVs?: Vector4;
  55951. backUVs?: Vector4;
  55952. instance?: Mesh;
  55953. invertUV?: boolean;
  55954. }, scene?: Nullable<Scene>): Mesh;
  55955. /**
  55956. * Creates lathe mesh.
  55957. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55958. * * 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
  55959. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55960. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55961. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55962. * * 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
  55963. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55964. * * 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
  55965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55967. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55969. * @param name defines the name of the mesh
  55970. * @param options defines the options used to create the mesh
  55971. * @param scene defines the hosting scene
  55972. * @returns the lathe mesh
  55973. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55974. */
  55975. static CreateLathe(name: string, options: {
  55976. shape: Vector3[];
  55977. radius?: number;
  55978. tessellation?: number;
  55979. clip?: number;
  55980. arc?: number;
  55981. closed?: boolean;
  55982. updatable?: boolean;
  55983. sideOrientation?: number;
  55984. frontUVs?: Vector4;
  55985. backUVs?: Vector4;
  55986. cap?: number;
  55987. invertUV?: boolean;
  55988. }, scene?: Nullable<Scene>): Mesh;
  55989. /**
  55990. * Creates a tiled plane mesh
  55991. * * You can set a limited pattern arrangement with the tiles
  55992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55995. * @param name defines the name of the mesh
  55996. * @param options defines the options used to create the mesh
  55997. * @param scene defines the hosting scene
  55998. * @returns the plane mesh
  55999. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56000. */
  56001. static CreateTiledPlane(name: string, options: {
  56002. pattern?: number;
  56003. tileSize?: number;
  56004. tileWidth?: number;
  56005. tileHeight?: number;
  56006. size?: number;
  56007. width?: number;
  56008. height?: number;
  56009. alignHorizontal?: number;
  56010. alignVertical?: number;
  56011. sideOrientation?: number;
  56012. frontUVs?: Vector4;
  56013. backUVs?: Vector4;
  56014. updatable?: boolean;
  56015. }, scene?: Nullable<Scene>): Mesh;
  56016. /**
  56017. * Creates a plane mesh
  56018. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56019. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56020. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56024. * @param name defines the name of the mesh
  56025. * @param options defines the options used to create the mesh
  56026. * @param scene defines the hosting scene
  56027. * @returns the plane mesh
  56028. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56029. */
  56030. static CreatePlane(name: string, options: {
  56031. size?: number;
  56032. width?: number;
  56033. height?: number;
  56034. sideOrientation?: number;
  56035. frontUVs?: Vector4;
  56036. backUVs?: Vector4;
  56037. updatable?: boolean;
  56038. sourcePlane?: Plane;
  56039. }, scene?: Nullable<Scene>): Mesh;
  56040. /**
  56041. * Creates a ground mesh
  56042. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56043. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56045. * @param name defines the name of the mesh
  56046. * @param options defines the options used to create the mesh
  56047. * @param scene defines the hosting scene
  56048. * @returns the ground mesh
  56049. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56050. */
  56051. static CreateGround(name: string, options: {
  56052. width?: number;
  56053. height?: number;
  56054. subdivisions?: number;
  56055. subdivisionsX?: number;
  56056. subdivisionsY?: number;
  56057. updatable?: boolean;
  56058. }, scene?: Nullable<Scene>): Mesh;
  56059. /**
  56060. * Creates a tiled ground mesh
  56061. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56062. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56063. * * 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
  56064. * * 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
  56065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56066. * @param name defines the name of the mesh
  56067. * @param options defines the options used to create the mesh
  56068. * @param scene defines the hosting scene
  56069. * @returns the tiled ground mesh
  56070. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56071. */
  56072. static CreateTiledGround(name: string, options: {
  56073. xmin: number;
  56074. zmin: number;
  56075. xmax: number;
  56076. zmax: number;
  56077. subdivisions?: {
  56078. w: number;
  56079. h: number;
  56080. };
  56081. precision?: {
  56082. w: number;
  56083. h: number;
  56084. };
  56085. updatable?: boolean;
  56086. }, scene?: Nullable<Scene>): Mesh;
  56087. /**
  56088. * Creates a ground mesh from a height map
  56089. * * The parameter `url` sets the URL of the height map image resource.
  56090. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56091. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56092. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56093. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56094. * * 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.
  56095. * * 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).
  56096. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56098. * @param name defines the name of the mesh
  56099. * @param url defines the url to the height map
  56100. * @param options defines the options used to create the mesh
  56101. * @param scene defines the hosting scene
  56102. * @returns the ground mesh
  56103. * @see https://doc.babylonjs.com/babylon101/height_map
  56104. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56105. */
  56106. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56107. width?: number;
  56108. height?: number;
  56109. subdivisions?: number;
  56110. minHeight?: number;
  56111. maxHeight?: number;
  56112. colorFilter?: Color3;
  56113. alphaFilter?: number;
  56114. updatable?: boolean;
  56115. onReady?: (mesh: GroundMesh) => void;
  56116. }, scene?: Nullable<Scene>): GroundMesh;
  56117. /**
  56118. * Creates a polygon mesh
  56119. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56120. * * 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
  56121. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56124. * * Remember you can only change the shape positions, not their number when updating a polygon
  56125. * @param name defines the name of the mesh
  56126. * @param options defines the options used to create the mesh
  56127. * @param scene defines the hosting scene
  56128. * @param earcutInjection can be used to inject your own earcut reference
  56129. * @returns the polygon mesh
  56130. */
  56131. static CreatePolygon(name: string, options: {
  56132. shape: Vector3[];
  56133. holes?: Vector3[][];
  56134. depth?: number;
  56135. faceUV?: Vector4[];
  56136. faceColors?: Color4[];
  56137. updatable?: boolean;
  56138. sideOrientation?: number;
  56139. frontUVs?: Vector4;
  56140. backUVs?: Vector4;
  56141. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56142. /**
  56143. * Creates an extruded polygon mesh, with depth in the Y direction.
  56144. * * 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)
  56145. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56146. * @param name defines the name of the mesh
  56147. * @param options defines the options used to create the mesh
  56148. * @param scene defines the hosting scene
  56149. * @param earcutInjection can be used to inject your own earcut reference
  56150. * @returns the polygon mesh
  56151. */
  56152. static ExtrudePolygon(name: string, options: {
  56153. shape: Vector3[];
  56154. holes?: Vector3[][];
  56155. depth?: number;
  56156. faceUV?: Vector4[];
  56157. faceColors?: Color4[];
  56158. updatable?: boolean;
  56159. sideOrientation?: number;
  56160. frontUVs?: Vector4;
  56161. backUVs?: Vector4;
  56162. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56163. /**
  56164. * Creates a tube mesh.
  56165. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56166. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56167. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56168. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56169. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56170. * * 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)
  56171. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56172. * * 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
  56173. * * 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
  56174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56175. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56176. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56178. * @param name defines the name of the mesh
  56179. * @param options defines the options used to create the mesh
  56180. * @param scene defines the hosting scene
  56181. * @returns the tube mesh
  56182. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56183. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56184. */
  56185. static CreateTube(name: string, options: {
  56186. path: Vector3[];
  56187. radius?: number;
  56188. tessellation?: number;
  56189. radiusFunction?: {
  56190. (i: number, distance: number): number;
  56191. };
  56192. cap?: number;
  56193. arc?: number;
  56194. updatable?: boolean;
  56195. sideOrientation?: number;
  56196. frontUVs?: Vector4;
  56197. backUVs?: Vector4;
  56198. instance?: Mesh;
  56199. invertUV?: boolean;
  56200. }, scene?: Nullable<Scene>): Mesh;
  56201. /**
  56202. * Creates a polyhedron mesh
  56203. * * 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
  56204. * * The parameter `size` (positive float, default 1) sets the polygon size
  56205. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56206. * * 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`
  56207. * * 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
  56208. * * 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)`)
  56209. * * 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
  56210. * * 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
  56211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56214. * @param name defines the name of the mesh
  56215. * @param options defines the options used to create the mesh
  56216. * @param scene defines the hosting scene
  56217. * @returns the polyhedron mesh
  56218. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56219. */
  56220. static CreatePolyhedron(name: string, options: {
  56221. type?: number;
  56222. size?: number;
  56223. sizeX?: number;
  56224. sizeY?: number;
  56225. sizeZ?: number;
  56226. custom?: any;
  56227. faceUV?: Vector4[];
  56228. faceColors?: Color4[];
  56229. flat?: boolean;
  56230. updatable?: boolean;
  56231. sideOrientation?: number;
  56232. frontUVs?: Vector4;
  56233. backUVs?: Vector4;
  56234. }, scene?: Nullable<Scene>): Mesh;
  56235. /**
  56236. * Creates a decal mesh.
  56237. * 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
  56238. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56239. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56240. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56241. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56242. * @param name defines the name of the mesh
  56243. * @param sourceMesh defines the mesh where the decal must be applied
  56244. * @param options defines the options used to create the mesh
  56245. * @param scene defines the hosting scene
  56246. * @returns the decal mesh
  56247. * @see https://doc.babylonjs.com/how_to/decals
  56248. */
  56249. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56250. position?: Vector3;
  56251. normal?: Vector3;
  56252. size?: Vector3;
  56253. angle?: number;
  56254. }): Mesh;
  56255. }
  56256. }
  56257. declare module "babylonjs/Meshes/meshSimplification" {
  56258. import { Mesh } from "babylonjs/Meshes/mesh";
  56259. /**
  56260. * A simplifier interface for future simplification implementations
  56261. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56262. */
  56263. export interface ISimplifier {
  56264. /**
  56265. * Simplification of a given mesh according to the given settings.
  56266. * Since this requires computation, it is assumed that the function runs async.
  56267. * @param settings The settings of the simplification, including quality and distance
  56268. * @param successCallback A callback that will be called after the mesh was simplified.
  56269. * @param errorCallback in case of an error, this callback will be called. optional.
  56270. */
  56271. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56272. }
  56273. /**
  56274. * Expected simplification settings.
  56275. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56276. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56277. */
  56278. export interface ISimplificationSettings {
  56279. /**
  56280. * Gets or sets the expected quality
  56281. */
  56282. quality: number;
  56283. /**
  56284. * Gets or sets the distance when this optimized version should be used
  56285. */
  56286. distance: number;
  56287. /**
  56288. * Gets an already optimized mesh
  56289. */
  56290. optimizeMesh?: boolean;
  56291. }
  56292. /**
  56293. * Class used to specify simplification options
  56294. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56295. */
  56296. export class SimplificationSettings implements ISimplificationSettings {
  56297. /** expected quality */
  56298. quality: number;
  56299. /** distance when this optimized version should be used */
  56300. distance: number;
  56301. /** already optimized mesh */
  56302. optimizeMesh?: boolean | undefined;
  56303. /**
  56304. * Creates a SimplificationSettings
  56305. * @param quality expected quality
  56306. * @param distance distance when this optimized version should be used
  56307. * @param optimizeMesh already optimized mesh
  56308. */
  56309. constructor(
  56310. /** expected quality */
  56311. quality: number,
  56312. /** distance when this optimized version should be used */
  56313. distance: number,
  56314. /** already optimized mesh */
  56315. optimizeMesh?: boolean | undefined);
  56316. }
  56317. /**
  56318. * Interface used to define a simplification task
  56319. */
  56320. export interface ISimplificationTask {
  56321. /**
  56322. * Array of settings
  56323. */
  56324. settings: Array<ISimplificationSettings>;
  56325. /**
  56326. * Simplification type
  56327. */
  56328. simplificationType: SimplificationType;
  56329. /**
  56330. * Mesh to simplify
  56331. */
  56332. mesh: Mesh;
  56333. /**
  56334. * Callback called on success
  56335. */
  56336. successCallback?: () => void;
  56337. /**
  56338. * Defines if parallel processing can be used
  56339. */
  56340. parallelProcessing: boolean;
  56341. }
  56342. /**
  56343. * Queue used to order the simplification tasks
  56344. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56345. */
  56346. export class SimplificationQueue {
  56347. private _simplificationArray;
  56348. /**
  56349. * Gets a boolean indicating that the process is still running
  56350. */
  56351. running: boolean;
  56352. /**
  56353. * Creates a new queue
  56354. */
  56355. constructor();
  56356. /**
  56357. * Adds a new simplification task
  56358. * @param task defines a task to add
  56359. */
  56360. addTask(task: ISimplificationTask): void;
  56361. /**
  56362. * Execute next task
  56363. */
  56364. executeNext(): void;
  56365. /**
  56366. * Execute a simplification task
  56367. * @param task defines the task to run
  56368. */
  56369. runSimplification(task: ISimplificationTask): void;
  56370. private getSimplifier;
  56371. }
  56372. /**
  56373. * The implemented types of simplification
  56374. * At the moment only Quadratic Error Decimation is implemented
  56375. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56376. */
  56377. export enum SimplificationType {
  56378. /** Quadratic error decimation */
  56379. QUADRATIC = 0
  56380. }
  56381. }
  56382. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  56383. import { Scene } from "babylonjs/scene";
  56384. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  56385. import { ISceneComponent } from "babylonjs/sceneComponent";
  56386. module "babylonjs/scene" {
  56387. interface Scene {
  56388. /** @hidden (Backing field) */
  56389. _simplificationQueue: SimplificationQueue;
  56390. /**
  56391. * Gets or sets the simplification queue attached to the scene
  56392. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56393. */
  56394. simplificationQueue: SimplificationQueue;
  56395. }
  56396. }
  56397. module "babylonjs/Meshes/mesh" {
  56398. interface Mesh {
  56399. /**
  56400. * Simplify the mesh according to the given array of settings.
  56401. * Function will return immediately and will simplify async
  56402. * @param settings a collection of simplification settings
  56403. * @param parallelProcessing should all levels calculate parallel or one after the other
  56404. * @param simplificationType the type of simplification to run
  56405. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56406. * @returns the current mesh
  56407. */
  56408. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56409. }
  56410. }
  56411. /**
  56412. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56413. * created in a scene
  56414. */
  56415. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56416. /**
  56417. * The component name helpfull to identify the component in the list of scene components.
  56418. */
  56419. readonly name: string;
  56420. /**
  56421. * The scene the component belongs to.
  56422. */
  56423. scene: Scene;
  56424. /**
  56425. * Creates a new instance of the component for the given scene
  56426. * @param scene Defines the scene to register the component in
  56427. */
  56428. constructor(scene: Scene);
  56429. /**
  56430. * Registers the component in a given scene
  56431. */
  56432. register(): void;
  56433. /**
  56434. * Rebuilds the elements related to this component in case of
  56435. * context lost for instance.
  56436. */
  56437. rebuild(): void;
  56438. /**
  56439. * Disposes the component and the associated ressources
  56440. */
  56441. dispose(): void;
  56442. private _beforeCameraUpdate;
  56443. }
  56444. }
  56445. declare module "babylonjs/Meshes/Builders/index" {
  56446. export * from "babylonjs/Meshes/Builders/boxBuilder";
  56447. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  56448. export * from "babylonjs/Meshes/Builders/discBuilder";
  56449. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  56450. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  56451. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  56452. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  56453. export * from "babylonjs/Meshes/Builders/torusBuilder";
  56454. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  56455. export * from "babylonjs/Meshes/Builders/linesBuilder";
  56456. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  56457. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  56458. export * from "babylonjs/Meshes/Builders/latheBuilder";
  56459. export * from "babylonjs/Meshes/Builders/planeBuilder";
  56460. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  56461. export * from "babylonjs/Meshes/Builders/groundBuilder";
  56462. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  56463. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  56464. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  56465. export * from "babylonjs/Meshes/Builders/decalBuilder";
  56466. }
  56467. declare module "babylonjs/Meshes/index" {
  56468. export * from "babylonjs/Meshes/abstractMesh";
  56469. export * from "babylonjs/Meshes/buffer";
  56470. export * from "babylonjs/Meshes/Compression/index";
  56471. export * from "babylonjs/Meshes/csg";
  56472. export * from "babylonjs/Meshes/geometry";
  56473. export * from "babylonjs/Meshes/groundMesh";
  56474. export * from "babylonjs/Meshes/trailMesh";
  56475. export * from "babylonjs/Meshes/instancedMesh";
  56476. export * from "babylonjs/Meshes/linesMesh";
  56477. export * from "babylonjs/Meshes/mesh";
  56478. export * from "babylonjs/Meshes/mesh.vertexData";
  56479. export * from "babylonjs/Meshes/meshBuilder";
  56480. export * from "babylonjs/Meshes/meshSimplification";
  56481. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  56482. export * from "babylonjs/Meshes/polygonMesh";
  56483. export * from "babylonjs/Meshes/subMesh";
  56484. export * from "babylonjs/Meshes/meshLODLevel";
  56485. export * from "babylonjs/Meshes/transformNode";
  56486. export * from "babylonjs/Meshes/Builders/index";
  56487. export * from "babylonjs/Meshes/dataBuffer";
  56488. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  56489. }
  56490. declare module "babylonjs/Morph/index" {
  56491. export * from "babylonjs/Morph/morphTarget";
  56492. export * from "babylonjs/Morph/morphTargetManager";
  56493. }
  56494. declare module "babylonjs/Offline/database" {
  56495. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  56496. /**
  56497. * Class used to enable access to IndexedDB
  56498. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56499. */
  56500. export class Database implements IOfflineProvider {
  56501. private _callbackManifestChecked;
  56502. private _currentSceneUrl;
  56503. private _db;
  56504. private _enableSceneOffline;
  56505. private _enableTexturesOffline;
  56506. private _manifestVersionFound;
  56507. private _mustUpdateRessources;
  56508. private _hasReachedQuota;
  56509. private _isSupported;
  56510. private _idbFactory;
  56511. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56512. private static IsUASupportingBlobStorage;
  56513. /**
  56514. * Gets a boolean indicating if Database storate is enabled (off by default)
  56515. */
  56516. static IDBStorageEnabled: boolean;
  56517. /**
  56518. * Gets a boolean indicating if scene must be saved in the database
  56519. */
  56520. readonly enableSceneOffline: boolean;
  56521. /**
  56522. * Gets a boolean indicating if textures must be saved in the database
  56523. */
  56524. readonly enableTexturesOffline: boolean;
  56525. /**
  56526. * Creates a new Database
  56527. * @param urlToScene defines the url to load the scene
  56528. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56529. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56530. */
  56531. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56532. private static _ParseURL;
  56533. private static _ReturnFullUrlLocation;
  56534. private _checkManifestFile;
  56535. /**
  56536. * Open the database and make it available
  56537. * @param successCallback defines the callback to call on success
  56538. * @param errorCallback defines the callback to call on error
  56539. */
  56540. open(successCallback: () => void, errorCallback: () => void): void;
  56541. /**
  56542. * Loads an image from the database
  56543. * @param url defines the url to load from
  56544. * @param image defines the target DOM image
  56545. */
  56546. loadImage(url: string, image: HTMLImageElement): void;
  56547. private _loadImageFromDBAsync;
  56548. private _saveImageIntoDBAsync;
  56549. private _checkVersionFromDB;
  56550. private _loadVersionFromDBAsync;
  56551. private _saveVersionIntoDBAsync;
  56552. /**
  56553. * Loads a file from database
  56554. * @param url defines the URL to load from
  56555. * @param sceneLoaded defines a callback to call on success
  56556. * @param progressCallBack defines a callback to call when progress changed
  56557. * @param errorCallback defines a callback to call on error
  56558. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56559. */
  56560. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56561. private _loadFileAsync;
  56562. private _saveFileAsync;
  56563. /**
  56564. * Validates if xhr data is correct
  56565. * @param xhr defines the request to validate
  56566. * @param dataType defines the expected data type
  56567. * @returns true if data is correct
  56568. */
  56569. private static _ValidateXHRData;
  56570. }
  56571. }
  56572. declare module "babylonjs/Offline/index" {
  56573. export * from "babylonjs/Offline/database";
  56574. export * from "babylonjs/Offline/IOfflineProvider";
  56575. }
  56576. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  56577. /** @hidden */
  56578. export var gpuUpdateParticlesPixelShader: {
  56579. name: string;
  56580. shader: string;
  56581. };
  56582. }
  56583. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  56584. /** @hidden */
  56585. export var gpuUpdateParticlesVertexShader: {
  56586. name: string;
  56587. shader: string;
  56588. };
  56589. }
  56590. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  56591. /** @hidden */
  56592. export var clipPlaneFragmentDeclaration2: {
  56593. name: string;
  56594. shader: string;
  56595. };
  56596. }
  56597. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  56598. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  56599. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56600. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56601. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56602. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56603. /** @hidden */
  56604. export var gpuRenderParticlesPixelShader: {
  56605. name: string;
  56606. shader: string;
  56607. };
  56608. }
  56609. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  56610. /** @hidden */
  56611. export var clipPlaneVertexDeclaration2: {
  56612. name: string;
  56613. shader: string;
  56614. };
  56615. }
  56616. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  56617. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  56618. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56619. /** @hidden */
  56620. export var gpuRenderParticlesVertexShader: {
  56621. name: string;
  56622. shader: string;
  56623. };
  56624. }
  56625. declare module "babylonjs/Particles/gpuParticleSystem" {
  56626. import { Nullable } from "babylonjs/types";
  56627. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  56628. import { Observable } from "babylonjs/Misc/observable";
  56629. import { Color4, Color3 } from "babylonjs/Maths/math";
  56630. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56631. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  56632. import { Scene, IDisposable } from "babylonjs/scene";
  56633. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  56634. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  56635. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  56636. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56637. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56638. /**
  56639. * This represents a GPU particle system in Babylon
  56640. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56641. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56642. */
  56643. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56644. /**
  56645. * The layer mask we are rendering the particles through.
  56646. */
  56647. layerMask: number;
  56648. private _capacity;
  56649. private _activeCount;
  56650. private _currentActiveCount;
  56651. private _accumulatedCount;
  56652. private _renderEffect;
  56653. private _updateEffect;
  56654. private _buffer0;
  56655. private _buffer1;
  56656. private _spriteBuffer;
  56657. private _updateVAO;
  56658. private _renderVAO;
  56659. private _targetIndex;
  56660. private _sourceBuffer;
  56661. private _targetBuffer;
  56662. private _engine;
  56663. private _currentRenderId;
  56664. private _started;
  56665. private _stopped;
  56666. private _timeDelta;
  56667. private _randomTexture;
  56668. private _randomTexture2;
  56669. private _attributesStrideSize;
  56670. private _updateEffectOptions;
  56671. private _randomTextureSize;
  56672. private _actualFrame;
  56673. private readonly _rawTextureWidth;
  56674. /**
  56675. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56676. */
  56677. static readonly IsSupported: boolean;
  56678. /**
  56679. * An event triggered when the system is disposed.
  56680. */
  56681. onDisposeObservable: Observable<GPUParticleSystem>;
  56682. /**
  56683. * Gets the maximum number of particles active at the same time.
  56684. * @returns The max number of active particles.
  56685. */
  56686. getCapacity(): number;
  56687. /**
  56688. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56689. * to override the particles.
  56690. */
  56691. forceDepthWrite: boolean;
  56692. /**
  56693. * Gets or set the number of active particles
  56694. */
  56695. activeParticleCount: number;
  56696. private _preWarmDone;
  56697. /**
  56698. * Is this system ready to be used/rendered
  56699. * @return true if the system is ready
  56700. */
  56701. isReady(): boolean;
  56702. /**
  56703. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56704. * @returns True if it has been started, otherwise false.
  56705. */
  56706. isStarted(): boolean;
  56707. /**
  56708. * Starts the particle system and begins to emit
  56709. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56710. */
  56711. start(delay?: number): void;
  56712. /**
  56713. * Stops the particle system.
  56714. */
  56715. stop(): void;
  56716. /**
  56717. * Remove all active particles
  56718. */
  56719. reset(): void;
  56720. /**
  56721. * Returns the string "GPUParticleSystem"
  56722. * @returns a string containing the class name
  56723. */
  56724. getClassName(): string;
  56725. private _colorGradientsTexture;
  56726. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56727. /**
  56728. * Adds a new color gradient
  56729. * @param gradient defines the gradient to use (between 0 and 1)
  56730. * @param color1 defines the color to affect to the specified gradient
  56731. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56732. * @returns the current particle system
  56733. */
  56734. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56735. /**
  56736. * Remove a specific color gradient
  56737. * @param gradient defines the gradient to remove
  56738. * @returns the current particle system
  56739. */
  56740. removeColorGradient(gradient: number): GPUParticleSystem;
  56741. private _angularSpeedGradientsTexture;
  56742. private _sizeGradientsTexture;
  56743. private _velocityGradientsTexture;
  56744. private _limitVelocityGradientsTexture;
  56745. private _dragGradientsTexture;
  56746. private _addFactorGradient;
  56747. /**
  56748. * Adds a new size gradient
  56749. * @param gradient defines the gradient to use (between 0 and 1)
  56750. * @param factor defines the size factor to affect to the specified gradient
  56751. * @returns the current particle system
  56752. */
  56753. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56754. /**
  56755. * Remove a specific size gradient
  56756. * @param gradient defines the gradient to remove
  56757. * @returns the current particle system
  56758. */
  56759. removeSizeGradient(gradient: number): GPUParticleSystem;
  56760. /**
  56761. * Adds a new angular speed gradient
  56762. * @param gradient defines the gradient to use (between 0 and 1)
  56763. * @param factor defines the angular speed to affect to the specified gradient
  56764. * @returns the current particle system
  56765. */
  56766. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56767. /**
  56768. * Remove a specific angular speed gradient
  56769. * @param gradient defines the gradient to remove
  56770. * @returns the current particle system
  56771. */
  56772. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56773. /**
  56774. * Adds a new velocity gradient
  56775. * @param gradient defines the gradient to use (between 0 and 1)
  56776. * @param factor defines the velocity to affect to the specified gradient
  56777. * @returns the current particle system
  56778. */
  56779. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56780. /**
  56781. * Remove a specific velocity gradient
  56782. * @param gradient defines the gradient to remove
  56783. * @returns the current particle system
  56784. */
  56785. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56786. /**
  56787. * Adds a new limit velocity gradient
  56788. * @param gradient defines the gradient to use (between 0 and 1)
  56789. * @param factor defines the limit velocity value to affect to the specified gradient
  56790. * @returns the current particle system
  56791. */
  56792. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56793. /**
  56794. * Remove a specific limit velocity gradient
  56795. * @param gradient defines the gradient to remove
  56796. * @returns the current particle system
  56797. */
  56798. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56799. /**
  56800. * Adds a new drag gradient
  56801. * @param gradient defines the gradient to use (between 0 and 1)
  56802. * @param factor defines the drag value to affect to the specified gradient
  56803. * @returns the current particle system
  56804. */
  56805. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56806. /**
  56807. * Remove a specific drag gradient
  56808. * @param gradient defines the gradient to remove
  56809. * @returns the current particle system
  56810. */
  56811. removeDragGradient(gradient: number): GPUParticleSystem;
  56812. /**
  56813. * Not supported by GPUParticleSystem
  56814. * @param gradient defines the gradient to use (between 0 and 1)
  56815. * @param factor defines the emit rate value to affect to the specified gradient
  56816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56817. * @returns the current particle system
  56818. */
  56819. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56820. /**
  56821. * Not supported by GPUParticleSystem
  56822. * @param gradient defines the gradient to remove
  56823. * @returns the current particle system
  56824. */
  56825. removeEmitRateGradient(gradient: number): IParticleSystem;
  56826. /**
  56827. * Not supported by GPUParticleSystem
  56828. * @param gradient defines the gradient to use (between 0 and 1)
  56829. * @param factor defines the start size value to affect to the specified gradient
  56830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56831. * @returns the current particle system
  56832. */
  56833. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56834. /**
  56835. * Not supported by GPUParticleSystem
  56836. * @param gradient defines the gradient to remove
  56837. * @returns the current particle system
  56838. */
  56839. removeStartSizeGradient(gradient: number): IParticleSystem;
  56840. /**
  56841. * Not supported by GPUParticleSystem
  56842. * @param gradient defines the gradient to use (between 0 and 1)
  56843. * @param min defines the color remap minimal range
  56844. * @param max defines the color remap maximal range
  56845. * @returns the current particle system
  56846. */
  56847. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56848. /**
  56849. * Not supported by GPUParticleSystem
  56850. * @param gradient defines the gradient to remove
  56851. * @returns the current particle system
  56852. */
  56853. removeColorRemapGradient(): IParticleSystem;
  56854. /**
  56855. * Not supported by GPUParticleSystem
  56856. * @param gradient defines the gradient to use (between 0 and 1)
  56857. * @param min defines the alpha remap minimal range
  56858. * @param max defines the alpha remap maximal range
  56859. * @returns the current particle system
  56860. */
  56861. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56862. /**
  56863. * Not supported by GPUParticleSystem
  56864. * @param gradient defines the gradient to remove
  56865. * @returns the current particle system
  56866. */
  56867. removeAlphaRemapGradient(): IParticleSystem;
  56868. /**
  56869. * Not supported by GPUParticleSystem
  56870. * @param gradient defines the gradient to use (between 0 and 1)
  56871. * @param color defines the color to affect to the specified gradient
  56872. * @returns the current particle system
  56873. */
  56874. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56875. /**
  56876. * Not supported by GPUParticleSystem
  56877. * @param gradient defines the gradient to remove
  56878. * @returns the current particle system
  56879. */
  56880. removeRampGradient(): IParticleSystem;
  56881. /**
  56882. * Not supported by GPUParticleSystem
  56883. * @returns the list of ramp gradients
  56884. */
  56885. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56886. /**
  56887. * Not supported by GPUParticleSystem
  56888. * Gets or sets a boolean indicating that ramp gradients must be used
  56889. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56890. */
  56891. useRampGradients: boolean;
  56892. /**
  56893. * Not supported by GPUParticleSystem
  56894. * @param gradient defines the gradient to use (between 0 and 1)
  56895. * @param factor defines the life time factor to affect to the specified gradient
  56896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56897. * @returns the current particle system
  56898. */
  56899. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56900. /**
  56901. * Not supported by GPUParticleSystem
  56902. * @param gradient defines the gradient to remove
  56903. * @returns the current particle system
  56904. */
  56905. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56906. /**
  56907. * Instantiates a GPU particle system.
  56908. * 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.
  56909. * @param name The name of the particle system
  56910. * @param options The options used to create the system
  56911. * @param scene The scene the particle system belongs to
  56912. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56913. */
  56914. constructor(name: string, options: Partial<{
  56915. capacity: number;
  56916. randomTextureSize: number;
  56917. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56918. protected _reset(): void;
  56919. private _createUpdateVAO;
  56920. private _createRenderVAO;
  56921. private _initialize;
  56922. /** @hidden */
  56923. _recreateUpdateEffect(): void;
  56924. /** @hidden */
  56925. _recreateRenderEffect(): void;
  56926. /**
  56927. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56928. * @param preWarm defines if we are in the pre-warmimg phase
  56929. */
  56930. animate(preWarm?: boolean): void;
  56931. private _createFactorGradientTexture;
  56932. private _createSizeGradientTexture;
  56933. private _createAngularSpeedGradientTexture;
  56934. private _createVelocityGradientTexture;
  56935. private _createLimitVelocityGradientTexture;
  56936. private _createDragGradientTexture;
  56937. private _createColorGradientTexture;
  56938. /**
  56939. * Renders the particle system in its current state
  56940. * @param preWarm defines if the system should only update the particles but not render them
  56941. * @returns the current number of particles
  56942. */
  56943. render(preWarm?: boolean): number;
  56944. /**
  56945. * Rebuilds the particle system
  56946. */
  56947. rebuild(): void;
  56948. private _releaseBuffers;
  56949. private _releaseVAOs;
  56950. /**
  56951. * Disposes the particle system and free the associated resources
  56952. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56953. */
  56954. dispose(disposeTexture?: boolean): void;
  56955. /**
  56956. * Clones the particle system.
  56957. * @param name The name of the cloned object
  56958. * @param newEmitter The new emitter to use
  56959. * @returns the cloned particle system
  56960. */
  56961. clone(name: string, newEmitter: any): GPUParticleSystem;
  56962. /**
  56963. * Serializes the particle system to a JSON object.
  56964. * @returns the JSON object
  56965. */
  56966. serialize(): any;
  56967. /**
  56968. * Parses a JSON object to create a GPU particle system.
  56969. * @param parsedParticleSystem The JSON object to parse
  56970. * @param scene The scene to create the particle system in
  56971. * @param rootUrl The root url to use to load external dependencies like texture
  56972. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56973. * @returns the parsed GPU particle system
  56974. */
  56975. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56976. }
  56977. }
  56978. declare module "babylonjs/Particles/particleSystemSet" {
  56979. import { Nullable } from "babylonjs/types";
  56980. import { Color3 } from "babylonjs/Maths/math";
  56981. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56983. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56984. import { Scene, IDisposable } from "babylonjs/scene";
  56985. /**
  56986. * Represents a set of particle systems working together to create a specific effect
  56987. */
  56988. export class ParticleSystemSet implements IDisposable {
  56989. private _emitterCreationOptions;
  56990. private _emitterNode;
  56991. /**
  56992. * Gets the particle system list
  56993. */
  56994. systems: IParticleSystem[];
  56995. /**
  56996. * Gets the emitter node used with this set
  56997. */
  56998. readonly emitterNode: Nullable<TransformNode>;
  56999. /**
  57000. * Creates a new emitter mesh as a sphere
  57001. * @param options defines the options used to create the sphere
  57002. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57003. * @param scene defines the hosting scene
  57004. */
  57005. setEmitterAsSphere(options: {
  57006. diameter: number;
  57007. segments: number;
  57008. color: Color3;
  57009. }, renderingGroupId: number, scene: Scene): void;
  57010. /**
  57011. * Starts all particle systems of the set
  57012. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57013. */
  57014. start(emitter?: AbstractMesh): void;
  57015. /**
  57016. * Release all associated resources
  57017. */
  57018. dispose(): void;
  57019. /**
  57020. * Serialize the set into a JSON compatible object
  57021. * @returns a JSON compatible representation of the set
  57022. */
  57023. serialize(): any;
  57024. /**
  57025. * Parse a new ParticleSystemSet from a serialized source
  57026. * @param data defines a JSON compatible representation of the set
  57027. * @param scene defines the hosting scene
  57028. * @param gpu defines if we want GPU particles or CPU particles
  57029. * @returns a new ParticleSystemSet
  57030. */
  57031. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57032. }
  57033. }
  57034. declare module "babylonjs/Particles/particleHelper" {
  57035. import { Nullable } from "babylonjs/types";
  57036. import { Scene } from "babylonjs/scene";
  57037. import { Vector3 } from "babylonjs/Maths/math";
  57038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57039. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57040. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  57041. /**
  57042. * This class is made for on one-liner static method to help creating particle system set.
  57043. */
  57044. export class ParticleHelper {
  57045. /**
  57046. * Gets or sets base Assets URL
  57047. */
  57048. static BaseAssetsUrl: string;
  57049. /**
  57050. * Create a default particle system that you can tweak
  57051. * @param emitter defines the emitter to use
  57052. * @param capacity defines the system capacity (default is 500 particles)
  57053. * @param scene defines the hosting scene
  57054. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57055. * @returns the new Particle system
  57056. */
  57057. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57058. /**
  57059. * This is the main static method (one-liner) of this helper to create different particle systems
  57060. * @param type This string represents the type to the particle system to create
  57061. * @param scene The scene where the particle system should live
  57062. * @param gpu If the system will use gpu
  57063. * @returns the ParticleSystemSet created
  57064. */
  57065. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57066. /**
  57067. * Static function used to export a particle system to a ParticleSystemSet variable.
  57068. * Please note that the emitter shape is not exported
  57069. * @param systems defines the particle systems to export
  57070. * @returns the created particle system set
  57071. */
  57072. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57073. }
  57074. }
  57075. declare module "babylonjs/Particles/particleSystemComponent" {
  57076. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57077. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  57078. import "babylonjs/Shaders/particles.vertex";
  57079. module "babylonjs/Engines/engine" {
  57080. interface Engine {
  57081. /**
  57082. * Create an effect to use with particle systems.
  57083. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57084. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57085. * @param uniformsNames defines a list of attribute names
  57086. * @param samplers defines an array of string used to represent textures
  57087. * @param defines defines the string containing the defines to use to compile the shaders
  57088. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57089. * @param onCompiled defines a function to call when the effect creation is successful
  57090. * @param onError defines a function to call when the effect creation has failed
  57091. * @returns the new Effect
  57092. */
  57093. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57094. }
  57095. }
  57096. module "babylonjs/Meshes/mesh" {
  57097. interface Mesh {
  57098. /**
  57099. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57100. * @returns an array of IParticleSystem
  57101. */
  57102. getEmittedParticleSystems(): IParticleSystem[];
  57103. /**
  57104. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57105. * @returns an array of IParticleSystem
  57106. */
  57107. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57108. }
  57109. }
  57110. /**
  57111. * @hidden
  57112. */
  57113. export var _IDoNeedToBeInTheBuild: number;
  57114. }
  57115. declare module "babylonjs/Particles/index" {
  57116. export * from "babylonjs/Particles/baseParticleSystem";
  57117. export * from "babylonjs/Particles/EmitterTypes/index";
  57118. export * from "babylonjs/Particles/gpuParticleSystem";
  57119. export * from "babylonjs/Particles/IParticleSystem";
  57120. export * from "babylonjs/Particles/particle";
  57121. export * from "babylonjs/Particles/particleHelper";
  57122. export * from "babylonjs/Particles/particleSystem";
  57123. export * from "babylonjs/Particles/particleSystemComponent";
  57124. export * from "babylonjs/Particles/particleSystemSet";
  57125. export * from "babylonjs/Particles/solidParticle";
  57126. export * from "babylonjs/Particles/solidParticleSystem";
  57127. export * from "babylonjs/Particles/subEmitter";
  57128. }
  57129. declare module "babylonjs/Physics/physicsEngineComponent" {
  57130. import { Nullable } from "babylonjs/types";
  57131. import { Observable, Observer } from "babylonjs/Misc/observable";
  57132. import { Vector3 } from "babylonjs/Maths/math";
  57133. import { Mesh } from "babylonjs/Meshes/mesh";
  57134. import { ISceneComponent } from "babylonjs/sceneComponent";
  57135. import { Scene } from "babylonjs/scene";
  57136. import { Node } from "babylonjs/node";
  57137. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57138. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57139. module "babylonjs/scene" {
  57140. interface Scene {
  57141. /** @hidden (Backing field) */
  57142. _physicsEngine: Nullable<IPhysicsEngine>;
  57143. /**
  57144. * Gets the current physics engine
  57145. * @returns a IPhysicsEngine or null if none attached
  57146. */
  57147. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57148. /**
  57149. * Enables physics to the current scene
  57150. * @param gravity defines the scene's gravity for the physics engine
  57151. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57152. * @return a boolean indicating if the physics engine was initialized
  57153. */
  57154. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57155. /**
  57156. * Disables and disposes the physics engine associated with the scene
  57157. */
  57158. disablePhysicsEngine(): void;
  57159. /**
  57160. * Gets a boolean indicating if there is an active physics engine
  57161. * @returns a boolean indicating if there is an active physics engine
  57162. */
  57163. isPhysicsEnabled(): boolean;
  57164. /**
  57165. * Deletes a physics compound impostor
  57166. * @param compound defines the compound to delete
  57167. */
  57168. deleteCompoundImpostor(compound: any): void;
  57169. /**
  57170. * An event triggered when physic simulation is about to be run
  57171. */
  57172. onBeforePhysicsObservable: Observable<Scene>;
  57173. /**
  57174. * An event triggered when physic simulation has been done
  57175. */
  57176. onAfterPhysicsObservable: Observable<Scene>;
  57177. }
  57178. }
  57179. module "babylonjs/Meshes/abstractMesh" {
  57180. interface AbstractMesh {
  57181. /** @hidden */
  57182. _physicsImpostor: Nullable<PhysicsImpostor>;
  57183. /**
  57184. * Gets or sets impostor used for physic simulation
  57185. * @see http://doc.babylonjs.com/features/physics_engine
  57186. */
  57187. physicsImpostor: Nullable<PhysicsImpostor>;
  57188. /**
  57189. * Gets the current physics impostor
  57190. * @see http://doc.babylonjs.com/features/physics_engine
  57191. * @returns a physics impostor or null
  57192. */
  57193. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57194. /** Apply a physic impulse to the mesh
  57195. * @param force defines the force to apply
  57196. * @param contactPoint defines where to apply the force
  57197. * @returns the current mesh
  57198. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57199. */
  57200. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57201. /**
  57202. * Creates a physic joint between two meshes
  57203. * @param otherMesh defines the other mesh to use
  57204. * @param pivot1 defines the pivot to use on this mesh
  57205. * @param pivot2 defines the pivot to use on the other mesh
  57206. * @param options defines additional options (can be plugin dependent)
  57207. * @returns the current mesh
  57208. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57209. */
  57210. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57211. /** @hidden */
  57212. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57213. }
  57214. }
  57215. /**
  57216. * Defines the physics engine scene component responsible to manage a physics engine
  57217. */
  57218. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57219. /**
  57220. * The component name helpful to identify the component in the list of scene components.
  57221. */
  57222. readonly name: string;
  57223. /**
  57224. * The scene the component belongs to.
  57225. */
  57226. scene: Scene;
  57227. /**
  57228. * Creates a new instance of the component for the given scene
  57229. * @param scene Defines the scene to register the component in
  57230. */
  57231. constructor(scene: Scene);
  57232. /**
  57233. * Registers the component in a given scene
  57234. */
  57235. register(): void;
  57236. /**
  57237. * Rebuilds the elements related to this component in case of
  57238. * context lost for instance.
  57239. */
  57240. rebuild(): void;
  57241. /**
  57242. * Disposes the component and the associated ressources
  57243. */
  57244. dispose(): void;
  57245. }
  57246. }
  57247. declare module "babylonjs/Physics/physicsHelper" {
  57248. import { Nullable } from "babylonjs/types";
  57249. import { Vector3 } from "babylonjs/Maths/math";
  57250. import { Mesh } from "babylonjs/Meshes/mesh";
  57251. import { Scene } from "babylonjs/scene";
  57252. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57253. /**
  57254. * A helper for physics simulations
  57255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57256. */
  57257. export class PhysicsHelper {
  57258. private _scene;
  57259. private _physicsEngine;
  57260. /**
  57261. * Initializes the Physics helper
  57262. * @param scene Babylon.js scene
  57263. */
  57264. constructor(scene: Scene);
  57265. /**
  57266. * Applies a radial explosion impulse
  57267. * @param origin the origin of the explosion
  57268. * @param radiusOrEventOptions the radius or the options of radial explosion
  57269. * @param strength the explosion strength
  57270. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57271. * @returns A physics radial explosion event, or null
  57272. */
  57273. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57274. /**
  57275. * Applies a radial explosion force
  57276. * @param origin the origin of the explosion
  57277. * @param radiusOrEventOptions the radius or the options of radial explosion
  57278. * @param strength the explosion strength
  57279. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57280. * @returns A physics radial explosion event, or null
  57281. */
  57282. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57283. /**
  57284. * Creates a gravitational field
  57285. * @param origin the origin of the explosion
  57286. * @param radiusOrEventOptions the radius or the options of radial explosion
  57287. * @param strength the explosion strength
  57288. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57289. * @returns A physics gravitational field event, or null
  57290. */
  57291. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57292. /**
  57293. * Creates a physics updraft event
  57294. * @param origin the origin of the updraft
  57295. * @param radiusOrEventOptions the radius or the options of the updraft
  57296. * @param strength the strength of the updraft
  57297. * @param height the height of the updraft
  57298. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57299. * @returns A physics updraft event, or null
  57300. */
  57301. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57302. /**
  57303. * Creates a physics vortex event
  57304. * @param origin the of the vortex
  57305. * @param radiusOrEventOptions the radius or the options of the vortex
  57306. * @param strength the strength of the vortex
  57307. * @param height the height of the vortex
  57308. * @returns a Physics vortex event, or null
  57309. * A physics vortex event or null
  57310. */
  57311. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57312. }
  57313. /**
  57314. * Represents a physics radial explosion event
  57315. */
  57316. class PhysicsRadialExplosionEvent {
  57317. private _scene;
  57318. private _options;
  57319. private _sphere;
  57320. private _dataFetched;
  57321. /**
  57322. * Initializes a radial explosioin event
  57323. * @param _scene BabylonJS scene
  57324. * @param _options The options for the vortex event
  57325. */
  57326. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57327. /**
  57328. * Returns the data related to the radial explosion event (sphere).
  57329. * @returns The radial explosion event data
  57330. */
  57331. getData(): PhysicsRadialExplosionEventData;
  57332. /**
  57333. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57334. * @param impostor A physics imposter
  57335. * @param origin the origin of the explosion
  57336. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57337. */
  57338. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57339. /**
  57340. * Triggers affecterd impostors callbacks
  57341. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57342. */
  57343. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57344. /**
  57345. * Disposes the sphere.
  57346. * @param force Specifies if the sphere should be disposed by force
  57347. */
  57348. dispose(force?: boolean): void;
  57349. /*** Helpers ***/
  57350. private _prepareSphere;
  57351. private _intersectsWithSphere;
  57352. }
  57353. /**
  57354. * Represents a gravitational field event
  57355. */
  57356. class PhysicsGravitationalFieldEvent {
  57357. private _physicsHelper;
  57358. private _scene;
  57359. private _origin;
  57360. private _options;
  57361. private _tickCallback;
  57362. private _sphere;
  57363. private _dataFetched;
  57364. /**
  57365. * Initializes the physics gravitational field event
  57366. * @param _physicsHelper A physics helper
  57367. * @param _scene BabylonJS scene
  57368. * @param _origin The origin position of the gravitational field event
  57369. * @param _options The options for the vortex event
  57370. */
  57371. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57372. /**
  57373. * Returns the data related to the gravitational field event (sphere).
  57374. * @returns A gravitational field event
  57375. */
  57376. getData(): PhysicsGravitationalFieldEventData;
  57377. /**
  57378. * Enables the gravitational field.
  57379. */
  57380. enable(): void;
  57381. /**
  57382. * Disables the gravitational field.
  57383. */
  57384. disable(): void;
  57385. /**
  57386. * Disposes the sphere.
  57387. * @param force The force to dispose from the gravitational field event
  57388. */
  57389. dispose(force?: boolean): void;
  57390. private _tick;
  57391. }
  57392. /**
  57393. * Represents a physics updraft event
  57394. */
  57395. class PhysicsUpdraftEvent {
  57396. private _scene;
  57397. private _origin;
  57398. private _options;
  57399. private _physicsEngine;
  57400. private _originTop;
  57401. private _originDirection;
  57402. private _tickCallback;
  57403. private _cylinder;
  57404. private _cylinderPosition;
  57405. private _dataFetched;
  57406. /**
  57407. * Initializes the physics updraft event
  57408. * @param _scene BabylonJS scene
  57409. * @param _origin The origin position of the updraft
  57410. * @param _options The options for the updraft event
  57411. */
  57412. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57413. /**
  57414. * Returns the data related to the updraft event (cylinder).
  57415. * @returns A physics updraft event
  57416. */
  57417. getData(): PhysicsUpdraftEventData;
  57418. /**
  57419. * Enables the updraft.
  57420. */
  57421. enable(): void;
  57422. /**
  57423. * Disables the updraft.
  57424. */
  57425. disable(): void;
  57426. /**
  57427. * Disposes the cylinder.
  57428. * @param force Specifies if the updraft should be disposed by force
  57429. */
  57430. dispose(force?: boolean): void;
  57431. private getImpostorHitData;
  57432. private _tick;
  57433. /*** Helpers ***/
  57434. private _prepareCylinder;
  57435. private _intersectsWithCylinder;
  57436. }
  57437. /**
  57438. * Represents a physics vortex event
  57439. */
  57440. class PhysicsVortexEvent {
  57441. private _scene;
  57442. private _origin;
  57443. private _options;
  57444. private _physicsEngine;
  57445. private _originTop;
  57446. private _tickCallback;
  57447. private _cylinder;
  57448. private _cylinderPosition;
  57449. private _dataFetched;
  57450. /**
  57451. * Initializes the physics vortex event
  57452. * @param _scene The BabylonJS scene
  57453. * @param _origin The origin position of the vortex
  57454. * @param _options The options for the vortex event
  57455. */
  57456. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57457. /**
  57458. * Returns the data related to the vortex event (cylinder).
  57459. * @returns The physics vortex event data
  57460. */
  57461. getData(): PhysicsVortexEventData;
  57462. /**
  57463. * Enables the vortex.
  57464. */
  57465. enable(): void;
  57466. /**
  57467. * Disables the cortex.
  57468. */
  57469. disable(): void;
  57470. /**
  57471. * Disposes the sphere.
  57472. * @param force
  57473. */
  57474. dispose(force?: boolean): void;
  57475. private getImpostorHitData;
  57476. private _tick;
  57477. /*** Helpers ***/
  57478. private _prepareCylinder;
  57479. private _intersectsWithCylinder;
  57480. }
  57481. /**
  57482. * Options fot the radial explosion event
  57483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57484. */
  57485. export class PhysicsRadialExplosionEventOptions {
  57486. /**
  57487. * The radius of the sphere for the radial explosion.
  57488. */
  57489. radius: number;
  57490. /**
  57491. * The strenth of the explosion.
  57492. */
  57493. strength: number;
  57494. /**
  57495. * The strenght of the force in correspondence to the distance of the affected object
  57496. */
  57497. falloff: PhysicsRadialImpulseFalloff;
  57498. /**
  57499. * Sphere options for the radial explosion.
  57500. */
  57501. sphere: {
  57502. segments: number;
  57503. diameter: number;
  57504. };
  57505. /**
  57506. * Sphere options for the radial explosion.
  57507. */
  57508. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57509. }
  57510. /**
  57511. * Options fot the updraft event
  57512. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57513. */
  57514. export class PhysicsUpdraftEventOptions {
  57515. /**
  57516. * The radius of the cylinder for the vortex
  57517. */
  57518. radius: number;
  57519. /**
  57520. * The strenth of the updraft.
  57521. */
  57522. strength: number;
  57523. /**
  57524. * The height of the cylinder for the updraft.
  57525. */
  57526. height: number;
  57527. /**
  57528. * The mode for the the updraft.
  57529. */
  57530. updraftMode: PhysicsUpdraftMode;
  57531. }
  57532. /**
  57533. * Options fot the vortex event
  57534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57535. */
  57536. export class PhysicsVortexEventOptions {
  57537. /**
  57538. * The radius of the cylinder for the vortex
  57539. */
  57540. radius: number;
  57541. /**
  57542. * The strenth of the vortex.
  57543. */
  57544. strength: number;
  57545. /**
  57546. * The height of the cylinder for the vortex.
  57547. */
  57548. height: number;
  57549. /**
  57550. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57551. */
  57552. centripetalForceThreshold: number;
  57553. /**
  57554. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57555. */
  57556. centripetalForceMultiplier: number;
  57557. /**
  57558. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57559. */
  57560. centrifugalForceMultiplier: number;
  57561. /**
  57562. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57563. */
  57564. updraftForceMultiplier: number;
  57565. }
  57566. /**
  57567. * The strenght of the force in correspondence to the distance of the affected object
  57568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57569. */
  57570. export enum PhysicsRadialImpulseFalloff {
  57571. /** Defines that impulse is constant in strength across it's whole radius */
  57572. Constant = 0,
  57573. /** Defines that impulse gets weaker if it's further from the origin */
  57574. Linear = 1
  57575. }
  57576. /**
  57577. * The strength of the force in correspondence to the distance of the affected object
  57578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57579. */
  57580. export enum PhysicsUpdraftMode {
  57581. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57582. Center = 0,
  57583. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57584. Perpendicular = 1
  57585. }
  57586. /**
  57587. * Interface for a physics hit data
  57588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57589. */
  57590. export interface PhysicsHitData {
  57591. /**
  57592. * The force applied at the contact point
  57593. */
  57594. force: Vector3;
  57595. /**
  57596. * The contact point
  57597. */
  57598. contactPoint: Vector3;
  57599. /**
  57600. * The distance from the origin to the contact point
  57601. */
  57602. distanceFromOrigin: number;
  57603. }
  57604. /**
  57605. * Interface for radial explosion event data
  57606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57607. */
  57608. export interface PhysicsRadialExplosionEventData {
  57609. /**
  57610. * A sphere used for the radial explosion event
  57611. */
  57612. sphere: Mesh;
  57613. }
  57614. /**
  57615. * Interface for gravitational field event data
  57616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57617. */
  57618. export interface PhysicsGravitationalFieldEventData {
  57619. /**
  57620. * A sphere mesh used for the gravitational field event
  57621. */
  57622. sphere: Mesh;
  57623. }
  57624. /**
  57625. * Interface for updraft event data
  57626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57627. */
  57628. export interface PhysicsUpdraftEventData {
  57629. /**
  57630. * A cylinder used for the updraft event
  57631. */
  57632. cylinder: Mesh;
  57633. }
  57634. /**
  57635. * Interface for vortex event data
  57636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57637. */
  57638. export interface PhysicsVortexEventData {
  57639. /**
  57640. * A cylinder used for the vortex event
  57641. */
  57642. cylinder: Mesh;
  57643. }
  57644. /**
  57645. * Interface for an affected physics impostor
  57646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57647. */
  57648. export interface PhysicsAffectedImpostorWithData {
  57649. /**
  57650. * The impostor affected by the effect
  57651. */
  57652. impostor: PhysicsImpostor;
  57653. /**
  57654. * The data about the hit/horce from the explosion
  57655. */
  57656. hitData: PhysicsHitData;
  57657. }
  57658. }
  57659. declare module "babylonjs/Physics/Plugins/index" {
  57660. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57661. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57662. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57663. }
  57664. declare module "babylonjs/Physics/index" {
  57665. export * from "babylonjs/Physics/IPhysicsEngine";
  57666. export * from "babylonjs/Physics/physicsEngine";
  57667. export * from "babylonjs/Physics/physicsEngineComponent";
  57668. export * from "babylonjs/Physics/physicsHelper";
  57669. export * from "babylonjs/Physics/physicsImpostor";
  57670. export * from "babylonjs/Physics/physicsJoint";
  57671. export * from "babylonjs/Physics/Plugins/index";
  57672. }
  57673. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57674. /** @hidden */
  57675. export var blackAndWhitePixelShader: {
  57676. name: string;
  57677. shader: string;
  57678. };
  57679. }
  57680. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57681. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57682. import { Camera } from "babylonjs/Cameras/camera";
  57683. import { Engine } from "babylonjs/Engines/engine";
  57684. import "babylonjs/Shaders/blackAndWhite.fragment";
  57685. /**
  57686. * Post process used to render in black and white
  57687. */
  57688. export class BlackAndWhitePostProcess extends PostProcess {
  57689. /**
  57690. * Linear about to convert he result to black and white (default: 1)
  57691. */
  57692. degree: number;
  57693. /**
  57694. * Creates a black and white post process
  57695. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57696. * @param name The name of the effect.
  57697. * @param options The required width/height ratio to downsize to before computing the render pass.
  57698. * @param camera The camera to apply the render pass to.
  57699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57700. * @param engine The engine which the post process will be applied. (default: current engine)
  57701. * @param reusable If the post process can be reused on the same frame. (default: false)
  57702. */
  57703. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57704. }
  57705. }
  57706. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57707. import { Nullable } from "babylonjs/types";
  57708. import { Camera } from "babylonjs/Cameras/camera";
  57709. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57710. import { Engine } from "babylonjs/Engines/engine";
  57711. /**
  57712. * This represents a set of one or more post processes in Babylon.
  57713. * A post process can be used to apply a shader to a texture after it is rendered.
  57714. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57715. */
  57716. export class PostProcessRenderEffect {
  57717. private _postProcesses;
  57718. private _getPostProcesses;
  57719. private _singleInstance;
  57720. private _cameras;
  57721. private _indicesForCamera;
  57722. /**
  57723. * Name of the effect
  57724. * @hidden
  57725. */
  57726. _name: string;
  57727. /**
  57728. * Instantiates a post process render effect.
  57729. * A post process can be used to apply a shader to a texture after it is rendered.
  57730. * @param engine The engine the effect is tied to
  57731. * @param name The name of the effect
  57732. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57733. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57734. */
  57735. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57736. /**
  57737. * Checks if all the post processes in the effect are supported.
  57738. */
  57739. readonly isSupported: boolean;
  57740. /**
  57741. * Updates the current state of the effect
  57742. * @hidden
  57743. */
  57744. _update(): void;
  57745. /**
  57746. * Attaches the effect on cameras
  57747. * @param cameras The camera to attach to.
  57748. * @hidden
  57749. */
  57750. _attachCameras(cameras: Camera): void;
  57751. /**
  57752. * Attaches the effect on cameras
  57753. * @param cameras The camera to attach to.
  57754. * @hidden
  57755. */
  57756. _attachCameras(cameras: Camera[]): void;
  57757. /**
  57758. * Detaches the effect on cameras
  57759. * @param cameras The camera to detatch from.
  57760. * @hidden
  57761. */
  57762. _detachCameras(cameras: Camera): void;
  57763. /**
  57764. * Detatches the effect on cameras
  57765. * @param cameras The camera to detatch from.
  57766. * @hidden
  57767. */
  57768. _detachCameras(cameras: Camera[]): void;
  57769. /**
  57770. * Enables the effect on given cameras
  57771. * @param cameras The camera to enable.
  57772. * @hidden
  57773. */
  57774. _enable(cameras: Camera): void;
  57775. /**
  57776. * Enables the effect on given cameras
  57777. * @param cameras The camera to enable.
  57778. * @hidden
  57779. */
  57780. _enable(cameras: Nullable<Camera[]>): void;
  57781. /**
  57782. * Disables the effect on the given cameras
  57783. * @param cameras The camera to disable.
  57784. * @hidden
  57785. */
  57786. _disable(cameras: Camera): void;
  57787. /**
  57788. * Disables the effect on the given cameras
  57789. * @param cameras The camera to disable.
  57790. * @hidden
  57791. */
  57792. _disable(cameras: Nullable<Camera[]>): void;
  57793. /**
  57794. * Gets a list of the post processes contained in the effect.
  57795. * @param camera The camera to get the post processes on.
  57796. * @returns The list of the post processes in the effect.
  57797. */
  57798. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57799. }
  57800. }
  57801. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57802. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57803. /** @hidden */
  57804. export var extractHighlightsPixelShader: {
  57805. name: string;
  57806. shader: string;
  57807. };
  57808. }
  57809. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57810. import { Nullable } from "babylonjs/types";
  57811. import { Camera } from "babylonjs/Cameras/camera";
  57812. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57813. import { Engine } from "babylonjs/Engines/engine";
  57814. import "babylonjs/Shaders/extractHighlights.fragment";
  57815. /**
  57816. * 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.
  57817. */
  57818. export class ExtractHighlightsPostProcess extends PostProcess {
  57819. /**
  57820. * The luminance threshold, pixels below this value will be set to black.
  57821. */
  57822. threshold: number;
  57823. /** @hidden */
  57824. _exposure: number;
  57825. /**
  57826. * Post process which has the input texture to be used when performing highlight extraction
  57827. * @hidden
  57828. */
  57829. _inputPostProcess: Nullable<PostProcess>;
  57830. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57831. }
  57832. }
  57833. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57834. /** @hidden */
  57835. export var bloomMergePixelShader: {
  57836. name: string;
  57837. shader: string;
  57838. };
  57839. }
  57840. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57841. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57842. import { Nullable } from "babylonjs/types";
  57843. import { Engine } from "babylonjs/Engines/engine";
  57844. import { Camera } from "babylonjs/Cameras/camera";
  57845. import "babylonjs/Shaders/bloomMerge.fragment";
  57846. /**
  57847. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57848. */
  57849. export class BloomMergePostProcess extends PostProcess {
  57850. /** Weight of the bloom to be added to the original input. */
  57851. weight: number;
  57852. /**
  57853. * Creates a new instance of @see BloomMergePostProcess
  57854. * @param name The name of the effect.
  57855. * @param originalFromInput Post process which's input will be used for the merge.
  57856. * @param blurred Blurred highlights post process which's output will be used.
  57857. * @param weight Weight of the bloom to be added to the original input.
  57858. * @param options The required width/height ratio to downsize to before computing the render pass.
  57859. * @param camera The camera to apply the render pass to.
  57860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57861. * @param engine The engine which the post process will be applied. (default: current engine)
  57862. * @param reusable If the post process can be reused on the same frame. (default: false)
  57863. * @param textureType Type of textures used when performing the post process. (default: 0)
  57864. * @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)
  57865. */
  57866. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57867. /** Weight of the bloom to be added to the original input. */
  57868. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57869. }
  57870. }
  57871. declare module "babylonjs/PostProcesses/bloomEffect" {
  57872. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57873. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57874. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57875. import { Camera } from "babylonjs/Cameras/camera";
  57876. import { Scene } from "babylonjs/scene";
  57877. /**
  57878. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57879. */
  57880. export class BloomEffect extends PostProcessRenderEffect {
  57881. private bloomScale;
  57882. /**
  57883. * @hidden Internal
  57884. */
  57885. _effects: Array<PostProcess>;
  57886. /**
  57887. * @hidden Internal
  57888. */
  57889. _downscale: ExtractHighlightsPostProcess;
  57890. private _blurX;
  57891. private _blurY;
  57892. private _merge;
  57893. /**
  57894. * The luminance threshold to find bright areas of the image to bloom.
  57895. */
  57896. threshold: number;
  57897. /**
  57898. * The strength of the bloom.
  57899. */
  57900. weight: number;
  57901. /**
  57902. * Specifies the size of the bloom blur kernel, relative to the final output size
  57903. */
  57904. kernel: number;
  57905. /**
  57906. * Creates a new instance of @see BloomEffect
  57907. * @param scene The scene the effect belongs to.
  57908. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57909. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57910. * @param bloomWeight The the strength of bloom.
  57911. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57912. * @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)
  57913. */
  57914. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57915. /**
  57916. * Disposes each of the internal effects for a given camera.
  57917. * @param camera The camera to dispose the effect on.
  57918. */
  57919. disposeEffects(camera: Camera): void;
  57920. /**
  57921. * @hidden Internal
  57922. */
  57923. _updateEffects(): void;
  57924. /**
  57925. * Internal
  57926. * @returns if all the contained post processes are ready.
  57927. * @hidden
  57928. */
  57929. _isReady(): boolean;
  57930. }
  57931. }
  57932. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  57933. /** @hidden */
  57934. export var chromaticAberrationPixelShader: {
  57935. name: string;
  57936. shader: string;
  57937. };
  57938. }
  57939. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  57940. import { Vector2 } from "babylonjs/Maths/math";
  57941. import { Nullable } from "babylonjs/types";
  57942. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57943. import { Camera } from "babylonjs/Cameras/camera";
  57944. import { Engine } from "babylonjs/Engines/engine";
  57945. import "babylonjs/Shaders/chromaticAberration.fragment";
  57946. /**
  57947. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57948. */
  57949. export class ChromaticAberrationPostProcess extends PostProcess {
  57950. /**
  57951. * The amount of seperation of rgb channels (default: 30)
  57952. */
  57953. aberrationAmount: number;
  57954. /**
  57955. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57956. */
  57957. radialIntensity: number;
  57958. /**
  57959. * 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))
  57960. */
  57961. direction: Vector2;
  57962. /**
  57963. * 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))
  57964. */
  57965. centerPosition: Vector2;
  57966. /**
  57967. * Creates a new instance ChromaticAberrationPostProcess
  57968. * @param name The name of the effect.
  57969. * @param screenWidth The width of the screen to apply the effect on.
  57970. * @param screenHeight The height of the screen to apply the effect on.
  57971. * @param options The required width/height ratio to downsize to before computing the render pass.
  57972. * @param camera The camera to apply the render pass to.
  57973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57974. * @param engine The engine which the post process will be applied. (default: current engine)
  57975. * @param reusable If the post process can be reused on the same frame. (default: false)
  57976. * @param textureType Type of textures used when performing the post process. (default: 0)
  57977. * @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)
  57978. */
  57979. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57980. }
  57981. }
  57982. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  57983. /** @hidden */
  57984. export var circleOfConfusionPixelShader: {
  57985. name: string;
  57986. shader: string;
  57987. };
  57988. }
  57989. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  57990. import { Nullable } from "babylonjs/types";
  57991. import { Engine } from "babylonjs/Engines/engine";
  57992. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57993. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57994. import { Camera } from "babylonjs/Cameras/camera";
  57995. import "babylonjs/Shaders/circleOfConfusion.fragment";
  57996. /**
  57997. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57998. */
  57999. export class CircleOfConfusionPostProcess extends PostProcess {
  58000. /**
  58001. * 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.
  58002. */
  58003. lensSize: number;
  58004. /**
  58005. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58006. */
  58007. fStop: number;
  58008. /**
  58009. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58010. */
  58011. focusDistance: number;
  58012. /**
  58013. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58014. */
  58015. focalLength: number;
  58016. private _depthTexture;
  58017. /**
  58018. * Creates a new instance CircleOfConfusionPostProcess
  58019. * @param name The name of the effect.
  58020. * @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.
  58021. * @param options The required width/height ratio to downsize to before computing the render pass.
  58022. * @param camera The camera to apply the render pass to.
  58023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58024. * @param engine The engine which the post process will be applied. (default: current engine)
  58025. * @param reusable If the post process can be reused on the same frame. (default: false)
  58026. * @param textureType Type of textures used when performing the post process. (default: 0)
  58027. * @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)
  58028. */
  58029. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58030. /**
  58031. * 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.
  58032. */
  58033. depthTexture: RenderTargetTexture;
  58034. }
  58035. }
  58036. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  58037. /** @hidden */
  58038. export var colorCorrectionPixelShader: {
  58039. name: string;
  58040. shader: string;
  58041. };
  58042. }
  58043. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  58044. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58045. import { Engine } from "babylonjs/Engines/engine";
  58046. import { Camera } from "babylonjs/Cameras/camera";
  58047. import "babylonjs/Shaders/colorCorrection.fragment";
  58048. /**
  58049. *
  58050. * This post-process allows the modification of rendered colors by using
  58051. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58052. *
  58053. * The object needs to be provided an url to a texture containing the color
  58054. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58055. * Use an image editing software to tweak the LUT to match your needs.
  58056. *
  58057. * For an example of a color LUT, see here:
  58058. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58059. * For explanations on color grading, see here:
  58060. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58061. *
  58062. */
  58063. export class ColorCorrectionPostProcess extends PostProcess {
  58064. private _colorTableTexture;
  58065. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58066. }
  58067. }
  58068. declare module "babylonjs/Shaders/convolution.fragment" {
  58069. /** @hidden */
  58070. export var convolutionPixelShader: {
  58071. name: string;
  58072. shader: string;
  58073. };
  58074. }
  58075. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  58076. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58077. import { Nullable } from "babylonjs/types";
  58078. import { Camera } from "babylonjs/Cameras/camera";
  58079. import { Engine } from "babylonjs/Engines/engine";
  58080. import "babylonjs/Shaders/convolution.fragment";
  58081. /**
  58082. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58083. * input texture to perform effects such as edge detection or sharpening
  58084. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58085. */
  58086. export class ConvolutionPostProcess extends PostProcess {
  58087. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58088. kernel: number[];
  58089. /**
  58090. * Creates a new instance ConvolutionPostProcess
  58091. * @param name The name of the effect.
  58092. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58093. * @param options The required width/height ratio to downsize to before computing the render pass.
  58094. * @param camera The camera to apply the render pass to.
  58095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58096. * @param engine The engine which the post process will be applied. (default: current engine)
  58097. * @param reusable If the post process can be reused on the same frame. (default: false)
  58098. * @param textureType Type of textures used when performing the post process. (default: 0)
  58099. */
  58100. constructor(name: string,
  58101. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58102. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58103. /**
  58104. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58105. */
  58106. static EdgeDetect0Kernel: number[];
  58107. /**
  58108. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58109. */
  58110. static EdgeDetect1Kernel: number[];
  58111. /**
  58112. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58113. */
  58114. static EdgeDetect2Kernel: number[];
  58115. /**
  58116. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58117. */
  58118. static SharpenKernel: number[];
  58119. /**
  58120. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58121. */
  58122. static EmbossKernel: number[];
  58123. /**
  58124. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58125. */
  58126. static GaussianKernel: number[];
  58127. }
  58128. }
  58129. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  58130. import { Nullable } from "babylonjs/types";
  58131. import { Vector2 } from "babylonjs/Maths/math";
  58132. import { Camera } from "babylonjs/Cameras/camera";
  58133. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58134. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  58135. import { Engine } from "babylonjs/Engines/engine";
  58136. import { Scene } from "babylonjs/scene";
  58137. /**
  58138. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58139. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58140. * based on samples that have a large difference in distance than the center pixel.
  58141. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58142. */
  58143. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58144. direction: Vector2;
  58145. /**
  58146. * Creates a new instance CircleOfConfusionPostProcess
  58147. * @param name The name of the effect.
  58148. * @param scene The scene the effect belongs to.
  58149. * @param direction The direction the blur should be applied.
  58150. * @param kernel The size of the kernel used to blur.
  58151. * @param options The required width/height ratio to downsize to before computing the render pass.
  58152. * @param camera The camera to apply the render pass to.
  58153. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58154. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58156. * @param engine The engine which the post process will be applied. (default: current engine)
  58157. * @param reusable If the post process can be reused on the same frame. (default: false)
  58158. * @param textureType Type of textures used when performing the post process. (default: 0)
  58159. * @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)
  58160. */
  58161. 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);
  58162. }
  58163. }
  58164. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  58165. /** @hidden */
  58166. export var depthOfFieldMergePixelShader: {
  58167. name: string;
  58168. shader: string;
  58169. };
  58170. }
  58171. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  58172. import { Nullable } from "babylonjs/types";
  58173. import { Camera } from "babylonjs/Cameras/camera";
  58174. import { Effect } from "babylonjs/Materials/effect";
  58175. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58176. import { Engine } from "babylonjs/Engines/engine";
  58177. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  58178. /**
  58179. * Options to be set when merging outputs from the default pipeline.
  58180. */
  58181. export class DepthOfFieldMergePostProcessOptions {
  58182. /**
  58183. * The original image to merge on top of
  58184. */
  58185. originalFromInput: PostProcess;
  58186. /**
  58187. * Parameters to perform the merge of the depth of field effect
  58188. */
  58189. depthOfField?: {
  58190. circleOfConfusion: PostProcess;
  58191. blurSteps: Array<PostProcess>;
  58192. };
  58193. /**
  58194. * Parameters to perform the merge of bloom effect
  58195. */
  58196. bloom?: {
  58197. blurred: PostProcess;
  58198. weight: number;
  58199. };
  58200. }
  58201. /**
  58202. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58203. */
  58204. export class DepthOfFieldMergePostProcess extends PostProcess {
  58205. private blurSteps;
  58206. /**
  58207. * Creates a new instance of DepthOfFieldMergePostProcess
  58208. * @param name The name of the effect.
  58209. * @param originalFromInput Post process which's input will be used for the merge.
  58210. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58211. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58212. * @param options The required width/height ratio to downsize to before computing the render pass.
  58213. * @param camera The camera to apply the render pass to.
  58214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58215. * @param engine The engine which the post process will be applied. (default: current engine)
  58216. * @param reusable If the post process can be reused on the same frame. (default: false)
  58217. * @param textureType Type of textures used when performing the post process. (default: 0)
  58218. * @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)
  58219. */
  58220. 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);
  58221. /**
  58222. * Updates the effect with the current post process compile time values and recompiles the shader.
  58223. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58224. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58225. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58226. * @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
  58227. * @param onCompiled Called when the shader has been compiled.
  58228. * @param onError Called if there is an error when compiling a shader.
  58229. */
  58230. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58231. }
  58232. }
  58233. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  58234. import { Nullable } from "babylonjs/types";
  58235. import { Camera } from "babylonjs/Cameras/camera";
  58236. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58237. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58238. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58239. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  58240. import { Scene } from "babylonjs/scene";
  58241. /**
  58242. * Specifies the level of max blur that should be applied when using the depth of field effect
  58243. */
  58244. export enum DepthOfFieldEffectBlurLevel {
  58245. /**
  58246. * Subtle blur
  58247. */
  58248. Low = 0,
  58249. /**
  58250. * Medium blur
  58251. */
  58252. Medium = 1,
  58253. /**
  58254. * Large blur
  58255. */
  58256. High = 2
  58257. }
  58258. /**
  58259. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58260. */
  58261. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58262. private _circleOfConfusion;
  58263. /**
  58264. * @hidden Internal, blurs from high to low
  58265. */
  58266. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58267. private _depthOfFieldBlurY;
  58268. private _dofMerge;
  58269. /**
  58270. * @hidden Internal post processes in depth of field effect
  58271. */
  58272. _effects: Array<PostProcess>;
  58273. /**
  58274. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58275. */
  58276. focalLength: number;
  58277. /**
  58278. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58279. */
  58280. fStop: number;
  58281. /**
  58282. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58283. */
  58284. focusDistance: number;
  58285. /**
  58286. * 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.
  58287. */
  58288. lensSize: number;
  58289. /**
  58290. * Creates a new instance DepthOfFieldEffect
  58291. * @param scene The scene the effect belongs to.
  58292. * @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.
  58293. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58294. * @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)
  58295. */
  58296. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58297. /**
  58298. * Get the current class name of the current effet
  58299. * @returns "DepthOfFieldEffect"
  58300. */
  58301. getClassName(): string;
  58302. /**
  58303. * 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.
  58304. */
  58305. depthTexture: RenderTargetTexture;
  58306. /**
  58307. * Disposes each of the internal effects for a given camera.
  58308. * @param camera The camera to dispose the effect on.
  58309. */
  58310. disposeEffects(camera: Camera): void;
  58311. /**
  58312. * @hidden Internal
  58313. */
  58314. _updateEffects(): void;
  58315. /**
  58316. * Internal
  58317. * @returns if all the contained post processes are ready.
  58318. * @hidden
  58319. */
  58320. _isReady(): boolean;
  58321. }
  58322. }
  58323. declare module "babylonjs/Shaders/displayPass.fragment" {
  58324. /** @hidden */
  58325. export var displayPassPixelShader: {
  58326. name: string;
  58327. shader: string;
  58328. };
  58329. }
  58330. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  58331. import { Nullable } from "babylonjs/types";
  58332. import { Camera } from "babylonjs/Cameras/camera";
  58333. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58334. import { Engine } from "babylonjs/Engines/engine";
  58335. import "babylonjs/Shaders/displayPass.fragment";
  58336. /**
  58337. * DisplayPassPostProcess which produces an output the same as it's input
  58338. */
  58339. export class DisplayPassPostProcess extends PostProcess {
  58340. /**
  58341. * Creates the DisplayPassPostProcess
  58342. * @param name The name of the effect.
  58343. * @param options The required width/height ratio to downsize to before computing the render pass.
  58344. * @param camera The camera to apply the render pass to.
  58345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58346. * @param engine The engine which the post process will be applied. (default: current engine)
  58347. * @param reusable If the post process can be reused on the same frame. (default: false)
  58348. */
  58349. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58350. }
  58351. }
  58352. declare module "babylonjs/Shaders/filter.fragment" {
  58353. /** @hidden */
  58354. export var filterPixelShader: {
  58355. name: string;
  58356. shader: string;
  58357. };
  58358. }
  58359. declare module "babylonjs/PostProcesses/filterPostProcess" {
  58360. import { Nullable } from "babylonjs/types";
  58361. import { Matrix } from "babylonjs/Maths/math";
  58362. import { Camera } from "babylonjs/Cameras/camera";
  58363. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58364. import { Engine } from "babylonjs/Engines/engine";
  58365. import "babylonjs/Shaders/filter.fragment";
  58366. /**
  58367. * Applies a kernel filter to the image
  58368. */
  58369. export class FilterPostProcess extends PostProcess {
  58370. /** The matrix to be applied to the image */
  58371. kernelMatrix: Matrix;
  58372. /**
  58373. *
  58374. * @param name The name of the effect.
  58375. * @param kernelMatrix The matrix to be applied to the image
  58376. * @param options The required width/height ratio to downsize to before computing the render pass.
  58377. * @param camera The camera to apply the render pass to.
  58378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58379. * @param engine The engine which the post process will be applied. (default: current engine)
  58380. * @param reusable If the post process can be reused on the same frame. (default: false)
  58381. */
  58382. constructor(name: string,
  58383. /** The matrix to be applied to the image */
  58384. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58385. }
  58386. }
  58387. declare module "babylonjs/Shaders/fxaa.fragment" {
  58388. /** @hidden */
  58389. export var fxaaPixelShader: {
  58390. name: string;
  58391. shader: string;
  58392. };
  58393. }
  58394. declare module "babylonjs/Shaders/fxaa.vertex" {
  58395. /** @hidden */
  58396. export var fxaaVertexShader: {
  58397. name: string;
  58398. shader: string;
  58399. };
  58400. }
  58401. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  58402. import { Nullable } from "babylonjs/types";
  58403. import { Camera } from "babylonjs/Cameras/camera";
  58404. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58405. import { Engine } from "babylonjs/Engines/engine";
  58406. import "babylonjs/Shaders/fxaa.fragment";
  58407. import "babylonjs/Shaders/fxaa.vertex";
  58408. /**
  58409. * Fxaa post process
  58410. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58411. */
  58412. export class FxaaPostProcess extends PostProcess {
  58413. /** @hidden */
  58414. texelWidth: number;
  58415. /** @hidden */
  58416. texelHeight: number;
  58417. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58418. private _getDefines;
  58419. }
  58420. }
  58421. declare module "babylonjs/Shaders/grain.fragment" {
  58422. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58423. /** @hidden */
  58424. export var grainPixelShader: {
  58425. name: string;
  58426. shader: string;
  58427. };
  58428. }
  58429. declare module "babylonjs/PostProcesses/grainPostProcess" {
  58430. import { Nullable } from "babylonjs/types";
  58431. import { Camera } from "babylonjs/Cameras/camera";
  58432. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58433. import { Engine } from "babylonjs/Engines/engine";
  58434. import "babylonjs/Shaders/grain.fragment";
  58435. /**
  58436. * The GrainPostProcess adds noise to the image at mid luminance levels
  58437. */
  58438. export class GrainPostProcess extends PostProcess {
  58439. /**
  58440. * The intensity of the grain added (default: 30)
  58441. */
  58442. intensity: number;
  58443. /**
  58444. * If the grain should be randomized on every frame
  58445. */
  58446. animated: boolean;
  58447. /**
  58448. * Creates a new instance of @see GrainPostProcess
  58449. * @param name The name of the effect.
  58450. * @param options The required width/height ratio to downsize to before computing the render pass.
  58451. * @param camera The camera to apply the render pass to.
  58452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58453. * @param engine The engine which the post process will be applied. (default: current engine)
  58454. * @param reusable If the post process can be reused on the same frame. (default: false)
  58455. * @param textureType Type of textures used when performing the post process. (default: 0)
  58456. * @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)
  58457. */
  58458. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58459. }
  58460. }
  58461. declare module "babylonjs/Shaders/highlights.fragment" {
  58462. /** @hidden */
  58463. export var highlightsPixelShader: {
  58464. name: string;
  58465. shader: string;
  58466. };
  58467. }
  58468. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  58469. import { Nullable } from "babylonjs/types";
  58470. import { Camera } from "babylonjs/Cameras/camera";
  58471. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58472. import { Engine } from "babylonjs/Engines/engine";
  58473. import "babylonjs/Shaders/highlights.fragment";
  58474. /**
  58475. * Extracts highlights from the image
  58476. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58477. */
  58478. export class HighlightsPostProcess extends PostProcess {
  58479. /**
  58480. * Extracts highlights from the image
  58481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58482. * @param name The name of the effect.
  58483. * @param options The required width/height ratio to downsize to before computing the render pass.
  58484. * @param camera The camera to apply the render pass to.
  58485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58486. * @param engine The engine which the post process will be applied. (default: current engine)
  58487. * @param reusable If the post process can be reused on the same frame. (default: false)
  58488. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58489. */
  58490. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58491. }
  58492. }
  58493. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  58494. /** @hidden */
  58495. export var mrtFragmentDeclaration: {
  58496. name: string;
  58497. shader: string;
  58498. };
  58499. }
  58500. declare module "babylonjs/Shaders/geometry.fragment" {
  58501. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  58502. /** @hidden */
  58503. export var geometryPixelShader: {
  58504. name: string;
  58505. shader: string;
  58506. };
  58507. }
  58508. declare module "babylonjs/Shaders/geometry.vertex" {
  58509. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58510. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58511. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58512. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58513. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58514. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58515. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58516. /** @hidden */
  58517. export var geometryVertexShader: {
  58518. name: string;
  58519. shader: string;
  58520. };
  58521. }
  58522. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  58523. import { Matrix } from "babylonjs/Maths/math";
  58524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58525. import { Mesh } from "babylonjs/Meshes/mesh";
  58526. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  58527. import { Effect } from "babylonjs/Materials/effect";
  58528. import { Scene } from "babylonjs/scene";
  58529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58530. import "babylonjs/Shaders/geometry.fragment";
  58531. import "babylonjs/Shaders/geometry.vertex";
  58532. /** @hidden */
  58533. interface ISavedTransformationMatrix {
  58534. world: Matrix;
  58535. viewProjection: Matrix;
  58536. }
  58537. /**
  58538. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58539. */
  58540. export class GeometryBufferRenderer {
  58541. /**
  58542. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58543. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58544. */
  58545. static readonly POSITION_TEXTURE_TYPE: number;
  58546. /**
  58547. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58548. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58549. */
  58550. static readonly VELOCITY_TEXTURE_TYPE: number;
  58551. /**
  58552. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58553. * in order to compute objects velocities when enableVelocity is set to "true"
  58554. * @hidden
  58555. */
  58556. _previousTransformationMatrices: {
  58557. [index: number]: ISavedTransformationMatrix;
  58558. };
  58559. /**
  58560. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58561. * in order to compute objects velocities when enableVelocity is set to "true"
  58562. * @hidden
  58563. */
  58564. _previousBonesTransformationMatrices: {
  58565. [index: number]: Float32Array;
  58566. };
  58567. /**
  58568. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58569. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58570. */
  58571. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58572. private _scene;
  58573. private _multiRenderTarget;
  58574. private _ratio;
  58575. private _enablePosition;
  58576. private _enableVelocity;
  58577. private _positionIndex;
  58578. private _velocityIndex;
  58579. protected _effect: Effect;
  58580. protected _cachedDefines: string;
  58581. /**
  58582. * Set the render list (meshes to be rendered) used in the G buffer.
  58583. */
  58584. renderList: Mesh[];
  58585. /**
  58586. * Gets wether or not G buffer are supported by the running hardware.
  58587. * This requires draw buffer supports
  58588. */
  58589. readonly isSupported: boolean;
  58590. /**
  58591. * Returns the index of the given texture type in the G-Buffer textures array
  58592. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58593. * @returns the index of the given texture type in the G-Buffer textures array
  58594. */
  58595. getTextureIndex(textureType: number): number;
  58596. /**
  58597. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58598. */
  58599. /**
  58600. * Sets whether or not objects positions are enabled for the G buffer.
  58601. */
  58602. enablePosition: boolean;
  58603. /**
  58604. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58605. */
  58606. /**
  58607. * Sets wether or not objects velocities are enabled for the G buffer.
  58608. */
  58609. enableVelocity: boolean;
  58610. /**
  58611. * Gets the scene associated with the buffer.
  58612. */
  58613. readonly scene: Scene;
  58614. /**
  58615. * Gets the ratio used by the buffer during its creation.
  58616. * How big is the buffer related to the main canvas.
  58617. */
  58618. readonly ratio: number;
  58619. /** @hidden */
  58620. static _SceneComponentInitialization: (scene: Scene) => void;
  58621. /**
  58622. * Creates a new G Buffer for the scene
  58623. * @param scene The scene the buffer belongs to
  58624. * @param ratio How big is the buffer related to the main canvas.
  58625. */
  58626. constructor(scene: Scene, ratio?: number);
  58627. /**
  58628. * Checks wether everything is ready to render a submesh to the G buffer.
  58629. * @param subMesh the submesh to check readiness for
  58630. * @param useInstances is the mesh drawn using instance or not
  58631. * @returns true if ready otherwise false
  58632. */
  58633. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58634. /**
  58635. * Gets the current underlying G Buffer.
  58636. * @returns the buffer
  58637. */
  58638. getGBuffer(): MultiRenderTarget;
  58639. /**
  58640. * Gets the number of samples used to render the buffer (anti aliasing).
  58641. */
  58642. /**
  58643. * Sets the number of samples used to render the buffer (anti aliasing).
  58644. */
  58645. samples: number;
  58646. /**
  58647. * Disposes the renderer and frees up associated resources.
  58648. */
  58649. dispose(): void;
  58650. protected _createRenderTargets(): void;
  58651. private _copyBonesTransformationMatrices;
  58652. }
  58653. }
  58654. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58655. import { Nullable } from "babylonjs/types";
  58656. import { Scene } from "babylonjs/scene";
  58657. import { ISceneComponent } from "babylonjs/sceneComponent";
  58658. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58659. module "babylonjs/scene" {
  58660. interface Scene {
  58661. /** @hidden (Backing field) */
  58662. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58663. /**
  58664. * Gets or Sets the current geometry buffer associated to the scene.
  58665. */
  58666. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58667. /**
  58668. * Enables a GeometryBufferRender and associates it with the scene
  58669. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58670. * @returns the GeometryBufferRenderer
  58671. */
  58672. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58673. /**
  58674. * Disables the GeometryBufferRender associated with the scene
  58675. */
  58676. disableGeometryBufferRenderer(): void;
  58677. }
  58678. }
  58679. /**
  58680. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58681. * in several rendering techniques.
  58682. */
  58683. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58684. /**
  58685. * The component name helpful to identify the component in the list of scene components.
  58686. */
  58687. readonly name: string;
  58688. /**
  58689. * The scene the component belongs to.
  58690. */
  58691. scene: Scene;
  58692. /**
  58693. * Creates a new instance of the component for the given scene
  58694. * @param scene Defines the scene to register the component in
  58695. */
  58696. constructor(scene: Scene);
  58697. /**
  58698. * Registers the component in a given scene
  58699. */
  58700. register(): void;
  58701. /**
  58702. * Rebuilds the elements related to this component in case of
  58703. * context lost for instance.
  58704. */
  58705. rebuild(): void;
  58706. /**
  58707. * Disposes the component and the associated ressources
  58708. */
  58709. dispose(): void;
  58710. private _gatherRenderTargets;
  58711. }
  58712. }
  58713. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58714. /** @hidden */
  58715. export var motionBlurPixelShader: {
  58716. name: string;
  58717. shader: string;
  58718. };
  58719. }
  58720. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58721. import { Nullable } from "babylonjs/types";
  58722. import { Camera } from "babylonjs/Cameras/camera";
  58723. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58724. import { Scene } from "babylonjs/scene";
  58725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58726. import "babylonjs/Animations/animatable";
  58727. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58728. import "babylonjs/Shaders/motionBlur.fragment";
  58729. import { Engine } from "babylonjs/Engines/engine";
  58730. /**
  58731. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58732. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58733. * As an example, all you have to do is to create the post-process:
  58734. * var mb = new BABYLON.MotionBlurPostProcess(
  58735. * 'mb', // The name of the effect.
  58736. * scene, // The scene containing the objects to blur according to their velocity.
  58737. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58738. * camera // The camera to apply the render pass to.
  58739. * );
  58740. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58741. */
  58742. export class MotionBlurPostProcess extends PostProcess {
  58743. /**
  58744. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58745. */
  58746. motionStrength: number;
  58747. /**
  58748. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58749. */
  58750. /**
  58751. * Sets the number of iterations to be used for motion blur quality
  58752. */
  58753. motionBlurSamples: number;
  58754. private _motionBlurSamples;
  58755. private _geometryBufferRenderer;
  58756. /**
  58757. * Creates a new instance MotionBlurPostProcess
  58758. * @param name The name of the effect.
  58759. * @param scene The scene containing the objects to blur according to their velocity.
  58760. * @param options The required width/height ratio to downsize to before computing the render pass.
  58761. * @param camera The camera to apply the render pass to.
  58762. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58763. * @param engine The engine which the post process will be applied. (default: current engine)
  58764. * @param reusable If the post process can be reused on the same frame. (default: false)
  58765. * @param textureType Type of textures used when performing the post process. (default: 0)
  58766. * @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)
  58767. */
  58768. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58769. /**
  58770. * Excludes the given skinned mesh from computing bones velocities.
  58771. * 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.
  58772. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58773. */
  58774. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58775. /**
  58776. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58777. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58778. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58779. */
  58780. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58781. /**
  58782. * Disposes the post process.
  58783. * @param camera The camera to dispose the post process on.
  58784. */
  58785. dispose(camera?: Camera): void;
  58786. }
  58787. }
  58788. declare module "babylonjs/Shaders/refraction.fragment" {
  58789. /** @hidden */
  58790. export var refractionPixelShader: {
  58791. name: string;
  58792. shader: string;
  58793. };
  58794. }
  58795. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58796. import { Color3 } from "babylonjs/Maths/math";
  58797. import { Camera } from "babylonjs/Cameras/camera";
  58798. import { Texture } from "babylonjs/Materials/Textures/texture";
  58799. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58800. import { Engine } from "babylonjs/Engines/engine";
  58801. import "babylonjs/Shaders/refraction.fragment";
  58802. /**
  58803. * Post process which applies a refractin texture
  58804. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58805. */
  58806. export class RefractionPostProcess extends PostProcess {
  58807. /** the base color of the refraction (used to taint the rendering) */
  58808. color: Color3;
  58809. /** simulated refraction depth */
  58810. depth: number;
  58811. /** the coefficient of the base color (0 to remove base color tainting) */
  58812. colorLevel: number;
  58813. private _refTexture;
  58814. private _ownRefractionTexture;
  58815. /**
  58816. * Gets or sets the refraction texture
  58817. * Please note that you are responsible for disposing the texture if you set it manually
  58818. */
  58819. refractionTexture: Texture;
  58820. /**
  58821. * Initializes the RefractionPostProcess
  58822. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58823. * @param name The name of the effect.
  58824. * @param refractionTextureUrl Url of the refraction texture to use
  58825. * @param color the base color of the refraction (used to taint the rendering)
  58826. * @param depth simulated refraction depth
  58827. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58828. * @param camera The camera to apply the render pass to.
  58829. * @param options The required width/height ratio to downsize to before computing the render pass.
  58830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58831. * @param engine The engine which the post process will be applied. (default: current engine)
  58832. * @param reusable If the post process can be reused on the same frame. (default: false)
  58833. */
  58834. constructor(name: string, refractionTextureUrl: string,
  58835. /** the base color of the refraction (used to taint the rendering) */
  58836. color: Color3,
  58837. /** simulated refraction depth */
  58838. depth: number,
  58839. /** the coefficient of the base color (0 to remove base color tainting) */
  58840. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58841. /**
  58842. * Disposes of the post process
  58843. * @param camera Camera to dispose post process on
  58844. */
  58845. dispose(camera: Camera): void;
  58846. }
  58847. }
  58848. declare module "babylonjs/Shaders/sharpen.fragment" {
  58849. /** @hidden */
  58850. export var sharpenPixelShader: {
  58851. name: string;
  58852. shader: string;
  58853. };
  58854. }
  58855. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  58856. import { Nullable } from "babylonjs/types";
  58857. import { Camera } from "babylonjs/Cameras/camera";
  58858. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58859. import "babylonjs/Shaders/sharpen.fragment";
  58860. import { Engine } from "babylonjs/Engines/engine";
  58861. /**
  58862. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58863. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58864. */
  58865. export class SharpenPostProcess extends PostProcess {
  58866. /**
  58867. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58868. */
  58869. colorAmount: number;
  58870. /**
  58871. * How much sharpness should be applied (default: 0.3)
  58872. */
  58873. edgeAmount: number;
  58874. /**
  58875. * Creates a new instance ConvolutionPostProcess
  58876. * @param name The name of the effect.
  58877. * @param options The required width/height ratio to downsize to before computing the render pass.
  58878. * @param camera The camera to apply the render pass to.
  58879. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58880. * @param engine The engine which the post process will be applied. (default: current engine)
  58881. * @param reusable If the post process can be reused on the same frame. (default: false)
  58882. * @param textureType Type of textures used when performing the post process. (default: 0)
  58883. * @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)
  58884. */
  58885. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58886. }
  58887. }
  58888. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58889. import { Nullable } from "babylonjs/types";
  58890. import { Camera } from "babylonjs/Cameras/camera";
  58891. import { Engine } from "babylonjs/Engines/engine";
  58892. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58893. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58894. /**
  58895. * PostProcessRenderPipeline
  58896. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58897. */
  58898. export class PostProcessRenderPipeline {
  58899. private engine;
  58900. private _renderEffects;
  58901. private _renderEffectsForIsolatedPass;
  58902. /**
  58903. * List of inspectable custom properties (used by the Inspector)
  58904. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58905. */
  58906. inspectableCustomProperties: IInspectable[];
  58907. /**
  58908. * @hidden
  58909. */
  58910. protected _cameras: Camera[];
  58911. /** @hidden */
  58912. _name: string;
  58913. /**
  58914. * Gets pipeline name
  58915. */
  58916. readonly name: string;
  58917. /**
  58918. * Initializes a PostProcessRenderPipeline
  58919. * @param engine engine to add the pipeline to
  58920. * @param name name of the pipeline
  58921. */
  58922. constructor(engine: Engine, name: string);
  58923. /**
  58924. * Gets the class name
  58925. * @returns "PostProcessRenderPipeline"
  58926. */
  58927. getClassName(): string;
  58928. /**
  58929. * If all the render effects in the pipeline are supported
  58930. */
  58931. readonly isSupported: boolean;
  58932. /**
  58933. * Adds an effect to the pipeline
  58934. * @param renderEffect the effect to add
  58935. */
  58936. addEffect(renderEffect: PostProcessRenderEffect): void;
  58937. /** @hidden */
  58938. _rebuild(): void;
  58939. /** @hidden */
  58940. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58941. /** @hidden */
  58942. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58943. /** @hidden */
  58944. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58945. /** @hidden */
  58946. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58947. /** @hidden */
  58948. _attachCameras(cameras: Camera, unique: boolean): void;
  58949. /** @hidden */
  58950. _attachCameras(cameras: Camera[], unique: boolean): void;
  58951. /** @hidden */
  58952. _detachCameras(cameras: Camera): void;
  58953. /** @hidden */
  58954. _detachCameras(cameras: Nullable<Camera[]>): void;
  58955. /** @hidden */
  58956. _update(): void;
  58957. /** @hidden */
  58958. _reset(): void;
  58959. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58960. /**
  58961. * Disposes of the pipeline
  58962. */
  58963. dispose(): void;
  58964. }
  58965. }
  58966. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  58967. import { Camera } from "babylonjs/Cameras/camera";
  58968. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58969. /**
  58970. * PostProcessRenderPipelineManager class
  58971. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58972. */
  58973. export class PostProcessRenderPipelineManager {
  58974. private _renderPipelines;
  58975. /**
  58976. * Initializes a PostProcessRenderPipelineManager
  58977. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58978. */
  58979. constructor();
  58980. /**
  58981. * Gets the list of supported render pipelines
  58982. */
  58983. readonly supportedPipelines: PostProcessRenderPipeline[];
  58984. /**
  58985. * Adds a pipeline to the manager
  58986. * @param renderPipeline The pipeline to add
  58987. */
  58988. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58989. /**
  58990. * Attaches a camera to the pipeline
  58991. * @param renderPipelineName The name of the pipeline to attach to
  58992. * @param cameras the camera to attach
  58993. * @param unique if the camera can be attached multiple times to the pipeline
  58994. */
  58995. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58996. /**
  58997. * Detaches a camera from the pipeline
  58998. * @param renderPipelineName The name of the pipeline to detach from
  58999. * @param cameras the camera to detach
  59000. */
  59001. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59002. /**
  59003. * Enables an effect by name on a pipeline
  59004. * @param renderPipelineName the name of the pipeline to enable the effect in
  59005. * @param renderEffectName the name of the effect to enable
  59006. * @param cameras the cameras that the effect should be enabled on
  59007. */
  59008. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59009. /**
  59010. * Disables an effect by name on a pipeline
  59011. * @param renderPipelineName the name of the pipeline to disable the effect in
  59012. * @param renderEffectName the name of the effect to disable
  59013. * @param cameras the cameras that the effect should be disabled on
  59014. */
  59015. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59016. /**
  59017. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59018. */
  59019. update(): void;
  59020. /** @hidden */
  59021. _rebuild(): void;
  59022. /**
  59023. * Disposes of the manager and pipelines
  59024. */
  59025. dispose(): void;
  59026. }
  59027. }
  59028. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  59029. import { ISceneComponent } from "babylonjs/sceneComponent";
  59030. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59031. import { Scene } from "babylonjs/scene";
  59032. module "babylonjs/scene" {
  59033. interface Scene {
  59034. /** @hidden (Backing field) */
  59035. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59036. /**
  59037. * Gets the postprocess render pipeline manager
  59038. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59039. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59040. */
  59041. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59042. }
  59043. }
  59044. /**
  59045. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59046. */
  59047. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59048. /**
  59049. * The component name helpfull to identify the component in the list of scene components.
  59050. */
  59051. readonly name: string;
  59052. /**
  59053. * The scene the component belongs to.
  59054. */
  59055. scene: Scene;
  59056. /**
  59057. * Creates a new instance of the component for the given scene
  59058. * @param scene Defines the scene to register the component in
  59059. */
  59060. constructor(scene: Scene);
  59061. /**
  59062. * Registers the component in a given scene
  59063. */
  59064. register(): void;
  59065. /**
  59066. * Rebuilds the elements related to this component in case of
  59067. * context lost for instance.
  59068. */
  59069. rebuild(): void;
  59070. /**
  59071. * Disposes the component and the associated ressources
  59072. */
  59073. dispose(): void;
  59074. private _gatherRenderTargets;
  59075. }
  59076. }
  59077. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  59078. import { Nullable } from "babylonjs/types";
  59079. import { IAnimatable } from "babylonjs/Misc/tools";
  59080. import { Camera } from "babylonjs/Cameras/camera";
  59081. import { IDisposable } from "babylonjs/scene";
  59082. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  59083. import { Scene } from "babylonjs/scene";
  59084. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  59085. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59086. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59087. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  59088. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59089. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59090. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  59091. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59092. import { Animation } from "babylonjs/Animations/animation";
  59093. /**
  59094. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59095. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59096. */
  59097. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59098. private _scene;
  59099. private _camerasToBeAttached;
  59100. /**
  59101. * ID of the sharpen post process,
  59102. */
  59103. private readonly SharpenPostProcessId;
  59104. /**
  59105. * @ignore
  59106. * ID of the image processing post process;
  59107. */
  59108. readonly ImageProcessingPostProcessId: string;
  59109. /**
  59110. * @ignore
  59111. * ID of the Fast Approximate Anti-Aliasing post process;
  59112. */
  59113. readonly FxaaPostProcessId: string;
  59114. /**
  59115. * ID of the chromatic aberration post process,
  59116. */
  59117. private readonly ChromaticAberrationPostProcessId;
  59118. /**
  59119. * ID of the grain post process
  59120. */
  59121. private readonly GrainPostProcessId;
  59122. /**
  59123. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59124. */
  59125. sharpen: SharpenPostProcess;
  59126. private _sharpenEffect;
  59127. private bloom;
  59128. /**
  59129. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59130. */
  59131. depthOfField: DepthOfFieldEffect;
  59132. /**
  59133. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59134. */
  59135. fxaa: FxaaPostProcess;
  59136. /**
  59137. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59138. */
  59139. imageProcessing: ImageProcessingPostProcess;
  59140. /**
  59141. * Chromatic aberration post process which will shift rgb colors in the image
  59142. */
  59143. chromaticAberration: ChromaticAberrationPostProcess;
  59144. private _chromaticAberrationEffect;
  59145. /**
  59146. * Grain post process which add noise to the image
  59147. */
  59148. grain: GrainPostProcess;
  59149. private _grainEffect;
  59150. /**
  59151. * Glow post process which adds a glow to emissive areas of the image
  59152. */
  59153. private _glowLayer;
  59154. /**
  59155. * Animations which can be used to tweak settings over a period of time
  59156. */
  59157. animations: Animation[];
  59158. private _imageProcessingConfigurationObserver;
  59159. private _sharpenEnabled;
  59160. private _bloomEnabled;
  59161. private _depthOfFieldEnabled;
  59162. private _depthOfFieldBlurLevel;
  59163. private _fxaaEnabled;
  59164. private _imageProcessingEnabled;
  59165. private _defaultPipelineTextureType;
  59166. private _bloomScale;
  59167. private _chromaticAberrationEnabled;
  59168. private _grainEnabled;
  59169. private _buildAllowed;
  59170. /**
  59171. * Gets active scene
  59172. */
  59173. readonly scene: Scene;
  59174. /**
  59175. * Enable or disable the sharpen process from the pipeline
  59176. */
  59177. sharpenEnabled: boolean;
  59178. private _resizeObserver;
  59179. private _hardwareScaleLevel;
  59180. private _bloomKernel;
  59181. /**
  59182. * Specifies the size of the bloom blur kernel, relative to the final output size
  59183. */
  59184. bloomKernel: number;
  59185. /**
  59186. * Specifies the weight of the bloom in the final rendering
  59187. */
  59188. private _bloomWeight;
  59189. /**
  59190. * Specifies the luma threshold for the area that will be blurred by the bloom
  59191. */
  59192. private _bloomThreshold;
  59193. private _hdr;
  59194. /**
  59195. * The strength of the bloom.
  59196. */
  59197. bloomWeight: number;
  59198. /**
  59199. * The strength of the bloom.
  59200. */
  59201. bloomThreshold: number;
  59202. /**
  59203. * The scale of the bloom, lower value will provide better performance.
  59204. */
  59205. bloomScale: number;
  59206. /**
  59207. * Enable or disable the bloom from the pipeline
  59208. */
  59209. bloomEnabled: boolean;
  59210. private _rebuildBloom;
  59211. /**
  59212. * If the depth of field is enabled.
  59213. */
  59214. depthOfFieldEnabled: boolean;
  59215. /**
  59216. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59217. */
  59218. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59219. /**
  59220. * If the anti aliasing is enabled.
  59221. */
  59222. fxaaEnabled: boolean;
  59223. private _samples;
  59224. /**
  59225. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59226. */
  59227. samples: number;
  59228. /**
  59229. * If image processing is enabled.
  59230. */
  59231. imageProcessingEnabled: boolean;
  59232. /**
  59233. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59234. */
  59235. glowLayerEnabled: boolean;
  59236. /**
  59237. * Gets the glow layer (or null if not defined)
  59238. */
  59239. readonly glowLayer: Nullable<GlowLayer>;
  59240. /**
  59241. * Enable or disable the chromaticAberration process from the pipeline
  59242. */
  59243. chromaticAberrationEnabled: boolean;
  59244. /**
  59245. * Enable or disable the grain process from the pipeline
  59246. */
  59247. grainEnabled: boolean;
  59248. /**
  59249. * @constructor
  59250. * @param name - The rendering pipeline name (default: "")
  59251. * @param hdr - If high dynamic range textures should be used (default: true)
  59252. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59253. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59254. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59255. */
  59256. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59257. /**
  59258. * Get the class name
  59259. * @returns "DefaultRenderingPipeline"
  59260. */
  59261. getClassName(): string;
  59262. /**
  59263. * Force the compilation of the entire pipeline.
  59264. */
  59265. prepare(): void;
  59266. private _hasCleared;
  59267. private _prevPostProcess;
  59268. private _prevPrevPostProcess;
  59269. private _setAutoClearAndTextureSharing;
  59270. private _depthOfFieldSceneObserver;
  59271. private _buildPipeline;
  59272. private _disposePostProcesses;
  59273. /**
  59274. * Adds a camera to the pipeline
  59275. * @param camera the camera to be added
  59276. */
  59277. addCamera(camera: Camera): void;
  59278. /**
  59279. * Removes a camera from the pipeline
  59280. * @param camera the camera to remove
  59281. */
  59282. removeCamera(camera: Camera): void;
  59283. /**
  59284. * Dispose of the pipeline and stop all post processes
  59285. */
  59286. dispose(): void;
  59287. /**
  59288. * Serialize the rendering pipeline (Used when exporting)
  59289. * @returns the serialized object
  59290. */
  59291. serialize(): any;
  59292. /**
  59293. * Parse the serialized pipeline
  59294. * @param source Source pipeline.
  59295. * @param scene The scene to load the pipeline to.
  59296. * @param rootUrl The URL of the serialized pipeline.
  59297. * @returns An instantiated pipeline from the serialized object.
  59298. */
  59299. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59300. }
  59301. }
  59302. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  59303. /** @hidden */
  59304. export var lensHighlightsPixelShader: {
  59305. name: string;
  59306. shader: string;
  59307. };
  59308. }
  59309. declare module "babylonjs/Shaders/depthOfField.fragment" {
  59310. /** @hidden */
  59311. export var depthOfFieldPixelShader: {
  59312. name: string;
  59313. shader: string;
  59314. };
  59315. }
  59316. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  59317. import { Camera } from "babylonjs/Cameras/camera";
  59318. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59319. import { Scene } from "babylonjs/scene";
  59320. import "babylonjs/Shaders/chromaticAberration.fragment";
  59321. import "babylonjs/Shaders/lensHighlights.fragment";
  59322. import "babylonjs/Shaders/depthOfField.fragment";
  59323. /**
  59324. * BABYLON.JS Chromatic Aberration GLSL Shader
  59325. * Author: Olivier Guyot
  59326. * Separates very slightly R, G and B colors on the edges of the screen
  59327. * Inspired by Francois Tarlier & Martins Upitis
  59328. */
  59329. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59330. /**
  59331. * @ignore
  59332. * The chromatic aberration PostProcess id in the pipeline
  59333. */
  59334. LensChromaticAberrationEffect: string;
  59335. /**
  59336. * @ignore
  59337. * The highlights enhancing PostProcess id in the pipeline
  59338. */
  59339. HighlightsEnhancingEffect: string;
  59340. /**
  59341. * @ignore
  59342. * The depth-of-field PostProcess id in the pipeline
  59343. */
  59344. LensDepthOfFieldEffect: string;
  59345. private _scene;
  59346. private _depthTexture;
  59347. private _grainTexture;
  59348. private _chromaticAberrationPostProcess;
  59349. private _highlightsPostProcess;
  59350. private _depthOfFieldPostProcess;
  59351. private _edgeBlur;
  59352. private _grainAmount;
  59353. private _chromaticAberration;
  59354. private _distortion;
  59355. private _highlightsGain;
  59356. private _highlightsThreshold;
  59357. private _dofDistance;
  59358. private _dofAperture;
  59359. private _dofDarken;
  59360. private _dofPentagon;
  59361. private _blurNoise;
  59362. /**
  59363. * @constructor
  59364. *
  59365. * Effect parameters are as follow:
  59366. * {
  59367. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59368. * edge_blur: number; // from 0 to x (1 for realism)
  59369. * distortion: number; // from 0 to x (1 for realism)
  59370. * grain_amount: number; // from 0 to 1
  59371. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59372. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59373. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59374. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59375. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59376. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59377. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59378. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59379. * }
  59380. * Note: if an effect parameter is unset, effect is disabled
  59381. *
  59382. * @param name The rendering pipeline name
  59383. * @param parameters - An object containing all parameters (see above)
  59384. * @param scene The scene linked to this pipeline
  59385. * @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)
  59386. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59387. */
  59388. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59389. /**
  59390. * Get the class name
  59391. * @returns "LensRenderingPipeline"
  59392. */
  59393. getClassName(): string;
  59394. /**
  59395. * Gets associated scene
  59396. */
  59397. readonly scene: Scene;
  59398. /**
  59399. * Gets or sets the edge blur
  59400. */
  59401. edgeBlur: number;
  59402. /**
  59403. * Gets or sets the grain amount
  59404. */
  59405. grainAmount: number;
  59406. /**
  59407. * Gets or sets the chromatic aberration amount
  59408. */
  59409. chromaticAberration: number;
  59410. /**
  59411. * Gets or sets the depth of field aperture
  59412. */
  59413. dofAperture: number;
  59414. /**
  59415. * Gets or sets the edge distortion
  59416. */
  59417. edgeDistortion: number;
  59418. /**
  59419. * Gets or sets the depth of field distortion
  59420. */
  59421. dofDistortion: number;
  59422. /**
  59423. * Gets or sets the darken out of focus amount
  59424. */
  59425. darkenOutOfFocus: number;
  59426. /**
  59427. * Gets or sets a boolean indicating if blur noise is enabled
  59428. */
  59429. blurNoise: boolean;
  59430. /**
  59431. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59432. */
  59433. pentagonBokeh: boolean;
  59434. /**
  59435. * Gets or sets the highlight grain amount
  59436. */
  59437. highlightsGain: number;
  59438. /**
  59439. * Gets or sets the highlight threshold
  59440. */
  59441. highlightsThreshold: number;
  59442. /**
  59443. * Sets the amount of blur at the edges
  59444. * @param amount blur amount
  59445. */
  59446. setEdgeBlur(amount: number): void;
  59447. /**
  59448. * Sets edge blur to 0
  59449. */
  59450. disableEdgeBlur(): void;
  59451. /**
  59452. * Sets the amout of grain
  59453. * @param amount Amount of grain
  59454. */
  59455. setGrainAmount(amount: number): void;
  59456. /**
  59457. * Set grain amount to 0
  59458. */
  59459. disableGrain(): void;
  59460. /**
  59461. * Sets the chromatic aberration amount
  59462. * @param amount amount of chromatic aberration
  59463. */
  59464. setChromaticAberration(amount: number): void;
  59465. /**
  59466. * Sets chromatic aberration amount to 0
  59467. */
  59468. disableChromaticAberration(): void;
  59469. /**
  59470. * Sets the EdgeDistortion amount
  59471. * @param amount amount of EdgeDistortion
  59472. */
  59473. setEdgeDistortion(amount: number): void;
  59474. /**
  59475. * Sets edge distortion to 0
  59476. */
  59477. disableEdgeDistortion(): void;
  59478. /**
  59479. * Sets the FocusDistance amount
  59480. * @param amount amount of FocusDistance
  59481. */
  59482. setFocusDistance(amount: number): void;
  59483. /**
  59484. * Disables depth of field
  59485. */
  59486. disableDepthOfField(): void;
  59487. /**
  59488. * Sets the Aperture amount
  59489. * @param amount amount of Aperture
  59490. */
  59491. setAperture(amount: number): void;
  59492. /**
  59493. * Sets the DarkenOutOfFocus amount
  59494. * @param amount amount of DarkenOutOfFocus
  59495. */
  59496. setDarkenOutOfFocus(amount: number): void;
  59497. private _pentagonBokehIsEnabled;
  59498. /**
  59499. * Creates a pentagon bokeh effect
  59500. */
  59501. enablePentagonBokeh(): void;
  59502. /**
  59503. * Disables the pentagon bokeh effect
  59504. */
  59505. disablePentagonBokeh(): void;
  59506. /**
  59507. * Enables noise blur
  59508. */
  59509. enableNoiseBlur(): void;
  59510. /**
  59511. * Disables noise blur
  59512. */
  59513. disableNoiseBlur(): void;
  59514. /**
  59515. * Sets the HighlightsGain amount
  59516. * @param amount amount of HighlightsGain
  59517. */
  59518. setHighlightsGain(amount: number): void;
  59519. /**
  59520. * Sets the HighlightsThreshold amount
  59521. * @param amount amount of HighlightsThreshold
  59522. */
  59523. setHighlightsThreshold(amount: number): void;
  59524. /**
  59525. * Disables highlights
  59526. */
  59527. disableHighlights(): void;
  59528. /**
  59529. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59530. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59531. */
  59532. dispose(disableDepthRender?: boolean): void;
  59533. private _createChromaticAberrationPostProcess;
  59534. private _createHighlightsPostProcess;
  59535. private _createDepthOfFieldPostProcess;
  59536. private _createGrainTexture;
  59537. }
  59538. }
  59539. declare module "babylonjs/Shaders/ssao2.fragment" {
  59540. /** @hidden */
  59541. export var ssao2PixelShader: {
  59542. name: string;
  59543. shader: string;
  59544. };
  59545. }
  59546. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  59547. /** @hidden */
  59548. export var ssaoCombinePixelShader: {
  59549. name: string;
  59550. shader: string;
  59551. };
  59552. }
  59553. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  59554. import { Camera } from "babylonjs/Cameras/camera";
  59555. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59556. import { Scene } from "babylonjs/scene";
  59557. import "babylonjs/Shaders/ssao2.fragment";
  59558. import "babylonjs/Shaders/ssaoCombine.fragment";
  59559. /**
  59560. * Render pipeline to produce ssao effect
  59561. */
  59562. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59563. /**
  59564. * @ignore
  59565. * The PassPostProcess id in the pipeline that contains the original scene color
  59566. */
  59567. SSAOOriginalSceneColorEffect: string;
  59568. /**
  59569. * @ignore
  59570. * The SSAO PostProcess id in the pipeline
  59571. */
  59572. SSAORenderEffect: string;
  59573. /**
  59574. * @ignore
  59575. * The horizontal blur PostProcess id in the pipeline
  59576. */
  59577. SSAOBlurHRenderEffect: string;
  59578. /**
  59579. * @ignore
  59580. * The vertical blur PostProcess id in the pipeline
  59581. */
  59582. SSAOBlurVRenderEffect: string;
  59583. /**
  59584. * @ignore
  59585. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59586. */
  59587. SSAOCombineRenderEffect: string;
  59588. /**
  59589. * The output strength of the SSAO post-process. Default value is 1.0.
  59590. */
  59591. totalStrength: number;
  59592. /**
  59593. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59594. */
  59595. maxZ: number;
  59596. /**
  59597. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59598. */
  59599. minZAspect: number;
  59600. private _samples;
  59601. /**
  59602. * Number of samples used for the SSAO calculations. Default value is 8
  59603. */
  59604. samples: number;
  59605. private _textureSamples;
  59606. /**
  59607. * Number of samples to use for antialiasing
  59608. */
  59609. textureSamples: number;
  59610. /**
  59611. * Ratio object used for SSAO ratio and blur ratio
  59612. */
  59613. private _ratio;
  59614. /**
  59615. * Dynamically generated sphere sampler.
  59616. */
  59617. private _sampleSphere;
  59618. /**
  59619. * Blur filter offsets
  59620. */
  59621. private _samplerOffsets;
  59622. private _expensiveBlur;
  59623. /**
  59624. * If bilateral blur should be used
  59625. */
  59626. expensiveBlur: boolean;
  59627. /**
  59628. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59629. */
  59630. radius: number;
  59631. /**
  59632. * The base color of the SSAO post-process
  59633. * The final result is "base + ssao" between [0, 1]
  59634. */
  59635. base: number;
  59636. /**
  59637. * Support test.
  59638. */
  59639. static readonly IsSupported: boolean;
  59640. private _scene;
  59641. private _depthTexture;
  59642. private _normalTexture;
  59643. private _randomTexture;
  59644. private _originalColorPostProcess;
  59645. private _ssaoPostProcess;
  59646. private _blurHPostProcess;
  59647. private _blurVPostProcess;
  59648. private _ssaoCombinePostProcess;
  59649. private _firstUpdate;
  59650. /**
  59651. * Gets active scene
  59652. */
  59653. readonly scene: Scene;
  59654. /**
  59655. * @constructor
  59656. * @param name The rendering pipeline name
  59657. * @param scene The scene linked to this pipeline
  59658. * @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 }
  59659. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59660. */
  59661. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59662. /**
  59663. * Get the class name
  59664. * @returns "SSAO2RenderingPipeline"
  59665. */
  59666. getClassName(): string;
  59667. /**
  59668. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59669. */
  59670. dispose(disableGeometryBufferRenderer?: boolean): void;
  59671. private _createBlurPostProcess;
  59672. /** @hidden */
  59673. _rebuild(): void;
  59674. private _bits;
  59675. private _radicalInverse_VdC;
  59676. private _hammersley;
  59677. private _hemisphereSample_uniform;
  59678. private _generateHemisphere;
  59679. private _createSSAOPostProcess;
  59680. private _createSSAOCombinePostProcess;
  59681. private _createRandomTexture;
  59682. /**
  59683. * Serialize the rendering pipeline (Used when exporting)
  59684. * @returns the serialized object
  59685. */
  59686. serialize(): any;
  59687. /**
  59688. * Parse the serialized pipeline
  59689. * @param source Source pipeline.
  59690. * @param scene The scene to load the pipeline to.
  59691. * @param rootUrl The URL of the serialized pipeline.
  59692. * @returns An instantiated pipeline from the serialized object.
  59693. */
  59694. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59695. }
  59696. }
  59697. declare module "babylonjs/Shaders/ssao.fragment" {
  59698. /** @hidden */
  59699. export var ssaoPixelShader: {
  59700. name: string;
  59701. shader: string;
  59702. };
  59703. }
  59704. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59705. import { Camera } from "babylonjs/Cameras/camera";
  59706. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59707. import { Scene } from "babylonjs/scene";
  59708. import "babylonjs/Shaders/ssao.fragment";
  59709. import "babylonjs/Shaders/ssaoCombine.fragment";
  59710. /**
  59711. * Render pipeline to produce ssao effect
  59712. */
  59713. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59714. /**
  59715. * @ignore
  59716. * The PassPostProcess id in the pipeline that contains the original scene color
  59717. */
  59718. SSAOOriginalSceneColorEffect: string;
  59719. /**
  59720. * @ignore
  59721. * The SSAO PostProcess id in the pipeline
  59722. */
  59723. SSAORenderEffect: string;
  59724. /**
  59725. * @ignore
  59726. * The horizontal blur PostProcess id in the pipeline
  59727. */
  59728. SSAOBlurHRenderEffect: string;
  59729. /**
  59730. * @ignore
  59731. * The vertical blur PostProcess id in the pipeline
  59732. */
  59733. SSAOBlurVRenderEffect: string;
  59734. /**
  59735. * @ignore
  59736. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59737. */
  59738. SSAOCombineRenderEffect: string;
  59739. /**
  59740. * The output strength of the SSAO post-process. Default value is 1.0.
  59741. */
  59742. totalStrength: number;
  59743. /**
  59744. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59745. */
  59746. radius: number;
  59747. /**
  59748. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59749. * Must not be equal to fallOff and superior to fallOff.
  59750. * Default value is 0.0075
  59751. */
  59752. area: number;
  59753. /**
  59754. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59755. * Must not be equal to area and inferior to area.
  59756. * Default value is 0.000001
  59757. */
  59758. fallOff: number;
  59759. /**
  59760. * The base color of the SSAO post-process
  59761. * The final result is "base + ssao" between [0, 1]
  59762. */
  59763. base: number;
  59764. private _scene;
  59765. private _depthTexture;
  59766. private _randomTexture;
  59767. private _originalColorPostProcess;
  59768. private _ssaoPostProcess;
  59769. private _blurHPostProcess;
  59770. private _blurVPostProcess;
  59771. private _ssaoCombinePostProcess;
  59772. private _firstUpdate;
  59773. /**
  59774. * Gets active scene
  59775. */
  59776. readonly scene: Scene;
  59777. /**
  59778. * @constructor
  59779. * @param name - The rendering pipeline name
  59780. * @param scene - The scene linked to this pipeline
  59781. * @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 }
  59782. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59783. */
  59784. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59785. /**
  59786. * Get the class name
  59787. * @returns "SSAORenderingPipeline"
  59788. */
  59789. getClassName(): string;
  59790. /**
  59791. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59792. */
  59793. dispose(disableDepthRender?: boolean): void;
  59794. private _createBlurPostProcess;
  59795. /** @hidden */
  59796. _rebuild(): void;
  59797. private _createSSAOPostProcess;
  59798. private _createSSAOCombinePostProcess;
  59799. private _createRandomTexture;
  59800. }
  59801. }
  59802. declare module "babylonjs/Shaders/standard.fragment" {
  59803. /** @hidden */
  59804. export var standardPixelShader: {
  59805. name: string;
  59806. shader: string;
  59807. };
  59808. }
  59809. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59810. import { Nullable } from "babylonjs/types";
  59811. import { IAnimatable } from "babylonjs/Misc/tools";
  59812. import { Camera } from "babylonjs/Cameras/camera";
  59813. import { Texture } from "babylonjs/Materials/Textures/texture";
  59814. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59815. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59816. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59817. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59818. import { IDisposable } from "babylonjs/scene";
  59819. import { SpotLight } from "babylonjs/Lights/spotLight";
  59820. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59821. import { Scene } from "babylonjs/scene";
  59822. import { Animation } from "babylonjs/Animations/animation";
  59823. import "babylonjs/Shaders/standard.fragment";
  59824. /**
  59825. * Standard rendering pipeline
  59826. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59827. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59828. */
  59829. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59830. /**
  59831. * Public members
  59832. */
  59833. /**
  59834. * Post-process which contains the original scene color before the pipeline applies all the effects
  59835. */
  59836. originalPostProcess: Nullable<PostProcess>;
  59837. /**
  59838. * Post-process used to down scale an image x4
  59839. */
  59840. downSampleX4PostProcess: Nullable<PostProcess>;
  59841. /**
  59842. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59843. */
  59844. brightPassPostProcess: Nullable<PostProcess>;
  59845. /**
  59846. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59847. */
  59848. blurHPostProcesses: PostProcess[];
  59849. /**
  59850. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59851. */
  59852. blurVPostProcesses: PostProcess[];
  59853. /**
  59854. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59855. */
  59856. textureAdderPostProcess: Nullable<PostProcess>;
  59857. /**
  59858. * Post-process used to create volumetric lighting effect
  59859. */
  59860. volumetricLightPostProcess: Nullable<PostProcess>;
  59861. /**
  59862. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59863. */
  59864. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59865. /**
  59866. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59867. */
  59868. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59869. /**
  59870. * Post-process used to merge the volumetric light effect and the real scene color
  59871. */
  59872. volumetricLightMergePostProces: Nullable<PostProcess>;
  59873. /**
  59874. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59875. */
  59876. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59877. /**
  59878. * Base post-process used to calculate the average luminance of the final image for HDR
  59879. */
  59880. luminancePostProcess: Nullable<PostProcess>;
  59881. /**
  59882. * Post-processes used to create down sample post-processes in order to get
  59883. * the average luminance of the final image for HDR
  59884. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59885. */
  59886. luminanceDownSamplePostProcesses: PostProcess[];
  59887. /**
  59888. * Post-process used to create a HDR effect (light adaptation)
  59889. */
  59890. hdrPostProcess: Nullable<PostProcess>;
  59891. /**
  59892. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59893. */
  59894. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59895. /**
  59896. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59897. */
  59898. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59899. /**
  59900. * Post-process used to merge the final HDR post-process and the real scene color
  59901. */
  59902. hdrFinalPostProcess: Nullable<PostProcess>;
  59903. /**
  59904. * Post-process used to create a lens flare effect
  59905. */
  59906. lensFlarePostProcess: Nullable<PostProcess>;
  59907. /**
  59908. * Post-process that merges the result of the lens flare post-process and the real scene color
  59909. */
  59910. lensFlareComposePostProcess: Nullable<PostProcess>;
  59911. /**
  59912. * Post-process used to create a motion blur effect
  59913. */
  59914. motionBlurPostProcess: Nullable<PostProcess>;
  59915. /**
  59916. * Post-process used to create a depth of field effect
  59917. */
  59918. depthOfFieldPostProcess: Nullable<PostProcess>;
  59919. /**
  59920. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59921. */
  59922. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59923. /**
  59924. * Represents the brightness threshold in order to configure the illuminated surfaces
  59925. */
  59926. brightThreshold: number;
  59927. /**
  59928. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59929. */
  59930. blurWidth: number;
  59931. /**
  59932. * Sets if the blur for highlighted surfaces must be only horizontal
  59933. */
  59934. horizontalBlur: boolean;
  59935. /**
  59936. * Gets the overall exposure used by the pipeline
  59937. */
  59938. /**
  59939. * Sets the overall exposure used by the pipeline
  59940. */
  59941. exposure: number;
  59942. /**
  59943. * Texture used typically to simulate "dirty" on camera lens
  59944. */
  59945. lensTexture: Nullable<Texture>;
  59946. /**
  59947. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59948. */
  59949. volumetricLightCoefficient: number;
  59950. /**
  59951. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59952. */
  59953. volumetricLightPower: number;
  59954. /**
  59955. * Used the set the blur intensity to smooth the volumetric lights
  59956. */
  59957. volumetricLightBlurScale: number;
  59958. /**
  59959. * Light (spot or directional) used to generate the volumetric lights rays
  59960. * The source light must have a shadow generate so the pipeline can get its
  59961. * depth map
  59962. */
  59963. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59964. /**
  59965. * For eye adaptation, represents the minimum luminance the eye can see
  59966. */
  59967. hdrMinimumLuminance: number;
  59968. /**
  59969. * For eye adaptation, represents the decrease luminance speed
  59970. */
  59971. hdrDecreaseRate: number;
  59972. /**
  59973. * For eye adaptation, represents the increase luminance speed
  59974. */
  59975. hdrIncreaseRate: number;
  59976. /**
  59977. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59978. */
  59979. /**
  59980. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59981. */
  59982. hdrAutoExposure: boolean;
  59983. /**
  59984. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59985. */
  59986. lensColorTexture: Nullable<Texture>;
  59987. /**
  59988. * The overall strengh for the lens flare effect
  59989. */
  59990. lensFlareStrength: number;
  59991. /**
  59992. * Dispersion coefficient for lens flare ghosts
  59993. */
  59994. lensFlareGhostDispersal: number;
  59995. /**
  59996. * Main lens flare halo width
  59997. */
  59998. lensFlareHaloWidth: number;
  59999. /**
  60000. * Based on the lens distortion effect, defines how much the lens flare result
  60001. * is distorted
  60002. */
  60003. lensFlareDistortionStrength: number;
  60004. /**
  60005. * Lens star texture must be used to simulate rays on the flares and is available
  60006. * in the documentation
  60007. */
  60008. lensStarTexture: Nullable<Texture>;
  60009. /**
  60010. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60011. * flare effect by taking account of the dirt texture
  60012. */
  60013. lensFlareDirtTexture: Nullable<Texture>;
  60014. /**
  60015. * Represents the focal length for the depth of field effect
  60016. */
  60017. depthOfFieldDistance: number;
  60018. /**
  60019. * Represents the blur intensity for the blurred part of the depth of field effect
  60020. */
  60021. depthOfFieldBlurWidth: number;
  60022. /**
  60023. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60024. */
  60025. /**
  60026. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60027. */
  60028. motionStrength: number;
  60029. /**
  60030. * Gets wether or not the motion blur post-process is object based or screen based.
  60031. */
  60032. /**
  60033. * Sets wether or not the motion blur post-process should be object based or screen based
  60034. */
  60035. objectBasedMotionBlur: boolean;
  60036. /**
  60037. * List of animations for the pipeline (IAnimatable implementation)
  60038. */
  60039. animations: Animation[];
  60040. /**
  60041. * Private members
  60042. */
  60043. private _scene;
  60044. private _currentDepthOfFieldSource;
  60045. private _basePostProcess;
  60046. private _fixedExposure;
  60047. private _currentExposure;
  60048. private _hdrAutoExposure;
  60049. private _hdrCurrentLuminance;
  60050. private _motionStrength;
  60051. private _isObjectBasedMotionBlur;
  60052. private _floatTextureType;
  60053. private _ratio;
  60054. private _bloomEnabled;
  60055. private _depthOfFieldEnabled;
  60056. private _vlsEnabled;
  60057. private _lensFlareEnabled;
  60058. private _hdrEnabled;
  60059. private _motionBlurEnabled;
  60060. private _fxaaEnabled;
  60061. private _motionBlurSamples;
  60062. private _volumetricLightStepsCount;
  60063. private _samples;
  60064. /**
  60065. * @ignore
  60066. * Specifies if the bloom pipeline is enabled
  60067. */
  60068. BloomEnabled: boolean;
  60069. /**
  60070. * @ignore
  60071. * Specifies if the depth of field pipeline is enabed
  60072. */
  60073. DepthOfFieldEnabled: boolean;
  60074. /**
  60075. * @ignore
  60076. * Specifies if the lens flare pipeline is enabed
  60077. */
  60078. LensFlareEnabled: boolean;
  60079. /**
  60080. * @ignore
  60081. * Specifies if the HDR pipeline is enabled
  60082. */
  60083. HDREnabled: boolean;
  60084. /**
  60085. * @ignore
  60086. * Specifies if the volumetric lights scattering effect is enabled
  60087. */
  60088. VLSEnabled: boolean;
  60089. /**
  60090. * @ignore
  60091. * Specifies if the motion blur effect is enabled
  60092. */
  60093. MotionBlurEnabled: boolean;
  60094. /**
  60095. * Specifies if anti-aliasing is enabled
  60096. */
  60097. fxaaEnabled: boolean;
  60098. /**
  60099. * Specifies the number of steps used to calculate the volumetric lights
  60100. * Typically in interval [50, 200]
  60101. */
  60102. volumetricLightStepsCount: number;
  60103. /**
  60104. * Specifies the number of samples used for the motion blur effect
  60105. * Typically in interval [16, 64]
  60106. */
  60107. motionBlurSamples: number;
  60108. /**
  60109. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60110. */
  60111. samples: number;
  60112. /**
  60113. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60114. * @constructor
  60115. * @param name The rendering pipeline name
  60116. * @param scene The scene linked to this pipeline
  60117. * @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)
  60118. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60119. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60120. */
  60121. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60122. private _buildPipeline;
  60123. private _createDownSampleX4PostProcess;
  60124. private _createBrightPassPostProcess;
  60125. private _createBlurPostProcesses;
  60126. private _createTextureAdderPostProcess;
  60127. private _createVolumetricLightPostProcess;
  60128. private _createLuminancePostProcesses;
  60129. private _createHdrPostProcess;
  60130. private _createLensFlarePostProcess;
  60131. private _createDepthOfFieldPostProcess;
  60132. private _createMotionBlurPostProcess;
  60133. private _getDepthTexture;
  60134. private _disposePostProcesses;
  60135. /**
  60136. * Dispose of the pipeline and stop all post processes
  60137. */
  60138. dispose(): void;
  60139. /**
  60140. * Serialize the rendering pipeline (Used when exporting)
  60141. * @returns the serialized object
  60142. */
  60143. serialize(): any;
  60144. /**
  60145. * Parse the serialized pipeline
  60146. * @param source Source pipeline.
  60147. * @param scene The scene to load the pipeline to.
  60148. * @param rootUrl The URL of the serialized pipeline.
  60149. * @returns An instantiated pipeline from the serialized object.
  60150. */
  60151. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60152. /**
  60153. * Luminance steps
  60154. */
  60155. static LuminanceSteps: number;
  60156. }
  60157. }
  60158. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  60159. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  60160. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  60161. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  60162. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  60163. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  60164. }
  60165. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  60166. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  60167. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60168. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60169. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60170. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60171. }
  60172. declare module "babylonjs/Shaders/tonemap.fragment" {
  60173. /** @hidden */
  60174. export var tonemapPixelShader: {
  60175. name: string;
  60176. shader: string;
  60177. };
  60178. }
  60179. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  60180. import { Camera } from "babylonjs/Cameras/camera";
  60181. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60182. import "babylonjs/Shaders/tonemap.fragment";
  60183. import { Engine } from "babylonjs/Engines/engine";
  60184. /** Defines operator used for tonemapping */
  60185. export enum TonemappingOperator {
  60186. /** Hable */
  60187. Hable = 0,
  60188. /** Reinhard */
  60189. Reinhard = 1,
  60190. /** HejiDawson */
  60191. HejiDawson = 2,
  60192. /** Photographic */
  60193. Photographic = 3
  60194. }
  60195. /**
  60196. * Defines a post process to apply tone mapping
  60197. */
  60198. export class TonemapPostProcess extends PostProcess {
  60199. private _operator;
  60200. /** Defines the required exposure adjustement */
  60201. exposureAdjustment: number;
  60202. /**
  60203. * Creates a new TonemapPostProcess
  60204. * @param name defines the name of the postprocess
  60205. * @param _operator defines the operator to use
  60206. * @param exposureAdjustment defines the required exposure adjustement
  60207. * @param camera defines the camera to use (can be null)
  60208. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60209. * @param engine defines the hosting engine (can be ignore if camera is set)
  60210. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60211. */
  60212. constructor(name: string, _operator: TonemappingOperator,
  60213. /** Defines the required exposure adjustement */
  60214. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60215. }
  60216. }
  60217. declare module "babylonjs/Shaders/depth.vertex" {
  60218. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60219. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60220. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60221. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60222. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60223. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60224. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60225. /** @hidden */
  60226. export var depthVertexShader: {
  60227. name: string;
  60228. shader: string;
  60229. };
  60230. }
  60231. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  60232. /** @hidden */
  60233. export var volumetricLightScatteringPixelShader: {
  60234. name: string;
  60235. shader: string;
  60236. };
  60237. }
  60238. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  60239. /** @hidden */
  60240. export var volumetricLightScatteringPassPixelShader: {
  60241. name: string;
  60242. shader: string;
  60243. };
  60244. }
  60245. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  60246. import { Vector3 } from "babylonjs/Maths/math";
  60247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60248. import { Mesh } from "babylonjs/Meshes/mesh";
  60249. import { Camera } from "babylonjs/Cameras/camera";
  60250. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60251. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60252. import { Scene } from "babylonjs/scene";
  60253. import "babylonjs/Meshes/Builders/planeBuilder";
  60254. import "babylonjs/Shaders/depth.vertex";
  60255. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  60256. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  60257. import { Engine } from "babylonjs/Engines/engine";
  60258. /**
  60259. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60260. */
  60261. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60262. private _volumetricLightScatteringPass;
  60263. private _volumetricLightScatteringRTT;
  60264. private _viewPort;
  60265. private _screenCoordinates;
  60266. private _cachedDefines;
  60267. /**
  60268. * If not undefined, the mesh position is computed from the attached node position
  60269. */
  60270. attachedNode: {
  60271. position: Vector3;
  60272. };
  60273. /**
  60274. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60275. */
  60276. customMeshPosition: Vector3;
  60277. /**
  60278. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60279. */
  60280. useCustomMeshPosition: boolean;
  60281. /**
  60282. * If the post-process should inverse the light scattering direction
  60283. */
  60284. invert: boolean;
  60285. /**
  60286. * The internal mesh used by the post-process
  60287. */
  60288. mesh: Mesh;
  60289. /**
  60290. * @hidden
  60291. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60292. */
  60293. useDiffuseColor: boolean;
  60294. /**
  60295. * Array containing the excluded meshes not rendered in the internal pass
  60296. */
  60297. excludedMeshes: AbstractMesh[];
  60298. /**
  60299. * Controls the overall intensity of the post-process
  60300. */
  60301. exposure: number;
  60302. /**
  60303. * Dissipates each sample's contribution in range [0, 1]
  60304. */
  60305. decay: number;
  60306. /**
  60307. * Controls the overall intensity of each sample
  60308. */
  60309. weight: number;
  60310. /**
  60311. * Controls the density of each sample
  60312. */
  60313. density: number;
  60314. /**
  60315. * @constructor
  60316. * @param name The post-process name
  60317. * @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)
  60318. * @param camera The camera that the post-process will be attached to
  60319. * @param mesh The mesh used to create the light scattering
  60320. * @param samples The post-process quality, default 100
  60321. * @param samplingModeThe post-process filtering mode
  60322. * @param engine The babylon engine
  60323. * @param reusable If the post-process is reusable
  60324. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60325. */
  60326. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60327. /**
  60328. * Returns the string "VolumetricLightScatteringPostProcess"
  60329. * @returns "VolumetricLightScatteringPostProcess"
  60330. */
  60331. getClassName(): string;
  60332. private _isReady;
  60333. /**
  60334. * Sets the new light position for light scattering effect
  60335. * @param position The new custom light position
  60336. */
  60337. setCustomMeshPosition(position: Vector3): void;
  60338. /**
  60339. * Returns the light position for light scattering effect
  60340. * @return Vector3 The custom light position
  60341. */
  60342. getCustomMeshPosition(): Vector3;
  60343. /**
  60344. * Disposes the internal assets and detaches the post-process from the camera
  60345. */
  60346. dispose(camera: Camera): void;
  60347. /**
  60348. * Returns the render target texture used by the post-process
  60349. * @return the render target texture used by the post-process
  60350. */
  60351. getPass(): RenderTargetTexture;
  60352. private _meshExcluded;
  60353. private _createPass;
  60354. private _updateMeshScreenCoordinates;
  60355. /**
  60356. * Creates a default mesh for the Volumeric Light Scattering post-process
  60357. * @param name The mesh name
  60358. * @param scene The scene where to create the mesh
  60359. * @return the default mesh
  60360. */
  60361. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60362. }
  60363. }
  60364. declare module "babylonjs/PostProcesses/index" {
  60365. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  60366. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  60367. export * from "babylonjs/PostProcesses/bloomEffect";
  60368. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  60369. export * from "babylonjs/PostProcesses/blurPostProcess";
  60370. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60371. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  60372. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  60373. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  60374. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60375. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  60376. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  60377. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  60378. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60379. export * from "babylonjs/PostProcesses/filterPostProcess";
  60380. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  60381. export * from "babylonjs/PostProcesses/grainPostProcess";
  60382. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  60383. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60384. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  60385. export * from "babylonjs/PostProcesses/passPostProcess";
  60386. export * from "babylonjs/PostProcesses/postProcess";
  60387. export * from "babylonjs/PostProcesses/postProcessManager";
  60388. export * from "babylonjs/PostProcesses/refractionPostProcess";
  60389. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  60390. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  60391. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  60392. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  60393. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  60394. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  60395. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  60396. }
  60397. declare module "babylonjs/Probes/index" {
  60398. export * from "babylonjs/Probes/reflectionProbe";
  60399. }
  60400. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  60401. import { Scene } from "babylonjs/scene";
  60402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60403. import { Color3 } from "babylonjs/Maths/math";
  60404. import { SmartArray } from "babylonjs/Misc/smartArray";
  60405. import { ISceneComponent } from "babylonjs/sceneComponent";
  60406. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  60407. import "babylonjs/Meshes/Builders/boxBuilder";
  60408. import "babylonjs/Shaders/color.fragment";
  60409. import "babylonjs/Shaders/color.vertex";
  60410. module "babylonjs/scene" {
  60411. interface Scene {
  60412. /** @hidden (Backing field) */
  60413. _boundingBoxRenderer: BoundingBoxRenderer;
  60414. /** @hidden (Backing field) */
  60415. _forceShowBoundingBoxes: boolean;
  60416. /**
  60417. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60418. */
  60419. forceShowBoundingBoxes: boolean;
  60420. /**
  60421. * Gets the bounding box renderer associated with the scene
  60422. * @returns a BoundingBoxRenderer
  60423. */
  60424. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60425. }
  60426. }
  60427. module "babylonjs/Meshes/abstractMesh" {
  60428. interface AbstractMesh {
  60429. /** @hidden (Backing field) */
  60430. _showBoundingBox: boolean;
  60431. /**
  60432. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60433. */
  60434. showBoundingBox: boolean;
  60435. }
  60436. }
  60437. /**
  60438. * Component responsible of rendering the bounding box of the meshes in a scene.
  60439. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60440. */
  60441. export class BoundingBoxRenderer implements ISceneComponent {
  60442. /**
  60443. * The component name helpfull to identify the component in the list of scene components.
  60444. */
  60445. readonly name: string;
  60446. /**
  60447. * The scene the component belongs to.
  60448. */
  60449. scene: Scene;
  60450. /**
  60451. * Color of the bounding box lines placed in front of an object
  60452. */
  60453. frontColor: Color3;
  60454. /**
  60455. * Color of the bounding box lines placed behind an object
  60456. */
  60457. backColor: Color3;
  60458. /**
  60459. * Defines if the renderer should show the back lines or not
  60460. */
  60461. showBackLines: boolean;
  60462. /**
  60463. * @hidden
  60464. */
  60465. renderList: SmartArray<BoundingBox>;
  60466. private _colorShader;
  60467. private _vertexBuffers;
  60468. private _indexBuffer;
  60469. private _fillIndexBuffer;
  60470. private _fillIndexData;
  60471. /**
  60472. * Instantiates a new bounding box renderer in a scene.
  60473. * @param scene the scene the renderer renders in
  60474. */
  60475. constructor(scene: Scene);
  60476. /**
  60477. * Registers the component in a given scene
  60478. */
  60479. register(): void;
  60480. private _evaluateSubMesh;
  60481. private _activeMesh;
  60482. private _prepareRessources;
  60483. private _createIndexBuffer;
  60484. /**
  60485. * Rebuilds the elements related to this component in case of
  60486. * context lost for instance.
  60487. */
  60488. rebuild(): void;
  60489. /**
  60490. * @hidden
  60491. */
  60492. reset(): void;
  60493. /**
  60494. * Render the bounding boxes of a specific rendering group
  60495. * @param renderingGroupId defines the rendering group to render
  60496. */
  60497. render(renderingGroupId: number): void;
  60498. /**
  60499. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60500. * @param mesh Define the mesh to render the occlusion bounding box for
  60501. */
  60502. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60503. /**
  60504. * Dispose and release the resources attached to this renderer.
  60505. */
  60506. dispose(): void;
  60507. }
  60508. }
  60509. declare module "babylonjs/Shaders/depth.fragment" {
  60510. /** @hidden */
  60511. export var depthPixelShader: {
  60512. name: string;
  60513. shader: string;
  60514. };
  60515. }
  60516. declare module "babylonjs/Rendering/depthRenderer" {
  60517. import { Nullable } from "babylonjs/types";
  60518. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60519. import { Scene } from "babylonjs/scene";
  60520. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60521. import { Camera } from "babylonjs/Cameras/camera";
  60522. import "babylonjs/Shaders/depth.fragment";
  60523. import "babylonjs/Shaders/depth.vertex";
  60524. /**
  60525. * This represents a depth renderer in Babylon.
  60526. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60527. */
  60528. export class DepthRenderer {
  60529. private _scene;
  60530. private _depthMap;
  60531. private _effect;
  60532. private _cachedDefines;
  60533. private _camera;
  60534. /**
  60535. * Specifiess that the depth renderer will only be used within
  60536. * the camera it is created for.
  60537. * This can help forcing its rendering during the camera processing.
  60538. */
  60539. useOnlyInActiveCamera: boolean;
  60540. /** @hidden */
  60541. static _SceneComponentInitialization: (scene: Scene) => void;
  60542. /**
  60543. * Instantiates a depth renderer
  60544. * @param scene The scene the renderer belongs to
  60545. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60546. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60547. */
  60548. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  60549. /**
  60550. * Creates the depth rendering effect and checks if the effect is ready.
  60551. * @param subMesh The submesh to be used to render the depth map of
  60552. * @param useInstances If multiple world instances should be used
  60553. * @returns if the depth renderer is ready to render the depth map
  60554. */
  60555. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60556. /**
  60557. * Gets the texture which the depth map will be written to.
  60558. * @returns The depth map texture
  60559. */
  60560. getDepthMap(): RenderTargetTexture;
  60561. /**
  60562. * Disposes of the depth renderer.
  60563. */
  60564. dispose(): void;
  60565. }
  60566. }
  60567. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  60568. import { Nullable } from "babylonjs/types";
  60569. import { Scene } from "babylonjs/scene";
  60570. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60571. import { Camera } from "babylonjs/Cameras/camera";
  60572. import { ISceneComponent } from "babylonjs/sceneComponent";
  60573. module "babylonjs/scene" {
  60574. interface Scene {
  60575. /** @hidden (Backing field) */
  60576. _depthRenderer: {
  60577. [id: string]: DepthRenderer;
  60578. };
  60579. /**
  60580. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60581. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60582. * @returns the created depth renderer
  60583. */
  60584. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  60585. /**
  60586. * Disables a depth renderer for a given camera
  60587. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60588. */
  60589. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60590. }
  60591. }
  60592. /**
  60593. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60594. * in several rendering techniques.
  60595. */
  60596. export class DepthRendererSceneComponent implements ISceneComponent {
  60597. /**
  60598. * The component name helpfull to identify the component in the list of scene components.
  60599. */
  60600. readonly name: string;
  60601. /**
  60602. * The scene the component belongs to.
  60603. */
  60604. scene: Scene;
  60605. /**
  60606. * Creates a new instance of the component for the given scene
  60607. * @param scene Defines the scene to register the component in
  60608. */
  60609. constructor(scene: Scene);
  60610. /**
  60611. * Registers the component in a given scene
  60612. */
  60613. register(): void;
  60614. /**
  60615. * Rebuilds the elements related to this component in case of
  60616. * context lost for instance.
  60617. */
  60618. rebuild(): void;
  60619. /**
  60620. * Disposes the component and the associated ressources
  60621. */
  60622. dispose(): void;
  60623. private _gatherRenderTargets;
  60624. private _gatherActiveCameraRenderTargets;
  60625. }
  60626. }
  60627. declare module "babylonjs/Shaders/outline.fragment" {
  60628. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60629. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  60630. /** @hidden */
  60631. export var outlinePixelShader: {
  60632. name: string;
  60633. shader: string;
  60634. };
  60635. }
  60636. declare module "babylonjs/Shaders/outline.vertex" {
  60637. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60638. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60639. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60640. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60641. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60642. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60643. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60644. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60645. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60646. /** @hidden */
  60647. export var outlineVertexShader: {
  60648. name: string;
  60649. shader: string;
  60650. };
  60651. }
  60652. declare module "babylonjs/Rendering/outlineRenderer" {
  60653. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60654. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60655. import { Scene } from "babylonjs/scene";
  60656. import { ISceneComponent } from "babylonjs/sceneComponent";
  60657. import "babylonjs/Shaders/outline.fragment";
  60658. import "babylonjs/Shaders/outline.vertex";
  60659. module "babylonjs/scene" {
  60660. interface Scene {
  60661. /** @hidden */
  60662. _outlineRenderer: OutlineRenderer;
  60663. /**
  60664. * Gets the outline renderer associated with the scene
  60665. * @returns a OutlineRenderer
  60666. */
  60667. getOutlineRenderer(): OutlineRenderer;
  60668. }
  60669. }
  60670. module "babylonjs/Meshes/abstractMesh" {
  60671. interface AbstractMesh {
  60672. /** @hidden (Backing field) */
  60673. _renderOutline: boolean;
  60674. /**
  60675. * Gets or sets a boolean indicating if the outline must be rendered as well
  60676. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60677. */
  60678. renderOutline: boolean;
  60679. /** @hidden (Backing field) */
  60680. _renderOverlay: boolean;
  60681. /**
  60682. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60683. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60684. */
  60685. renderOverlay: boolean;
  60686. }
  60687. }
  60688. /**
  60689. * This class is responsible to draw bothe outline/overlay of meshes.
  60690. * It should not be used directly but through the available method on mesh.
  60691. */
  60692. export class OutlineRenderer implements ISceneComponent {
  60693. /**
  60694. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60695. */
  60696. private static _StencilReference;
  60697. /**
  60698. * The name of the component. Each component must have a unique name.
  60699. */
  60700. name: string;
  60701. /**
  60702. * The scene the component belongs to.
  60703. */
  60704. scene: Scene;
  60705. /**
  60706. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60707. */
  60708. zOffset: number;
  60709. private _engine;
  60710. private _effect;
  60711. private _cachedDefines;
  60712. private _savedDepthWrite;
  60713. /**
  60714. * Instantiates a new outline renderer. (There could be only one per scene).
  60715. * @param scene Defines the scene it belongs to
  60716. */
  60717. constructor(scene: Scene);
  60718. /**
  60719. * Register the component to one instance of a scene.
  60720. */
  60721. register(): void;
  60722. /**
  60723. * Rebuilds the elements related to this component in case of
  60724. * context lost for instance.
  60725. */
  60726. rebuild(): void;
  60727. /**
  60728. * Disposes the component and the associated ressources.
  60729. */
  60730. dispose(): void;
  60731. /**
  60732. * Renders the outline in the canvas.
  60733. * @param subMesh Defines the sumesh to render
  60734. * @param batch Defines the batch of meshes in case of instances
  60735. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60736. */
  60737. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60738. /**
  60739. * Returns whether or not the outline renderer is ready for a given submesh.
  60740. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60741. * @param subMesh Defines the submesh to check readyness for
  60742. * @param useInstances Defines wheter wee are trying to render instances or not
  60743. * @returns true if ready otherwise false
  60744. */
  60745. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60746. private _beforeRenderingMesh;
  60747. private _afterRenderingMesh;
  60748. }
  60749. }
  60750. declare module "babylonjs/Rendering/index" {
  60751. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60752. export * from "babylonjs/Rendering/depthRenderer";
  60753. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60754. export * from "babylonjs/Rendering/edgesRenderer";
  60755. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60756. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60757. export * from "babylonjs/Rendering/outlineRenderer";
  60758. export * from "babylonjs/Rendering/renderingGroup";
  60759. export * from "babylonjs/Rendering/renderingManager";
  60760. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60761. }
  60762. declare module "babylonjs/Sprites/index" {
  60763. export * from "babylonjs/Sprites/sprite";
  60764. export * from "babylonjs/Sprites/spriteManager";
  60765. export * from "babylonjs/Sprites/spriteSceneComponent";
  60766. }
  60767. declare module "babylonjs/Misc/assetsManager" {
  60768. import { Scene } from "babylonjs/scene";
  60769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60770. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60771. import { Skeleton } from "babylonjs/Bones/skeleton";
  60772. import { Observable } from "babylonjs/Misc/observable";
  60773. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60774. import { Texture } from "babylonjs/Materials/Textures/texture";
  60775. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60776. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60777. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60778. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60779. /**
  60780. * Defines the list of states available for a task inside a AssetsManager
  60781. */
  60782. export enum AssetTaskState {
  60783. /**
  60784. * Initialization
  60785. */
  60786. INIT = 0,
  60787. /**
  60788. * Running
  60789. */
  60790. RUNNING = 1,
  60791. /**
  60792. * Done
  60793. */
  60794. DONE = 2,
  60795. /**
  60796. * Error
  60797. */
  60798. ERROR = 3
  60799. }
  60800. /**
  60801. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60802. */
  60803. export abstract class AbstractAssetTask {
  60804. /**
  60805. * Task name
  60806. */ name: string;
  60807. /**
  60808. * Callback called when the task is successful
  60809. */
  60810. onSuccess: (task: any) => void;
  60811. /**
  60812. * Callback called when the task is not successful
  60813. */
  60814. onError: (task: any, message?: string, exception?: any) => void;
  60815. /**
  60816. * Creates a new AssetsManager
  60817. * @param name defines the name of the task
  60818. */
  60819. constructor(
  60820. /**
  60821. * Task name
  60822. */ name: string);
  60823. private _isCompleted;
  60824. private _taskState;
  60825. private _errorObject;
  60826. /**
  60827. * Get if the task is completed
  60828. */
  60829. readonly isCompleted: boolean;
  60830. /**
  60831. * Gets the current state of the task
  60832. */
  60833. readonly taskState: AssetTaskState;
  60834. /**
  60835. * Gets the current error object (if task is in error)
  60836. */
  60837. readonly errorObject: {
  60838. message?: string;
  60839. exception?: any;
  60840. };
  60841. /**
  60842. * Internal only
  60843. * @hidden
  60844. */
  60845. _setErrorObject(message?: string, exception?: any): void;
  60846. /**
  60847. * Execute the current task
  60848. * @param scene defines the scene where you want your assets to be loaded
  60849. * @param onSuccess is a callback called when the task is successfully executed
  60850. * @param onError is a callback called if an error occurs
  60851. */
  60852. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60853. /**
  60854. * Execute the current task
  60855. * @param scene defines the scene where you want your assets to be loaded
  60856. * @param onSuccess is a callback called when the task is successfully executed
  60857. * @param onError is a callback called if an error occurs
  60858. */
  60859. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60860. /**
  60861. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60862. * This can be used with failed tasks that have the reason for failure fixed.
  60863. */
  60864. reset(): void;
  60865. private onErrorCallback;
  60866. private onDoneCallback;
  60867. }
  60868. /**
  60869. * Define the interface used by progress events raised during assets loading
  60870. */
  60871. export interface IAssetsProgressEvent {
  60872. /**
  60873. * Defines the number of remaining tasks to process
  60874. */
  60875. remainingCount: number;
  60876. /**
  60877. * Defines the total number of tasks
  60878. */
  60879. totalCount: number;
  60880. /**
  60881. * Defines the task that was just processed
  60882. */
  60883. task: AbstractAssetTask;
  60884. }
  60885. /**
  60886. * Class used to share progress information about assets loading
  60887. */
  60888. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60889. /**
  60890. * Defines the number of remaining tasks to process
  60891. */
  60892. remainingCount: number;
  60893. /**
  60894. * Defines the total number of tasks
  60895. */
  60896. totalCount: number;
  60897. /**
  60898. * Defines the task that was just processed
  60899. */
  60900. task: AbstractAssetTask;
  60901. /**
  60902. * Creates a AssetsProgressEvent
  60903. * @param remainingCount defines the number of remaining tasks to process
  60904. * @param totalCount defines the total number of tasks
  60905. * @param task defines the task that was just processed
  60906. */
  60907. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60908. }
  60909. /**
  60910. * Define a task used by AssetsManager to load meshes
  60911. */
  60912. export class MeshAssetTask extends AbstractAssetTask {
  60913. /**
  60914. * Defines the name of the task
  60915. */
  60916. name: string;
  60917. /**
  60918. * Defines the list of mesh's names you want to load
  60919. */
  60920. meshesNames: any;
  60921. /**
  60922. * Defines the root url to use as a base to load your meshes and associated resources
  60923. */
  60924. rootUrl: string;
  60925. /**
  60926. * Defines the filename of the scene to load from
  60927. */
  60928. sceneFilename: string;
  60929. /**
  60930. * Gets the list of loaded meshes
  60931. */
  60932. loadedMeshes: Array<AbstractMesh>;
  60933. /**
  60934. * Gets the list of loaded particle systems
  60935. */
  60936. loadedParticleSystems: Array<IParticleSystem>;
  60937. /**
  60938. * Gets the list of loaded skeletons
  60939. */
  60940. loadedSkeletons: Array<Skeleton>;
  60941. /**
  60942. * Gets the list of loaded animation groups
  60943. */
  60944. loadedAnimationGroups: Array<AnimationGroup>;
  60945. /**
  60946. * Callback called when the task is successful
  60947. */
  60948. onSuccess: (task: MeshAssetTask) => void;
  60949. /**
  60950. * Callback called when the task is successful
  60951. */
  60952. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60953. /**
  60954. * Creates a new MeshAssetTask
  60955. * @param name defines the name of the task
  60956. * @param meshesNames defines the list of mesh's names you want to load
  60957. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60958. * @param sceneFilename defines the filename of the scene to load from
  60959. */
  60960. constructor(
  60961. /**
  60962. * Defines the name of the task
  60963. */
  60964. name: string,
  60965. /**
  60966. * Defines the list of mesh's names you want to load
  60967. */
  60968. meshesNames: any,
  60969. /**
  60970. * Defines the root url to use as a base to load your meshes and associated resources
  60971. */
  60972. rootUrl: string,
  60973. /**
  60974. * Defines the filename of the scene to load from
  60975. */
  60976. sceneFilename: string);
  60977. /**
  60978. * Execute the current task
  60979. * @param scene defines the scene where you want your assets to be loaded
  60980. * @param onSuccess is a callback called when the task is successfully executed
  60981. * @param onError is a callback called if an error occurs
  60982. */
  60983. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60984. }
  60985. /**
  60986. * Define a task used by AssetsManager to load text content
  60987. */
  60988. export class TextFileAssetTask extends AbstractAssetTask {
  60989. /**
  60990. * Defines the name of the task
  60991. */
  60992. name: string;
  60993. /**
  60994. * Defines the location of the file to load
  60995. */
  60996. url: string;
  60997. /**
  60998. * Gets the loaded text string
  60999. */
  61000. text: string;
  61001. /**
  61002. * Callback called when the task is successful
  61003. */
  61004. onSuccess: (task: TextFileAssetTask) => void;
  61005. /**
  61006. * Callback called when the task is successful
  61007. */
  61008. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61009. /**
  61010. * Creates a new TextFileAssetTask object
  61011. * @param name defines the name of the task
  61012. * @param url defines the location of the file to load
  61013. */
  61014. constructor(
  61015. /**
  61016. * Defines the name of the task
  61017. */
  61018. name: string,
  61019. /**
  61020. * Defines the location of the file to load
  61021. */
  61022. url: string);
  61023. /**
  61024. * Execute the current task
  61025. * @param scene defines the scene where you want your assets to be loaded
  61026. * @param onSuccess is a callback called when the task is successfully executed
  61027. * @param onError is a callback called if an error occurs
  61028. */
  61029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61030. }
  61031. /**
  61032. * Define a task used by AssetsManager to load binary data
  61033. */
  61034. export class BinaryFileAssetTask extends AbstractAssetTask {
  61035. /**
  61036. * Defines the name of the task
  61037. */
  61038. name: string;
  61039. /**
  61040. * Defines the location of the file to load
  61041. */
  61042. url: string;
  61043. /**
  61044. * Gets the lodaded data (as an array buffer)
  61045. */
  61046. data: ArrayBuffer;
  61047. /**
  61048. * Callback called when the task is successful
  61049. */
  61050. onSuccess: (task: BinaryFileAssetTask) => void;
  61051. /**
  61052. * Callback called when the task is successful
  61053. */
  61054. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61055. /**
  61056. * Creates a new BinaryFileAssetTask object
  61057. * @param name defines the name of the new task
  61058. * @param url defines the location of the file to load
  61059. */
  61060. constructor(
  61061. /**
  61062. * Defines the name of the task
  61063. */
  61064. name: string,
  61065. /**
  61066. * Defines the location of the file to load
  61067. */
  61068. url: string);
  61069. /**
  61070. * Execute the current task
  61071. * @param scene defines the scene where you want your assets to be loaded
  61072. * @param onSuccess is a callback called when the task is successfully executed
  61073. * @param onError is a callback called if an error occurs
  61074. */
  61075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61076. }
  61077. /**
  61078. * Define a task used by AssetsManager to load images
  61079. */
  61080. export class ImageAssetTask extends AbstractAssetTask {
  61081. /**
  61082. * Defines the name of the task
  61083. */
  61084. name: string;
  61085. /**
  61086. * Defines the location of the image to load
  61087. */
  61088. url: string;
  61089. /**
  61090. * Gets the loaded images
  61091. */
  61092. image: HTMLImageElement;
  61093. /**
  61094. * Callback called when the task is successful
  61095. */
  61096. onSuccess: (task: ImageAssetTask) => void;
  61097. /**
  61098. * Callback called when the task is successful
  61099. */
  61100. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61101. /**
  61102. * Creates a new ImageAssetTask
  61103. * @param name defines the name of the task
  61104. * @param url defines the location of the image to load
  61105. */
  61106. constructor(
  61107. /**
  61108. * Defines the name of the task
  61109. */
  61110. name: string,
  61111. /**
  61112. * Defines the location of the image to load
  61113. */
  61114. url: string);
  61115. /**
  61116. * Execute the current task
  61117. * @param scene defines the scene where you want your assets to be loaded
  61118. * @param onSuccess is a callback called when the task is successfully executed
  61119. * @param onError is a callback called if an error occurs
  61120. */
  61121. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61122. }
  61123. /**
  61124. * Defines the interface used by texture loading tasks
  61125. */
  61126. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61127. /**
  61128. * Gets the loaded texture
  61129. */
  61130. texture: TEX;
  61131. }
  61132. /**
  61133. * Define a task used by AssetsManager to load 2D textures
  61134. */
  61135. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61136. /**
  61137. * Defines the name of the task
  61138. */
  61139. name: string;
  61140. /**
  61141. * Defines the location of the file to load
  61142. */
  61143. url: string;
  61144. /**
  61145. * Defines if mipmap should not be generated (default is false)
  61146. */
  61147. noMipmap?: boolean | undefined;
  61148. /**
  61149. * Defines if texture must be inverted on Y axis (default is false)
  61150. */
  61151. invertY?: boolean | undefined;
  61152. /**
  61153. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61154. */
  61155. samplingMode: number;
  61156. /**
  61157. * Gets the loaded texture
  61158. */
  61159. texture: Texture;
  61160. /**
  61161. * Callback called when the task is successful
  61162. */
  61163. onSuccess: (task: TextureAssetTask) => void;
  61164. /**
  61165. * Callback called when the task is successful
  61166. */
  61167. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61168. /**
  61169. * Creates a new TextureAssetTask object
  61170. * @param name defines the name of the task
  61171. * @param url defines the location of the file to load
  61172. * @param noMipmap defines if mipmap should not be generated (default is false)
  61173. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61174. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61175. */
  61176. constructor(
  61177. /**
  61178. * Defines the name of the task
  61179. */
  61180. name: string,
  61181. /**
  61182. * Defines the location of the file to load
  61183. */
  61184. url: string,
  61185. /**
  61186. * Defines if mipmap should not be generated (default is false)
  61187. */
  61188. noMipmap?: boolean | undefined,
  61189. /**
  61190. * Defines if texture must be inverted on Y axis (default is false)
  61191. */
  61192. invertY?: boolean | undefined,
  61193. /**
  61194. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61195. */
  61196. samplingMode?: number);
  61197. /**
  61198. * Execute the current task
  61199. * @param scene defines the scene where you want your assets to be loaded
  61200. * @param onSuccess is a callback called when the task is successfully executed
  61201. * @param onError is a callback called if an error occurs
  61202. */
  61203. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61204. }
  61205. /**
  61206. * Define a task used by AssetsManager to load cube textures
  61207. */
  61208. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61209. /**
  61210. * Defines the name of the task
  61211. */
  61212. name: string;
  61213. /**
  61214. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61215. */
  61216. url: string;
  61217. /**
  61218. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61219. */
  61220. extensions?: string[] | undefined;
  61221. /**
  61222. * Defines if mipmaps should not be generated (default is false)
  61223. */
  61224. noMipmap?: boolean | undefined;
  61225. /**
  61226. * Defines the explicit list of files (undefined by default)
  61227. */
  61228. files?: string[] | undefined;
  61229. /**
  61230. * Gets the loaded texture
  61231. */
  61232. texture: CubeTexture;
  61233. /**
  61234. * Callback called when the task is successful
  61235. */
  61236. onSuccess: (task: CubeTextureAssetTask) => void;
  61237. /**
  61238. * Callback called when the task is successful
  61239. */
  61240. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61241. /**
  61242. * Creates a new CubeTextureAssetTask
  61243. * @param name defines the name of the task
  61244. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61245. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61246. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61247. * @param files defines the explicit list of files (undefined by default)
  61248. */
  61249. constructor(
  61250. /**
  61251. * Defines the name of the task
  61252. */
  61253. name: string,
  61254. /**
  61255. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61256. */
  61257. url: string,
  61258. /**
  61259. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61260. */
  61261. extensions?: string[] | undefined,
  61262. /**
  61263. * Defines if mipmaps should not be generated (default is false)
  61264. */
  61265. noMipmap?: boolean | undefined,
  61266. /**
  61267. * Defines the explicit list of files (undefined by default)
  61268. */
  61269. files?: string[] | undefined);
  61270. /**
  61271. * Execute the current task
  61272. * @param scene defines the scene where you want your assets to be loaded
  61273. * @param onSuccess is a callback called when the task is successfully executed
  61274. * @param onError is a callback called if an error occurs
  61275. */
  61276. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61277. }
  61278. /**
  61279. * Define a task used by AssetsManager to load HDR cube textures
  61280. */
  61281. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61282. /**
  61283. * Defines the name of the task
  61284. */
  61285. name: string;
  61286. /**
  61287. * Defines the location of the file to load
  61288. */
  61289. url: string;
  61290. /**
  61291. * Defines the desired size (the more it increases the longer the generation will be)
  61292. */
  61293. size: number;
  61294. /**
  61295. * Defines if mipmaps should not be generated (default is false)
  61296. */
  61297. noMipmap: boolean;
  61298. /**
  61299. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61300. */
  61301. generateHarmonics: boolean;
  61302. /**
  61303. * 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)
  61304. */
  61305. gammaSpace: boolean;
  61306. /**
  61307. * Internal Use Only
  61308. */
  61309. reserved: boolean;
  61310. /**
  61311. * Gets the loaded texture
  61312. */
  61313. texture: HDRCubeTexture;
  61314. /**
  61315. * Callback called when the task is successful
  61316. */
  61317. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61318. /**
  61319. * Callback called when the task is successful
  61320. */
  61321. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61322. /**
  61323. * Creates a new HDRCubeTextureAssetTask object
  61324. * @param name defines the name of the task
  61325. * @param url defines the location of the file to load
  61326. * @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.
  61327. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61328. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61329. * @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)
  61330. * @param reserved Internal use only
  61331. */
  61332. constructor(
  61333. /**
  61334. * Defines the name of the task
  61335. */
  61336. name: string,
  61337. /**
  61338. * Defines the location of the file to load
  61339. */
  61340. url: string,
  61341. /**
  61342. * Defines the desired size (the more it increases the longer the generation will be)
  61343. */
  61344. size: number,
  61345. /**
  61346. * Defines if mipmaps should not be generated (default is false)
  61347. */
  61348. noMipmap?: boolean,
  61349. /**
  61350. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61351. */
  61352. generateHarmonics?: boolean,
  61353. /**
  61354. * 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)
  61355. */
  61356. gammaSpace?: boolean,
  61357. /**
  61358. * Internal Use Only
  61359. */
  61360. reserved?: boolean);
  61361. /**
  61362. * Execute the current task
  61363. * @param scene defines the scene where you want your assets to be loaded
  61364. * @param onSuccess is a callback called when the task is successfully executed
  61365. * @param onError is a callback called if an error occurs
  61366. */
  61367. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61368. }
  61369. /**
  61370. * Define a task used by AssetsManager to load Equirectangular cube textures
  61371. */
  61372. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61373. /**
  61374. * Defines the name of the task
  61375. */
  61376. name: string;
  61377. /**
  61378. * Defines the location of the file to load
  61379. */
  61380. url: string;
  61381. /**
  61382. * Defines the desired size (the more it increases the longer the generation will be)
  61383. */
  61384. size: number;
  61385. /**
  61386. * Defines if mipmaps should not be generated (default is false)
  61387. */
  61388. noMipmap: boolean;
  61389. /**
  61390. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61391. * but the standard material would require them in Gamma space) (default is true)
  61392. */
  61393. gammaSpace: boolean;
  61394. /**
  61395. * Gets the loaded texture
  61396. */
  61397. texture: EquiRectangularCubeTexture;
  61398. /**
  61399. * Callback called when the task is successful
  61400. */
  61401. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61402. /**
  61403. * Callback called when the task is successful
  61404. */
  61405. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61406. /**
  61407. * Creates a new EquiRectangularCubeTextureAssetTask object
  61408. * @param name defines the name of the task
  61409. * @param url defines the location of the file to load
  61410. * @param size defines the desired size (the more it increases the longer the generation will be)
  61411. * If the size is omitted this implies you are using a preprocessed cubemap.
  61412. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61413. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61414. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61415. * (default is true)
  61416. */
  61417. constructor(
  61418. /**
  61419. * Defines the name of the task
  61420. */
  61421. name: string,
  61422. /**
  61423. * Defines the location of the file to load
  61424. */
  61425. url: string,
  61426. /**
  61427. * Defines the desired size (the more it increases the longer the generation will be)
  61428. */
  61429. size: number,
  61430. /**
  61431. * Defines if mipmaps should not be generated (default is false)
  61432. */
  61433. noMipmap?: boolean,
  61434. /**
  61435. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61436. * but the standard material would require them in Gamma space) (default is true)
  61437. */
  61438. gammaSpace?: boolean);
  61439. /**
  61440. * Execute the current task
  61441. * @param scene defines the scene where you want your assets to be loaded
  61442. * @param onSuccess is a callback called when the task is successfully executed
  61443. * @param onError is a callback called if an error occurs
  61444. */
  61445. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61446. }
  61447. /**
  61448. * This class can be used to easily import assets into a scene
  61449. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61450. */
  61451. export class AssetsManager {
  61452. private _scene;
  61453. private _isLoading;
  61454. protected _tasks: AbstractAssetTask[];
  61455. protected _waitingTasksCount: number;
  61456. protected _totalTasksCount: number;
  61457. /**
  61458. * Callback called when all tasks are processed
  61459. */
  61460. onFinish: (tasks: AbstractAssetTask[]) => void;
  61461. /**
  61462. * Callback called when a task is successful
  61463. */
  61464. onTaskSuccess: (task: AbstractAssetTask) => void;
  61465. /**
  61466. * Callback called when a task had an error
  61467. */
  61468. onTaskError: (task: AbstractAssetTask) => void;
  61469. /**
  61470. * Callback called when a task is done (whatever the result is)
  61471. */
  61472. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61473. /**
  61474. * Observable called when all tasks are processed
  61475. */
  61476. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61477. /**
  61478. * Observable called when a task had an error
  61479. */
  61480. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61481. /**
  61482. * Observable called when all tasks were executed
  61483. */
  61484. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61485. /**
  61486. * Observable called when a task is done (whatever the result is)
  61487. */
  61488. onProgressObservable: Observable<IAssetsProgressEvent>;
  61489. /**
  61490. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61491. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61492. */
  61493. useDefaultLoadingScreen: boolean;
  61494. /**
  61495. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61496. * when all assets have been downloaded.
  61497. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61498. */
  61499. autoHideLoadingUI: boolean;
  61500. /**
  61501. * Creates a new AssetsManager
  61502. * @param scene defines the scene to work on
  61503. */
  61504. constructor(scene: Scene);
  61505. /**
  61506. * Add a MeshAssetTask to the list of active tasks
  61507. * @param taskName defines the name of the new task
  61508. * @param meshesNames defines the name of meshes to load
  61509. * @param rootUrl defines the root url to use to locate files
  61510. * @param sceneFilename defines the filename of the scene file
  61511. * @returns a new MeshAssetTask object
  61512. */
  61513. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61514. /**
  61515. * Add a TextFileAssetTask to the list of active tasks
  61516. * @param taskName defines the name of the new task
  61517. * @param url defines the url of the file to load
  61518. * @returns a new TextFileAssetTask object
  61519. */
  61520. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61521. /**
  61522. * Add a BinaryFileAssetTask to the list of active tasks
  61523. * @param taskName defines the name of the new task
  61524. * @param url defines the url of the file to load
  61525. * @returns a new BinaryFileAssetTask object
  61526. */
  61527. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61528. /**
  61529. * Add a ImageAssetTask to the list of active tasks
  61530. * @param taskName defines the name of the new task
  61531. * @param url defines the url of the file to load
  61532. * @returns a new ImageAssetTask object
  61533. */
  61534. addImageTask(taskName: string, url: string): ImageAssetTask;
  61535. /**
  61536. * Add a TextureAssetTask to the list of active tasks
  61537. * @param taskName defines the name of the new task
  61538. * @param url defines the url of the file to load
  61539. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61540. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61541. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61542. * @returns a new TextureAssetTask object
  61543. */
  61544. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61545. /**
  61546. * Add a CubeTextureAssetTask to the list of active tasks
  61547. * @param taskName defines the name of the new task
  61548. * @param url defines the url of the file to load
  61549. * @param extensions defines the extension to use to load the cube map (can be null)
  61550. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61551. * @param files defines the list of files to load (can be null)
  61552. * @returns a new CubeTextureAssetTask object
  61553. */
  61554. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61555. /**
  61556. *
  61557. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61558. * @param taskName defines the name of the new task
  61559. * @param url defines the url of the file to load
  61560. * @param size defines the size you want for the cubemap (can be null)
  61561. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61562. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61563. * @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)
  61564. * @param reserved Internal use only
  61565. * @returns a new HDRCubeTextureAssetTask object
  61566. */
  61567. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61568. /**
  61569. *
  61570. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61571. * @param taskName defines the name of the new task
  61572. * @param url defines the url of the file to load
  61573. * @param size defines the size you want for the cubemap (can be null)
  61574. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61575. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61576. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61577. * @returns a new EquiRectangularCubeTextureAssetTask object
  61578. */
  61579. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61580. /**
  61581. * Remove a task from the assets manager.
  61582. * @param task the task to remove
  61583. */
  61584. removeTask(task: AbstractAssetTask): void;
  61585. private _decreaseWaitingTasksCount;
  61586. private _runTask;
  61587. /**
  61588. * Reset the AssetsManager and remove all tasks
  61589. * @return the current instance of the AssetsManager
  61590. */
  61591. reset(): AssetsManager;
  61592. /**
  61593. * Start the loading process
  61594. * @return the current instance of the AssetsManager
  61595. */
  61596. load(): AssetsManager;
  61597. /**
  61598. * Start the loading process as an async operation
  61599. * @return a promise returning the list of failed tasks
  61600. */
  61601. loadAsync(): Promise<void>;
  61602. }
  61603. }
  61604. declare module "babylonjs/Misc/deferred" {
  61605. /**
  61606. * Wrapper class for promise with external resolve and reject.
  61607. */
  61608. export class Deferred<T> {
  61609. /**
  61610. * The promise associated with this deferred object.
  61611. */
  61612. readonly promise: Promise<T>;
  61613. private _resolve;
  61614. private _reject;
  61615. /**
  61616. * The resolve method of the promise associated with this deferred object.
  61617. */
  61618. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61619. /**
  61620. * The reject method of the promise associated with this deferred object.
  61621. */
  61622. readonly reject: (reason?: any) => void;
  61623. /**
  61624. * Constructor for this deferred object.
  61625. */
  61626. constructor();
  61627. }
  61628. }
  61629. declare module "babylonjs/Misc/meshExploder" {
  61630. import { Mesh } from "babylonjs/Meshes/mesh";
  61631. /**
  61632. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61633. */
  61634. export class MeshExploder {
  61635. private _centerMesh;
  61636. private _meshes;
  61637. private _meshesOrigins;
  61638. private _toCenterVectors;
  61639. private _scaledDirection;
  61640. private _newPosition;
  61641. private _centerPosition;
  61642. /**
  61643. * Explodes meshes from a center mesh.
  61644. * @param meshes The meshes to explode.
  61645. * @param centerMesh The mesh to be center of explosion.
  61646. */
  61647. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61648. private _setCenterMesh;
  61649. /**
  61650. * Get class name
  61651. * @returns "MeshExploder"
  61652. */
  61653. getClassName(): string;
  61654. /**
  61655. * "Exploded meshes"
  61656. * @returns Array of meshes with the centerMesh at index 0.
  61657. */
  61658. getMeshes(): Array<Mesh>;
  61659. /**
  61660. * Explodes meshes giving a specific direction
  61661. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61662. */
  61663. explode(direction?: number): void;
  61664. }
  61665. }
  61666. declare module "babylonjs/Misc/filesInput" {
  61667. import { Engine } from "babylonjs/Engines/engine";
  61668. import { Scene } from "babylonjs/scene";
  61669. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61670. /**
  61671. * Class used to help managing file picking and drag'n'drop
  61672. */
  61673. export class FilesInput {
  61674. /**
  61675. * List of files ready to be loaded
  61676. */
  61677. static readonly FilesToLoad: {
  61678. [key: string]: File;
  61679. };
  61680. /**
  61681. * Callback called when a file is processed
  61682. */
  61683. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61684. private _engine;
  61685. private _currentScene;
  61686. private _sceneLoadedCallback;
  61687. private _progressCallback;
  61688. private _additionalRenderLoopLogicCallback;
  61689. private _textureLoadingCallback;
  61690. private _startingProcessingFilesCallback;
  61691. private _onReloadCallback;
  61692. private _errorCallback;
  61693. private _elementToMonitor;
  61694. private _sceneFileToLoad;
  61695. private _filesToLoad;
  61696. /**
  61697. * Creates a new FilesInput
  61698. * @param engine defines the rendering engine
  61699. * @param scene defines the hosting scene
  61700. * @param sceneLoadedCallback callback called when scene is loaded
  61701. * @param progressCallback callback called to track progress
  61702. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61703. * @param textureLoadingCallback callback called when a texture is loading
  61704. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61705. * @param onReloadCallback callback called when a reload is requested
  61706. * @param errorCallback callback call if an error occurs
  61707. */
  61708. 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);
  61709. private _dragEnterHandler;
  61710. private _dragOverHandler;
  61711. private _dropHandler;
  61712. /**
  61713. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61714. * @param elementToMonitor defines the DOM element to track
  61715. */
  61716. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61717. /**
  61718. * Release all associated resources
  61719. */
  61720. dispose(): void;
  61721. private renderFunction;
  61722. private drag;
  61723. private drop;
  61724. private _traverseFolder;
  61725. private _processFiles;
  61726. /**
  61727. * Load files from a drop event
  61728. * @param event defines the drop event to use as source
  61729. */
  61730. loadFiles(event: any): void;
  61731. private _processReload;
  61732. /**
  61733. * Reload the current scene from the loaded files
  61734. */
  61735. reload(): void;
  61736. }
  61737. }
  61738. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61739. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61740. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61741. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61742. }
  61743. declare module "babylonjs/Misc/sceneOptimizer" {
  61744. import { Scene, IDisposable } from "babylonjs/scene";
  61745. import { Observable } from "babylonjs/Misc/observable";
  61746. /**
  61747. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61748. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61749. */
  61750. export class SceneOptimization {
  61751. /**
  61752. * Defines the priority of this optimization (0 by default which means first in the list)
  61753. */
  61754. priority: number;
  61755. /**
  61756. * Gets a string describing the action executed by the current optimization
  61757. * @returns description string
  61758. */
  61759. getDescription(): string;
  61760. /**
  61761. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61762. * @param scene defines the current scene where to apply this optimization
  61763. * @param optimizer defines the current optimizer
  61764. * @returns true if everything that can be done was applied
  61765. */
  61766. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61767. /**
  61768. * Creates the SceneOptimization object
  61769. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61770. * @param desc defines the description associated with the optimization
  61771. */
  61772. constructor(
  61773. /**
  61774. * Defines the priority of this optimization (0 by default which means first in the list)
  61775. */
  61776. priority?: number);
  61777. }
  61778. /**
  61779. * Defines an optimization used to reduce the size of render target textures
  61780. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61781. */
  61782. export class TextureOptimization extends SceneOptimization {
  61783. /**
  61784. * Defines the priority of this optimization (0 by default which means first in the list)
  61785. */
  61786. priority: number;
  61787. /**
  61788. * 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
  61789. */
  61790. maximumSize: number;
  61791. /**
  61792. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61793. */
  61794. step: number;
  61795. /**
  61796. * Gets a string describing the action executed by the current optimization
  61797. * @returns description string
  61798. */
  61799. getDescription(): string;
  61800. /**
  61801. * Creates the TextureOptimization object
  61802. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61803. * @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
  61804. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61805. */
  61806. constructor(
  61807. /**
  61808. * Defines the priority of this optimization (0 by default which means first in the list)
  61809. */
  61810. priority?: number,
  61811. /**
  61812. * 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
  61813. */
  61814. maximumSize?: number,
  61815. /**
  61816. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61817. */
  61818. step?: number);
  61819. /**
  61820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61821. * @param scene defines the current scene where to apply this optimization
  61822. * @param optimizer defines the current optimizer
  61823. * @returns true if everything that can be done was applied
  61824. */
  61825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61826. }
  61827. /**
  61828. * Defines an optimization used to increase or decrease the rendering resolution
  61829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61830. */
  61831. export class HardwareScalingOptimization extends SceneOptimization {
  61832. /**
  61833. * Defines the priority of this optimization (0 by default which means first in the list)
  61834. */
  61835. priority: number;
  61836. /**
  61837. * Defines the maximum scale to use (2 by default)
  61838. */
  61839. maximumScale: number;
  61840. /**
  61841. * Defines the step to use between two passes (0.5 by default)
  61842. */
  61843. step: number;
  61844. private _currentScale;
  61845. private _directionOffset;
  61846. /**
  61847. * Gets a string describing the action executed by the current optimization
  61848. * @return description string
  61849. */
  61850. getDescription(): string;
  61851. /**
  61852. * Creates the HardwareScalingOptimization object
  61853. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61854. * @param maximumScale defines the maximum scale to use (2 by default)
  61855. * @param step defines the step to use between two passes (0.5 by default)
  61856. */
  61857. constructor(
  61858. /**
  61859. * Defines the priority of this optimization (0 by default which means first in the list)
  61860. */
  61861. priority?: number,
  61862. /**
  61863. * Defines the maximum scale to use (2 by default)
  61864. */
  61865. maximumScale?: number,
  61866. /**
  61867. * Defines the step to use between two passes (0.5 by default)
  61868. */
  61869. step?: number);
  61870. /**
  61871. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61872. * @param scene defines the current scene where to apply this optimization
  61873. * @param optimizer defines the current optimizer
  61874. * @returns true if everything that can be done was applied
  61875. */
  61876. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61877. }
  61878. /**
  61879. * Defines an optimization used to remove shadows
  61880. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61881. */
  61882. export class ShadowsOptimization extends SceneOptimization {
  61883. /**
  61884. * Gets a string describing the action executed by the current optimization
  61885. * @return description string
  61886. */
  61887. getDescription(): string;
  61888. /**
  61889. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61890. * @param scene defines the current scene where to apply this optimization
  61891. * @param optimizer defines the current optimizer
  61892. * @returns true if everything that can be done was applied
  61893. */
  61894. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61895. }
  61896. /**
  61897. * Defines an optimization used to turn post-processes off
  61898. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61899. */
  61900. export class PostProcessesOptimization extends SceneOptimization {
  61901. /**
  61902. * Gets a string describing the action executed by the current optimization
  61903. * @return description string
  61904. */
  61905. getDescription(): string;
  61906. /**
  61907. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61908. * @param scene defines the current scene where to apply this optimization
  61909. * @param optimizer defines the current optimizer
  61910. * @returns true if everything that can be done was applied
  61911. */
  61912. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61913. }
  61914. /**
  61915. * Defines an optimization used to turn lens flares off
  61916. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61917. */
  61918. export class LensFlaresOptimization extends SceneOptimization {
  61919. /**
  61920. * Gets a string describing the action executed by the current optimization
  61921. * @return description string
  61922. */
  61923. getDescription(): string;
  61924. /**
  61925. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61926. * @param scene defines the current scene where to apply this optimization
  61927. * @param optimizer defines the current optimizer
  61928. * @returns true if everything that can be done was applied
  61929. */
  61930. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61931. }
  61932. /**
  61933. * Defines an optimization based on user defined callback.
  61934. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61935. */
  61936. export class CustomOptimization extends SceneOptimization {
  61937. /**
  61938. * Callback called to apply the custom optimization.
  61939. */
  61940. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61941. /**
  61942. * Callback called to get custom description
  61943. */
  61944. onGetDescription: () => string;
  61945. /**
  61946. * Gets a string describing the action executed by the current optimization
  61947. * @returns description string
  61948. */
  61949. getDescription(): string;
  61950. /**
  61951. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61952. * @param scene defines the current scene where to apply this optimization
  61953. * @param optimizer defines the current optimizer
  61954. * @returns true if everything that can be done was applied
  61955. */
  61956. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61957. }
  61958. /**
  61959. * Defines an optimization used to turn particles off
  61960. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61961. */
  61962. export class ParticlesOptimization extends SceneOptimization {
  61963. /**
  61964. * Gets a string describing the action executed by the current optimization
  61965. * @return description string
  61966. */
  61967. getDescription(): string;
  61968. /**
  61969. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61970. * @param scene defines the current scene where to apply this optimization
  61971. * @param optimizer defines the current optimizer
  61972. * @returns true if everything that can be done was applied
  61973. */
  61974. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61975. }
  61976. /**
  61977. * Defines an optimization used to turn render targets off
  61978. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61979. */
  61980. export class RenderTargetsOptimization extends SceneOptimization {
  61981. /**
  61982. * Gets a string describing the action executed by the current optimization
  61983. * @return description string
  61984. */
  61985. getDescription(): string;
  61986. /**
  61987. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61988. * @param scene defines the current scene where to apply this optimization
  61989. * @param optimizer defines the current optimizer
  61990. * @returns true if everything that can be done was applied
  61991. */
  61992. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61993. }
  61994. /**
  61995. * Defines an optimization used to merge meshes with compatible materials
  61996. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61997. */
  61998. export class MergeMeshesOptimization extends SceneOptimization {
  61999. private static _UpdateSelectionTree;
  62000. /**
  62001. * Gets or sets a boolean which defines if optimization octree has to be updated
  62002. */
  62003. /**
  62004. * Gets or sets a boolean which defines if optimization octree has to be updated
  62005. */
  62006. static UpdateSelectionTree: boolean;
  62007. /**
  62008. * Gets a string describing the action executed by the current optimization
  62009. * @return description string
  62010. */
  62011. getDescription(): string;
  62012. private _canBeMerged;
  62013. /**
  62014. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62015. * @param scene defines the current scene where to apply this optimization
  62016. * @param optimizer defines the current optimizer
  62017. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62018. * @returns true if everything that can be done was applied
  62019. */
  62020. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62021. }
  62022. /**
  62023. * Defines a list of options used by SceneOptimizer
  62024. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62025. */
  62026. export class SceneOptimizerOptions {
  62027. /**
  62028. * Defines the target frame rate to reach (60 by default)
  62029. */
  62030. targetFrameRate: number;
  62031. /**
  62032. * Defines the interval between two checkes (2000ms by default)
  62033. */
  62034. trackerDuration: number;
  62035. /**
  62036. * Gets the list of optimizations to apply
  62037. */
  62038. optimizations: SceneOptimization[];
  62039. /**
  62040. * Creates a new list of options used by SceneOptimizer
  62041. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62042. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62043. */
  62044. constructor(
  62045. /**
  62046. * Defines the target frame rate to reach (60 by default)
  62047. */
  62048. targetFrameRate?: number,
  62049. /**
  62050. * Defines the interval between two checkes (2000ms by default)
  62051. */
  62052. trackerDuration?: number);
  62053. /**
  62054. * Add a new optimization
  62055. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62056. * @returns the current SceneOptimizerOptions
  62057. */
  62058. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62059. /**
  62060. * Add a new custom optimization
  62061. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62062. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62063. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62064. * @returns the current SceneOptimizerOptions
  62065. */
  62066. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62067. /**
  62068. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62069. * @param targetFrameRate defines the target frame rate (60 by default)
  62070. * @returns a SceneOptimizerOptions object
  62071. */
  62072. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62073. /**
  62074. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62075. * @param targetFrameRate defines the target frame rate (60 by default)
  62076. * @returns a SceneOptimizerOptions object
  62077. */
  62078. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62079. /**
  62080. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62081. * @param targetFrameRate defines the target frame rate (60 by default)
  62082. * @returns a SceneOptimizerOptions object
  62083. */
  62084. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62085. }
  62086. /**
  62087. * Class used to run optimizations in order to reach a target frame rate
  62088. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62089. */
  62090. export class SceneOptimizer implements IDisposable {
  62091. private _isRunning;
  62092. private _options;
  62093. private _scene;
  62094. private _currentPriorityLevel;
  62095. private _targetFrameRate;
  62096. private _trackerDuration;
  62097. private _currentFrameRate;
  62098. private _sceneDisposeObserver;
  62099. private _improvementMode;
  62100. /**
  62101. * Defines an observable called when the optimizer reaches the target frame rate
  62102. */
  62103. onSuccessObservable: Observable<SceneOptimizer>;
  62104. /**
  62105. * Defines an observable called when the optimizer enables an optimization
  62106. */
  62107. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62108. /**
  62109. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62110. */
  62111. onFailureObservable: Observable<SceneOptimizer>;
  62112. /**
  62113. * Gets a boolean indicating if the optimizer is in improvement mode
  62114. */
  62115. readonly isInImprovementMode: boolean;
  62116. /**
  62117. * Gets the current priority level (0 at start)
  62118. */
  62119. readonly currentPriorityLevel: number;
  62120. /**
  62121. * Gets the current frame rate checked by the SceneOptimizer
  62122. */
  62123. readonly currentFrameRate: number;
  62124. /**
  62125. * Gets or sets the current target frame rate (60 by default)
  62126. */
  62127. /**
  62128. * Gets or sets the current target frame rate (60 by default)
  62129. */
  62130. targetFrameRate: number;
  62131. /**
  62132. * Gets or sets the current interval between two checks (every 2000ms by default)
  62133. */
  62134. /**
  62135. * Gets or sets the current interval between two checks (every 2000ms by default)
  62136. */
  62137. trackerDuration: number;
  62138. /**
  62139. * Gets the list of active optimizations
  62140. */
  62141. readonly optimizations: SceneOptimization[];
  62142. /**
  62143. * Creates a new SceneOptimizer
  62144. * @param scene defines the scene to work on
  62145. * @param options defines the options to use with the SceneOptimizer
  62146. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62147. * @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)
  62148. */
  62149. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62150. /**
  62151. * Stops the current optimizer
  62152. */
  62153. stop(): void;
  62154. /**
  62155. * Reset the optimizer to initial step (current priority level = 0)
  62156. */
  62157. reset(): void;
  62158. /**
  62159. * Start the optimizer. By default it will try to reach a specific framerate
  62160. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62161. */
  62162. start(): void;
  62163. private _checkCurrentState;
  62164. /**
  62165. * Release all resources
  62166. */
  62167. dispose(): void;
  62168. /**
  62169. * Helper function to create a SceneOptimizer with one single line of code
  62170. * @param scene defines the scene to work on
  62171. * @param options defines the options to use with the SceneOptimizer
  62172. * @param onSuccess defines a callback to call on success
  62173. * @param onFailure defines a callback to call on failure
  62174. * @returns the new SceneOptimizer object
  62175. */
  62176. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62177. }
  62178. }
  62179. declare module "babylonjs/Misc/sceneSerializer" {
  62180. import { Scene } from "babylonjs/scene";
  62181. /**
  62182. * Class used to serialize a scene into a string
  62183. */
  62184. export class SceneSerializer {
  62185. /**
  62186. * Clear cache used by a previous serialization
  62187. */
  62188. static ClearCache(): void;
  62189. /**
  62190. * Serialize a scene into a JSON compatible object
  62191. * @param scene defines the scene to serialize
  62192. * @returns a JSON compatible object
  62193. */
  62194. static Serialize(scene: Scene): any;
  62195. /**
  62196. * Serialize a mesh into a JSON compatible object
  62197. * @param toSerialize defines the mesh to serialize
  62198. * @param withParents defines if parents must be serialized as well
  62199. * @param withChildren defines if children must be serialized as well
  62200. * @returns a JSON compatible object
  62201. */
  62202. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62203. }
  62204. }
  62205. declare module "babylonjs/Misc/textureTools" {
  62206. import { Texture } from "babylonjs/Materials/Textures/texture";
  62207. /**
  62208. * Class used to host texture specific utilities
  62209. */
  62210. export class TextureTools {
  62211. /**
  62212. * Uses the GPU to create a copy texture rescaled at a given size
  62213. * @param texture Texture to copy from
  62214. * @param width defines the desired width
  62215. * @param height defines the desired height
  62216. * @param useBilinearMode defines if bilinear mode has to be used
  62217. * @return the generated texture
  62218. */
  62219. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62220. }
  62221. }
  62222. declare module "babylonjs/Misc/videoRecorder" {
  62223. import { Nullable } from "babylonjs/types";
  62224. import { Engine } from "babylonjs/Engines/engine";
  62225. /**
  62226. * This represents the different options available for the video capture.
  62227. */
  62228. export interface VideoRecorderOptions {
  62229. /** Defines the mime type of the video. */
  62230. mimeType: string;
  62231. /** Defines the FPS the video should be recorded at. */
  62232. fps: number;
  62233. /** Defines the chunk size for the recording data. */
  62234. recordChunckSize: number;
  62235. /** The audio tracks to attach to the recording. */
  62236. audioTracks?: MediaStreamTrack[];
  62237. }
  62238. /**
  62239. * This can help with recording videos from BabylonJS.
  62240. * This is based on the available WebRTC functionalities of the browser.
  62241. *
  62242. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62243. */
  62244. export class VideoRecorder {
  62245. private static readonly _defaultOptions;
  62246. /**
  62247. * Returns whether or not the VideoRecorder is available in your browser.
  62248. * @param engine Defines the Babylon Engine.
  62249. * @returns true if supported otherwise false.
  62250. */
  62251. static IsSupported(engine: Engine): boolean;
  62252. private readonly _options;
  62253. private _canvas;
  62254. private _mediaRecorder;
  62255. private _recordedChunks;
  62256. private _fileName;
  62257. private _resolve;
  62258. private _reject;
  62259. /**
  62260. * True when a recording is already in progress.
  62261. */
  62262. readonly isRecording: boolean;
  62263. /**
  62264. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62265. * @param engine Defines the BabylonJS Engine you wish to record.
  62266. * @param options Defines options that can be used to customize the capture.
  62267. */
  62268. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62269. /**
  62270. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62271. */
  62272. stopRecording(): void;
  62273. /**
  62274. * Starts recording the canvas for a max duration specified in parameters.
  62275. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62276. * If null no automatic download will start and you can rely on the promise to get the data back.
  62277. * @param maxDuration Defines the maximum recording time in seconds.
  62278. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62279. * @return A promise callback at the end of the recording with the video data in Blob.
  62280. */
  62281. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62282. /**
  62283. * Releases internal resources used during the recording.
  62284. */
  62285. dispose(): void;
  62286. private _handleDataAvailable;
  62287. private _handleError;
  62288. private _handleStop;
  62289. }
  62290. }
  62291. declare module "babylonjs/Misc/screenshotTools" {
  62292. import { Camera } from "babylonjs/Cameras/camera";
  62293. import { Engine } from "babylonjs/Engines/engine";
  62294. /**
  62295. * Class containing a set of static utilities functions for screenshots
  62296. */
  62297. export class ScreenshotTools {
  62298. /**
  62299. * Captures a screenshot of the current rendering
  62300. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62301. * @param engine defines the rendering engine
  62302. * @param camera defines the source camera
  62303. * @param size This parameter can be set to a single number or to an object with the
  62304. * following (optional) properties: precision, width, height. If a single number is passed,
  62305. * it will be used for both width and height. If an object is passed, the screenshot size
  62306. * will be derived from the parameters. The precision property is a multiplier allowing
  62307. * rendering at a higher or lower resolution
  62308. * @param successCallback defines the callback receives a single parameter which contains the
  62309. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62310. * src parameter of an <img> to display it
  62311. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62312. * Check your browser for supported MIME types
  62313. */
  62314. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  62315. /**
  62316. * Generates an image screenshot from the specified camera.
  62317. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62318. * @param engine The engine to use for rendering
  62319. * @param camera The camera to use for rendering
  62320. * @param size This parameter can be set to a single number or to an object with the
  62321. * following (optional) properties: precision, width, height. If a single number is passed,
  62322. * it will be used for both width and height. If an object is passed, the screenshot size
  62323. * will be derived from the parameters. The precision property is a multiplier allowing
  62324. * rendering at a higher or lower resolution
  62325. * @param successCallback The callback receives a single parameter which contains the
  62326. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62327. * src parameter of an <img> to display it
  62328. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62329. * Check your browser for supported MIME types
  62330. * @param samples Texture samples (default: 1)
  62331. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62332. * @param fileName A name for for the downloaded file.
  62333. */
  62334. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62335. }
  62336. }
  62337. declare module "babylonjs/Misc/index" {
  62338. export * from "babylonjs/Misc/andOrNotEvaluator";
  62339. export * from "babylonjs/Misc/assetsManager";
  62340. export * from "babylonjs/Misc/dds";
  62341. export * from "babylonjs/Misc/decorators";
  62342. export * from "babylonjs/Misc/deferred";
  62343. export * from "babylonjs/Misc/environmentTextureTools";
  62344. export * from "babylonjs/Misc/meshExploder";
  62345. export * from "babylonjs/Misc/filesInput";
  62346. export * from "babylonjs/Misc/HighDynamicRange/index";
  62347. export * from "babylonjs/Misc/khronosTextureContainer";
  62348. export * from "babylonjs/Misc/observable";
  62349. export * from "babylonjs/Misc/performanceMonitor";
  62350. export * from "babylonjs/Misc/promise";
  62351. export * from "babylonjs/Misc/sceneOptimizer";
  62352. export * from "babylonjs/Misc/sceneSerializer";
  62353. export * from "babylonjs/Misc/smartArray";
  62354. export * from "babylonjs/Misc/stringDictionary";
  62355. export * from "babylonjs/Misc/tags";
  62356. export * from "babylonjs/Misc/textureTools";
  62357. export * from "babylonjs/Misc/tga";
  62358. export * from "babylonjs/Misc/tools";
  62359. export * from "babylonjs/Misc/videoRecorder";
  62360. export * from "babylonjs/Misc/virtualJoystick";
  62361. export * from "babylonjs/Misc/workerPool";
  62362. export * from "babylonjs/Misc/logger";
  62363. export * from "babylonjs/Misc/typeStore";
  62364. export * from "babylonjs/Misc/filesInputStore";
  62365. export * from "babylonjs/Misc/deepCopier";
  62366. export * from "babylonjs/Misc/pivotTools";
  62367. export * from "babylonjs/Misc/precisionDate";
  62368. export * from "babylonjs/Misc/screenshotTools";
  62369. export * from "babylonjs/Misc/typeStore";
  62370. export * from "babylonjs/Misc/webRequest";
  62371. export * from "babylonjs/Misc/iInspectable";
  62372. export * from "babylonjs/Misc/brdfTextureTools";
  62373. }
  62374. declare module "babylonjs/index" {
  62375. export * from "babylonjs/abstractScene";
  62376. export * from "babylonjs/Actions/index";
  62377. export * from "babylonjs/Animations/index";
  62378. export * from "babylonjs/assetContainer";
  62379. export * from "babylonjs/Audio/index";
  62380. export * from "babylonjs/Behaviors/index";
  62381. export * from "babylonjs/Bones/index";
  62382. export * from "babylonjs/Cameras/index";
  62383. export * from "babylonjs/Collisions/index";
  62384. export * from "babylonjs/Culling/index";
  62385. export * from "babylonjs/Debug/index";
  62386. export * from "babylonjs/Engines/index";
  62387. export * from "babylonjs/Events/index";
  62388. export * from "babylonjs/Gamepads/index";
  62389. export * from "babylonjs/Gizmos/index";
  62390. export * from "babylonjs/Helpers/index";
  62391. export * from "babylonjs/Instrumentation/index";
  62392. export * from "babylonjs/Layers/index";
  62393. export * from "babylonjs/LensFlares/index";
  62394. export * from "babylonjs/Lights/index";
  62395. export * from "babylonjs/Loading/index";
  62396. export * from "babylonjs/Materials/index";
  62397. export * from "babylonjs/Maths/index";
  62398. export * from "babylonjs/Meshes/index";
  62399. export * from "babylonjs/Morph/index";
  62400. export * from "babylonjs/node";
  62401. export * from "babylonjs/Offline/index";
  62402. export * from "babylonjs/Particles/index";
  62403. export * from "babylonjs/Physics/index";
  62404. export * from "babylonjs/PostProcesses/index";
  62405. export * from "babylonjs/Probes/index";
  62406. export * from "babylonjs/Rendering/index";
  62407. export * from "babylonjs/scene";
  62408. export * from "babylonjs/sceneComponent";
  62409. export * from "babylonjs/Sprites/index";
  62410. export * from "babylonjs/States/index";
  62411. export * from "babylonjs/Misc/index";
  62412. export * from "babylonjs/types";
  62413. }
  62414. declare module "babylonjs/Animations/pathCursor" {
  62415. import { Path2, Vector3 } from "babylonjs/Maths/math";
  62416. /**
  62417. * A cursor which tracks a point on a path
  62418. */
  62419. export class PathCursor {
  62420. private path;
  62421. /**
  62422. * Stores path cursor callbacks for when an onchange event is triggered
  62423. */
  62424. private _onchange;
  62425. /**
  62426. * The value of the path cursor
  62427. */
  62428. value: number;
  62429. /**
  62430. * The animation array of the path cursor
  62431. */
  62432. animations: Animation[];
  62433. /**
  62434. * Initializes the path cursor
  62435. * @param path The path to track
  62436. */
  62437. constructor(path: Path2);
  62438. /**
  62439. * Gets the cursor point on the path
  62440. * @returns A point on the path cursor at the cursor location
  62441. */
  62442. getPoint(): Vector3;
  62443. /**
  62444. * Moves the cursor ahead by the step amount
  62445. * @param step The amount to move the cursor forward
  62446. * @returns This path cursor
  62447. */
  62448. moveAhead(step?: number): PathCursor;
  62449. /**
  62450. * Moves the cursor behind by the step amount
  62451. * @param step The amount to move the cursor back
  62452. * @returns This path cursor
  62453. */
  62454. moveBack(step?: number): PathCursor;
  62455. /**
  62456. * Moves the cursor by the step amount
  62457. * If the step amount is greater than one, an exception is thrown
  62458. * @param step The amount to move the cursor
  62459. * @returns This path cursor
  62460. */
  62461. move(step: number): PathCursor;
  62462. /**
  62463. * Ensures that the value is limited between zero and one
  62464. * @returns This path cursor
  62465. */
  62466. private ensureLimits;
  62467. /**
  62468. * Runs onchange callbacks on change (used by the animation engine)
  62469. * @returns This path cursor
  62470. */
  62471. private raiseOnChange;
  62472. /**
  62473. * Executes a function on change
  62474. * @param f A path cursor onchange callback
  62475. * @returns This path cursor
  62476. */
  62477. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62478. }
  62479. }
  62480. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  62481. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  62482. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  62483. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  62484. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  62485. }
  62486. declare module "babylonjs/Engines/Processors/Expressions/index" {
  62487. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  62488. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  62489. }
  62490. declare module "babylonjs/Engines/Processors/index" {
  62491. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  62492. export * from "babylonjs/Engines/Processors/Expressions/index";
  62493. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  62494. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  62495. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  62496. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  62497. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  62498. export * from "babylonjs/Engines/Processors/shaderProcessor";
  62499. }
  62500. declare module "babylonjs/Legacy/legacy" {
  62501. import * as Babylon from "babylonjs/index";
  62502. export * from "babylonjs/index";
  62503. }
  62504. declare module "babylonjs/Shaders/blur.fragment" {
  62505. /** @hidden */
  62506. export var blurPixelShader: {
  62507. name: string;
  62508. shader: string;
  62509. };
  62510. }
  62511. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  62512. /** @hidden */
  62513. export var pointCloudVertexDeclaration: {
  62514. name: string;
  62515. shader: string;
  62516. };
  62517. }
  62518. // Mixins
  62519. interface Window {
  62520. mozIndexedDB: IDBFactory;
  62521. webkitIndexedDB: IDBFactory;
  62522. msIndexedDB: IDBFactory;
  62523. webkitURL: typeof URL;
  62524. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62525. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62526. WebGLRenderingContext: WebGLRenderingContext;
  62527. MSGesture: MSGesture;
  62528. CANNON: any;
  62529. AudioContext: AudioContext;
  62530. webkitAudioContext: AudioContext;
  62531. PointerEvent: any;
  62532. Math: Math;
  62533. Uint8Array: Uint8ArrayConstructor;
  62534. Float32Array: Float32ArrayConstructor;
  62535. mozURL: typeof URL;
  62536. msURL: typeof URL;
  62537. VRFrameData: any; // WebVR, from specs 1.1
  62538. DracoDecoderModule: any;
  62539. setImmediate(handler: (...args: any[]) => void): number;
  62540. }
  62541. interface HTMLCanvasElement {
  62542. requestPointerLock(): void;
  62543. msRequestPointerLock?(): void;
  62544. mozRequestPointerLock?(): void;
  62545. webkitRequestPointerLock?(): void;
  62546. /** Track wether a record is in progress */
  62547. isRecording: boolean;
  62548. /** Capture Stream method defined by some browsers */
  62549. captureStream(fps?: number): MediaStream;
  62550. }
  62551. interface CanvasRenderingContext2D {
  62552. msImageSmoothingEnabled: boolean;
  62553. }
  62554. interface MouseEvent {
  62555. mozMovementX: number;
  62556. mozMovementY: number;
  62557. webkitMovementX: number;
  62558. webkitMovementY: number;
  62559. msMovementX: number;
  62560. msMovementY: number;
  62561. }
  62562. interface Navigator {
  62563. mozGetVRDevices: (any: any) => any;
  62564. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62565. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62566. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62567. webkitGetGamepads(): Gamepad[];
  62568. msGetGamepads(): Gamepad[];
  62569. webkitGamepads(): Gamepad[];
  62570. }
  62571. interface HTMLVideoElement {
  62572. mozSrcObject: any;
  62573. }
  62574. interface Math {
  62575. fround(x: number): number;
  62576. imul(a: number, b: number): number;
  62577. }
  62578. interface WebGLRenderingContext {
  62579. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62580. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62581. vertexAttribDivisor(index: number, divisor: number): void;
  62582. createVertexArray(): any;
  62583. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62584. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62585. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62586. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62587. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62588. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62589. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62590. // Queries
  62591. createQuery(): WebGLQuery;
  62592. deleteQuery(query: WebGLQuery): void;
  62593. beginQuery(target: number, query: WebGLQuery): void;
  62594. endQuery(target: number): void;
  62595. getQueryParameter(query: WebGLQuery, pname: number): any;
  62596. getQuery(target: number, pname: number): any;
  62597. MAX_SAMPLES: number;
  62598. RGBA8: number;
  62599. READ_FRAMEBUFFER: number;
  62600. DRAW_FRAMEBUFFER: number;
  62601. UNIFORM_BUFFER: number;
  62602. HALF_FLOAT_OES: number;
  62603. RGBA16F: number;
  62604. RGBA32F: number;
  62605. R32F: number;
  62606. RG32F: number;
  62607. RGB32F: number;
  62608. R16F: number;
  62609. RG16F: number;
  62610. RGB16F: number;
  62611. RED: number;
  62612. RG: number;
  62613. R8: number;
  62614. RG8: number;
  62615. UNSIGNED_INT_24_8: number;
  62616. DEPTH24_STENCIL8: number;
  62617. /* Multiple Render Targets */
  62618. drawBuffers(buffers: number[]): void;
  62619. readBuffer(src: number): void;
  62620. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62621. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62622. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62623. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62624. // Occlusion Query
  62625. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62626. ANY_SAMPLES_PASSED: number;
  62627. QUERY_RESULT_AVAILABLE: number;
  62628. QUERY_RESULT: number;
  62629. }
  62630. interface WebGLProgram {
  62631. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62632. }
  62633. interface EXT_disjoint_timer_query {
  62634. QUERY_COUNTER_BITS_EXT: number;
  62635. TIME_ELAPSED_EXT: number;
  62636. TIMESTAMP_EXT: number;
  62637. GPU_DISJOINT_EXT: number;
  62638. QUERY_RESULT_EXT: number;
  62639. QUERY_RESULT_AVAILABLE_EXT: number;
  62640. queryCounterEXT(query: WebGLQuery, target: number): void;
  62641. createQueryEXT(): WebGLQuery;
  62642. beginQueryEXT(target: number, query: WebGLQuery): void;
  62643. endQueryEXT(target: number): void;
  62644. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62645. deleteQueryEXT(query: WebGLQuery): void;
  62646. }
  62647. interface WebGLUniformLocation {
  62648. _currentState: any;
  62649. }
  62650. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62651. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62652. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62653. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62654. interface WebGLRenderingContext {
  62655. readonly RASTERIZER_DISCARD: number;
  62656. readonly DEPTH_COMPONENT24: number;
  62657. readonly TEXTURE_3D: number;
  62658. readonly TEXTURE_2D_ARRAY: number;
  62659. readonly TEXTURE_COMPARE_FUNC: number;
  62660. readonly TEXTURE_COMPARE_MODE: number;
  62661. readonly COMPARE_REF_TO_TEXTURE: number;
  62662. readonly TEXTURE_WRAP_R: number;
  62663. readonly HALF_FLOAT: number;
  62664. readonly RGB8: number;
  62665. readonly RED_INTEGER: number;
  62666. readonly RG_INTEGER: number;
  62667. readonly RGB_INTEGER: number;
  62668. readonly RGBA_INTEGER: number;
  62669. readonly R8_SNORM: number;
  62670. readonly RG8_SNORM: number;
  62671. readonly RGB8_SNORM: number;
  62672. readonly RGBA8_SNORM: number;
  62673. readonly R8I: number;
  62674. readonly RG8I: number;
  62675. readonly RGB8I: number;
  62676. readonly RGBA8I: number;
  62677. readonly R8UI: number;
  62678. readonly RG8UI: number;
  62679. readonly RGB8UI: number;
  62680. readonly RGBA8UI: number;
  62681. readonly R16I: number;
  62682. readonly RG16I: number;
  62683. readonly RGB16I: number;
  62684. readonly RGBA16I: number;
  62685. readonly R16UI: number;
  62686. readonly RG16UI: number;
  62687. readonly RGB16UI: number;
  62688. readonly RGBA16UI: number;
  62689. readonly R32I: number;
  62690. readonly RG32I: number;
  62691. readonly RGB32I: number;
  62692. readonly RGBA32I: number;
  62693. readonly R32UI: number;
  62694. readonly RG32UI: number;
  62695. readonly RGB32UI: number;
  62696. readonly RGBA32UI: number;
  62697. readonly RGB10_A2UI: number;
  62698. readonly R11F_G11F_B10F: number;
  62699. readonly RGB9_E5: number;
  62700. readonly RGB10_A2: number;
  62701. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62702. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62703. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62704. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62705. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62706. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62707. 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;
  62708. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62709. readonly TRANSFORM_FEEDBACK: number;
  62710. readonly INTERLEAVED_ATTRIBS: number;
  62711. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62712. createTransformFeedback(): WebGLTransformFeedback;
  62713. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62714. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62715. beginTransformFeedback(primitiveMode: number): void;
  62716. endTransformFeedback(): void;
  62717. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62718. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62719. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62720. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62721. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62722. }
  62723. interface ImageBitmap {
  62724. readonly width: number;
  62725. readonly height: number;
  62726. close(): void;
  62727. }
  62728. interface WebGLQuery extends WebGLObject {
  62729. }
  62730. declare var WebGLQuery: {
  62731. prototype: WebGLQuery;
  62732. new(): WebGLQuery;
  62733. };
  62734. interface WebGLSampler extends WebGLObject {
  62735. }
  62736. declare var WebGLSampler: {
  62737. prototype: WebGLSampler;
  62738. new(): WebGLSampler;
  62739. };
  62740. interface WebGLSync extends WebGLObject {
  62741. }
  62742. declare var WebGLSync: {
  62743. prototype: WebGLSync;
  62744. new(): WebGLSync;
  62745. };
  62746. interface WebGLTransformFeedback extends WebGLObject {
  62747. }
  62748. declare var WebGLTransformFeedback: {
  62749. prototype: WebGLTransformFeedback;
  62750. new(): WebGLTransformFeedback;
  62751. };
  62752. interface WebGLVertexArrayObject extends WebGLObject {
  62753. }
  62754. declare var WebGLVertexArrayObject: {
  62755. prototype: WebGLVertexArrayObject;
  62756. new(): WebGLVertexArrayObject;
  62757. };
  62758. // Type definitions for WebVR API
  62759. // Project: https://w3c.github.io/webvr/
  62760. // Definitions by: six a <https://github.com/lostfictions>
  62761. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62762. interface VRDisplay extends EventTarget {
  62763. /**
  62764. * Dictionary of capabilities describing the VRDisplay.
  62765. */
  62766. readonly capabilities: VRDisplayCapabilities;
  62767. /**
  62768. * z-depth defining the far plane of the eye view frustum
  62769. * enables mapping of values in the render target depth
  62770. * attachment to scene coordinates. Initially set to 10000.0.
  62771. */
  62772. depthFar: number;
  62773. /**
  62774. * z-depth defining the near plane of the eye view frustum
  62775. * enables mapping of values in the render target depth
  62776. * attachment to scene coordinates. Initially set to 0.01.
  62777. */
  62778. depthNear: number;
  62779. /**
  62780. * An identifier for this distinct VRDisplay. Used as an
  62781. * association point in the Gamepad API.
  62782. */
  62783. readonly displayId: number;
  62784. /**
  62785. * A display name, a user-readable name identifying it.
  62786. */
  62787. readonly displayName: string;
  62788. readonly isConnected: boolean;
  62789. readonly isPresenting: boolean;
  62790. /**
  62791. * If this VRDisplay supports room-scale experiences, the optional
  62792. * stage attribute contains details on the room-scale parameters.
  62793. */
  62794. readonly stageParameters: VRStageParameters | null;
  62795. /**
  62796. * Passing the value returned by `requestAnimationFrame` to
  62797. * `cancelAnimationFrame` will unregister the callback.
  62798. * @param handle Define the hanle of the request to cancel
  62799. */
  62800. cancelAnimationFrame(handle: number): void;
  62801. /**
  62802. * Stops presenting to the VRDisplay.
  62803. * @returns a promise to know when it stopped
  62804. */
  62805. exitPresent(): Promise<void>;
  62806. /**
  62807. * Return the current VREyeParameters for the given eye.
  62808. * @param whichEye Define the eye we want the parameter for
  62809. * @returns the eye parameters
  62810. */
  62811. getEyeParameters(whichEye: string): VREyeParameters;
  62812. /**
  62813. * Populates the passed VRFrameData with the information required to render
  62814. * the current frame.
  62815. * @param frameData Define the data structure to populate
  62816. * @returns true if ok otherwise false
  62817. */
  62818. getFrameData(frameData: VRFrameData): boolean;
  62819. /**
  62820. * Get the layers currently being presented.
  62821. * @returns the list of VR layers
  62822. */
  62823. getLayers(): VRLayer[];
  62824. /**
  62825. * Return a VRPose containing the future predicted pose of the VRDisplay
  62826. * when the current frame will be presented. The value returned will not
  62827. * change until JavaScript has returned control to the browser.
  62828. *
  62829. * The VRPose will contain the position, orientation, velocity,
  62830. * and acceleration of each of these properties.
  62831. * @returns the pose object
  62832. */
  62833. getPose(): VRPose;
  62834. /**
  62835. * Return the current instantaneous pose of the VRDisplay, with no
  62836. * prediction applied.
  62837. * @returns the current instantaneous pose
  62838. */
  62839. getImmediatePose(): VRPose;
  62840. /**
  62841. * The callback passed to `requestAnimationFrame` will be called
  62842. * any time a new frame should be rendered. When the VRDisplay is
  62843. * presenting the callback will be called at the native refresh
  62844. * rate of the HMD. When not presenting this function acts
  62845. * identically to how window.requestAnimationFrame acts. Content should
  62846. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62847. * asynchronously from other displays and at differing refresh rates.
  62848. * @param callback Define the eaction to run next frame
  62849. * @returns the request handle it
  62850. */
  62851. requestAnimationFrame(callback: FrameRequestCallback): number;
  62852. /**
  62853. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62854. * Repeat calls while already presenting will update the VRLayers being displayed.
  62855. * @param layers Define the list of layer to present
  62856. * @returns a promise to know when the request has been fulfilled
  62857. */
  62858. requestPresent(layers: VRLayer[]): Promise<void>;
  62859. /**
  62860. * Reset the pose for this display, treating its current position and
  62861. * orientation as the "origin/zero" values. VRPose.position,
  62862. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62863. * updated when calling resetPose(). This should be called in only
  62864. * sitting-space experiences.
  62865. */
  62866. resetPose(): void;
  62867. /**
  62868. * The VRLayer provided to the VRDisplay will be captured and presented
  62869. * in the HMD. Calling this function has the same effect on the source
  62870. * canvas as any other operation that uses its source image, and canvases
  62871. * created without preserveDrawingBuffer set to true will be cleared.
  62872. * @param pose Define the pose to submit
  62873. */
  62874. submitFrame(pose?: VRPose): void;
  62875. }
  62876. declare var VRDisplay: {
  62877. prototype: VRDisplay;
  62878. new(): VRDisplay;
  62879. };
  62880. interface VRLayer {
  62881. leftBounds?: number[] | Float32Array | null;
  62882. rightBounds?: number[] | Float32Array | null;
  62883. source?: HTMLCanvasElement | null;
  62884. }
  62885. interface VRDisplayCapabilities {
  62886. readonly canPresent: boolean;
  62887. readonly hasExternalDisplay: boolean;
  62888. readonly hasOrientation: boolean;
  62889. readonly hasPosition: boolean;
  62890. readonly maxLayers: number;
  62891. }
  62892. interface VREyeParameters {
  62893. /** @deprecated */
  62894. readonly fieldOfView: VRFieldOfView;
  62895. readonly offset: Float32Array;
  62896. readonly renderHeight: number;
  62897. readonly renderWidth: number;
  62898. }
  62899. interface VRFieldOfView {
  62900. readonly downDegrees: number;
  62901. readonly leftDegrees: number;
  62902. readonly rightDegrees: number;
  62903. readonly upDegrees: number;
  62904. }
  62905. interface VRFrameData {
  62906. readonly leftProjectionMatrix: Float32Array;
  62907. readonly leftViewMatrix: Float32Array;
  62908. readonly pose: VRPose;
  62909. readonly rightProjectionMatrix: Float32Array;
  62910. readonly rightViewMatrix: Float32Array;
  62911. readonly timestamp: number;
  62912. }
  62913. interface VRPose {
  62914. readonly angularAcceleration: Float32Array | null;
  62915. readonly angularVelocity: Float32Array | null;
  62916. readonly linearAcceleration: Float32Array | null;
  62917. readonly linearVelocity: Float32Array | null;
  62918. readonly orientation: Float32Array | null;
  62919. readonly position: Float32Array | null;
  62920. readonly timestamp: number;
  62921. }
  62922. interface VRStageParameters {
  62923. sittingToStandingTransform?: Float32Array;
  62924. sizeX?: number;
  62925. sizeY?: number;
  62926. }
  62927. interface Navigator {
  62928. getVRDisplays(): Promise<VRDisplay[]>;
  62929. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62930. }
  62931. interface Window {
  62932. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62933. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62934. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62935. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62936. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62937. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62938. }
  62939. interface Gamepad {
  62940. readonly displayId: number;
  62941. }
  62942. interface XRDevice {
  62943. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  62944. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  62945. }
  62946. interface XRSession {
  62947. getInputSources(): Array<any>;
  62948. baseLayer: XRWebGLLayer;
  62949. requestFrameOfReference(type: string): Promise<void>;
  62950. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  62951. end(): Promise<void>;
  62952. requestAnimationFrame: Function;
  62953. addEventListener: Function;
  62954. }
  62955. interface XRSessionCreationOptions {
  62956. outputContext?: WebGLRenderingContext | null;
  62957. immersive?: boolean;
  62958. environmentIntegration?: boolean;
  62959. }
  62960. interface XRLayer {
  62961. getViewport: Function;
  62962. framebufferWidth: number;
  62963. framebufferHeight: number;
  62964. }
  62965. interface XRView {
  62966. projectionMatrix: Float32Array;
  62967. }
  62968. interface XRFrame {
  62969. getDevicePose: Function;
  62970. getInputPose: Function;
  62971. views: Array<XRView>;
  62972. baseLayer: XRLayer;
  62973. }
  62974. interface XRFrameOfReference {
  62975. }
  62976. interface XRWebGLLayer extends XRLayer {
  62977. framebuffer: WebGLFramebuffer;
  62978. }
  62979. declare var XRWebGLLayer: {
  62980. prototype: XRWebGLLayer;
  62981. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  62982. };
  62983. declare module "babylonjs" {
  62984. export * from "babylonjs/Legacy/legacy";
  62985. }
  62986. declare module BABYLON {
  62987. /** Alias type for value that can be null */
  62988. export type Nullable<T> = T | null;
  62989. /**
  62990. * Alias type for number that are floats
  62991. * @ignorenaming
  62992. */
  62993. export type float = number;
  62994. /**
  62995. * Alias type for number that are doubles.
  62996. * @ignorenaming
  62997. */
  62998. export type double = number;
  62999. /**
  63000. * Alias type for number that are integer
  63001. * @ignorenaming
  63002. */
  63003. export type int = number;
  63004. /** Alias type for number array or Float32Array */
  63005. export type FloatArray = number[] | Float32Array;
  63006. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  63007. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  63008. /**
  63009. * Alias for types that can be used by a Buffer or VertexBuffer.
  63010. */
  63011. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  63012. /**
  63013. * Alias type for primitive types
  63014. * @ignorenaming
  63015. */
  63016. type Primitive = undefined | null | boolean | string | number | Function;
  63017. /**
  63018. * Type modifier to make all the properties of an object Readonly
  63019. */
  63020. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  63021. /**
  63022. * Type modifier to make all the properties of an object Readonly recursively
  63023. */
  63024. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  63025. /** @hidden */
  63026. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  63027. }
  63028. /** @hidden */
  63029. /** @hidden */
  63030. type DeepImmutableObject<T> = {
  63031. readonly [K in keyof T]: DeepImmutable<T[K]>;
  63032. };
  63033. }
  63034. declare module BABYLON {
  63035. /**
  63036. * Class containing a set of static utilities functions for arrays.
  63037. */
  63038. export class ArrayTools {
  63039. /**
  63040. * Returns an array of the given size filled with element built from the given constructor and the paramters
  63041. * @param size the number of element to construct and put in the array
  63042. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  63043. * @returns a new array filled with new objects
  63044. */
  63045. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  63046. }
  63047. }
  63048. declare module BABYLON {
  63049. /**
  63050. * Scalar computation library
  63051. */
  63052. export class Scalar {
  63053. /**
  63054. * Two pi constants convenient for computation.
  63055. */
  63056. static TwoPi: number;
  63057. /**
  63058. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  63059. * @param a number
  63060. * @param b number
  63061. * @param epsilon (default = 1.401298E-45)
  63062. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  63063. */
  63064. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  63065. /**
  63066. * Returns a string : the upper case translation of the number i to hexadecimal.
  63067. * @param i number
  63068. * @returns the upper case translation of the number i to hexadecimal.
  63069. */
  63070. static ToHex(i: number): string;
  63071. /**
  63072. * Returns -1 if value is negative and +1 is value is positive.
  63073. * @param value the value
  63074. * @returns the value itself if it's equal to zero.
  63075. */
  63076. static Sign(value: number): number;
  63077. /**
  63078. * Returns the value itself if it's between min and max.
  63079. * Returns min if the value is lower than min.
  63080. * Returns max if the value is greater than max.
  63081. * @param value the value to clmap
  63082. * @param min the min value to clamp to (default: 0)
  63083. * @param max the max value to clamp to (default: 1)
  63084. * @returns the clamped value
  63085. */
  63086. static Clamp(value: number, min?: number, max?: number): number;
  63087. /**
  63088. * the log2 of value.
  63089. * @param value the value to compute log2 of
  63090. * @returns the log2 of value.
  63091. */
  63092. static Log2(value: number): number;
  63093. /**
  63094. * Loops the value, so that it is never larger than length and never smaller than 0.
  63095. *
  63096. * This is similar to the modulo operator but it works with floating point numbers.
  63097. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  63098. * With t = 5 and length = 2.5, the result would be 0.0.
  63099. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  63100. * @param value the value
  63101. * @param length the length
  63102. * @returns the looped value
  63103. */
  63104. static Repeat(value: number, length: number): number;
  63105. /**
  63106. * Normalize the value between 0.0 and 1.0 using min and max values
  63107. * @param value value to normalize
  63108. * @param min max to normalize between
  63109. * @param max min to normalize between
  63110. * @returns the normalized value
  63111. */
  63112. static Normalize(value: number, min: number, max: number): number;
  63113. /**
  63114. * Denormalize the value from 0.0 and 1.0 using min and max values
  63115. * @param normalized value to denormalize
  63116. * @param min max to denormalize between
  63117. * @param max min to denormalize between
  63118. * @returns the denormalized value
  63119. */
  63120. static Denormalize(normalized: number, min: number, max: number): number;
  63121. /**
  63122. * Calculates the shortest difference between two given angles given in degrees.
  63123. * @param current current angle in degrees
  63124. * @param target target angle in degrees
  63125. * @returns the delta
  63126. */
  63127. static DeltaAngle(current: number, target: number): number;
  63128. /**
  63129. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  63130. * @param tx value
  63131. * @param length length
  63132. * @returns The returned value will move back and forth between 0 and length
  63133. */
  63134. static PingPong(tx: number, length: number): number;
  63135. /**
  63136. * Interpolates between min and max with smoothing at the limits.
  63137. *
  63138. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  63139. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  63140. * @param from from
  63141. * @param to to
  63142. * @param tx value
  63143. * @returns the smooth stepped value
  63144. */
  63145. static SmoothStep(from: number, to: number, tx: number): number;
  63146. /**
  63147. * Moves a value current towards target.
  63148. *
  63149. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  63150. * Negative values of maxDelta pushes the value away from target.
  63151. * @param current current value
  63152. * @param target target value
  63153. * @param maxDelta max distance to move
  63154. * @returns resulting value
  63155. */
  63156. static MoveTowards(current: number, target: number, maxDelta: number): number;
  63157. /**
  63158. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  63159. *
  63160. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  63161. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  63162. * @param current current value
  63163. * @param target target value
  63164. * @param maxDelta max distance to move
  63165. * @returns resulting angle
  63166. */
  63167. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  63168. /**
  63169. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  63170. * @param start start value
  63171. * @param end target value
  63172. * @param amount amount to lerp between
  63173. * @returns the lerped value
  63174. */
  63175. static Lerp(start: number, end: number, amount: number): number;
  63176. /**
  63177. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  63178. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  63179. * @param start start value
  63180. * @param end target value
  63181. * @param amount amount to lerp between
  63182. * @returns the lerped value
  63183. */
  63184. static LerpAngle(start: number, end: number, amount: number): number;
  63185. /**
  63186. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  63187. * @param a start value
  63188. * @param b target value
  63189. * @param value value between a and b
  63190. * @returns the inverseLerp value
  63191. */
  63192. static InverseLerp(a: number, b: number, value: number): number;
  63193. /**
  63194. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  63195. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  63196. * @param value1 spline value
  63197. * @param tangent1 spline value
  63198. * @param value2 spline value
  63199. * @param tangent2 spline value
  63200. * @param amount input value
  63201. * @returns hermite result
  63202. */
  63203. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  63204. /**
  63205. * Returns a random float number between and min and max values
  63206. * @param min min value of random
  63207. * @param max max value of random
  63208. * @returns random value
  63209. */
  63210. static RandomRange(min: number, max: number): number;
  63211. /**
  63212. * This function returns percentage of a number in a given range.
  63213. *
  63214. * RangeToPercent(40,20,60) will return 0.5 (50%)
  63215. * RangeToPercent(34,0,100) will return 0.34 (34%)
  63216. * @param number to convert to percentage
  63217. * @param min min range
  63218. * @param max max range
  63219. * @returns the percentage
  63220. */
  63221. static RangeToPercent(number: number, min: number, max: number): number;
  63222. /**
  63223. * This function returns number that corresponds to the percentage in a given range.
  63224. *
  63225. * PercentToRange(0.34,0,100) will return 34.
  63226. * @param percent to convert to number
  63227. * @param min min range
  63228. * @param max max range
  63229. * @returns the number
  63230. */
  63231. static PercentToRange(percent: number, min: number, max: number): number;
  63232. /**
  63233. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  63234. * @param angle The angle to normalize in radian.
  63235. * @return The converted angle.
  63236. */
  63237. static NormalizeRadians(angle: number): number;
  63238. }
  63239. }
  63240. declare module BABYLON {
  63241. /**
  63242. * Constant used to convert a value to gamma space
  63243. * @ignorenaming
  63244. */
  63245. export const ToGammaSpace: number;
  63246. /**
  63247. * Constant used to convert a value to linear space
  63248. * @ignorenaming
  63249. */
  63250. export const ToLinearSpace = 2.2;
  63251. /**
  63252. * Constant used to define the minimal number value in Babylon.js
  63253. * @ignorenaming
  63254. */
  63255. let Epsilon: number;
  63256. /**
  63257. * Class used to hold a RBG color
  63258. */
  63259. export class Color3 {
  63260. /**
  63261. * Defines the red component (between 0 and 1, default is 0)
  63262. */
  63263. r: number;
  63264. /**
  63265. * Defines the green component (between 0 and 1, default is 0)
  63266. */
  63267. g: number;
  63268. /**
  63269. * Defines the blue component (between 0 and 1, default is 0)
  63270. */
  63271. b: number;
  63272. /**
  63273. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  63274. * @param r defines the red component (between 0 and 1, default is 0)
  63275. * @param g defines the green component (between 0 and 1, default is 0)
  63276. * @param b defines the blue component (between 0 and 1, default is 0)
  63277. */
  63278. constructor(
  63279. /**
  63280. * Defines the red component (between 0 and 1, default is 0)
  63281. */
  63282. r?: number,
  63283. /**
  63284. * Defines the green component (between 0 and 1, default is 0)
  63285. */
  63286. g?: number,
  63287. /**
  63288. * Defines the blue component (between 0 and 1, default is 0)
  63289. */
  63290. b?: number);
  63291. /**
  63292. * Creates a string with the Color3 current values
  63293. * @returns the string representation of the Color3 object
  63294. */
  63295. toString(): string;
  63296. /**
  63297. * Returns the string "Color3"
  63298. * @returns "Color3"
  63299. */
  63300. getClassName(): string;
  63301. /**
  63302. * Compute the Color3 hash code
  63303. * @returns an unique number that can be used to hash Color3 objects
  63304. */
  63305. getHashCode(): number;
  63306. /**
  63307. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  63308. * @param array defines the array where to store the r,g,b components
  63309. * @param index defines an optional index in the target array to define where to start storing values
  63310. * @returns the current Color3 object
  63311. */
  63312. toArray(array: FloatArray, index?: number): Color3;
  63313. /**
  63314. * Returns a new Color4 object from the current Color3 and the given alpha
  63315. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  63316. * @returns a new Color4 object
  63317. */
  63318. toColor4(alpha?: number): Color4;
  63319. /**
  63320. * Returns a new array populated with 3 numeric elements : red, green and blue values
  63321. * @returns the new array
  63322. */
  63323. asArray(): number[];
  63324. /**
  63325. * Returns the luminance value
  63326. * @returns a float value
  63327. */
  63328. toLuminance(): number;
  63329. /**
  63330. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  63331. * @param otherColor defines the second operand
  63332. * @returns the new Color3 object
  63333. */
  63334. multiply(otherColor: DeepImmutable<Color3>): Color3;
  63335. /**
  63336. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  63337. * @param otherColor defines the second operand
  63338. * @param result defines the Color3 object where to store the result
  63339. * @returns the current Color3
  63340. */
  63341. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63342. /**
  63343. * Determines equality between Color3 objects
  63344. * @param otherColor defines the second operand
  63345. * @returns true if the rgb values are equal to the given ones
  63346. */
  63347. equals(otherColor: DeepImmutable<Color3>): boolean;
  63348. /**
  63349. * Determines equality between the current Color3 object and a set of r,b,g values
  63350. * @param r defines the red component to check
  63351. * @param g defines the green component to check
  63352. * @param b defines the blue component to check
  63353. * @returns true if the rgb values are equal to the given ones
  63354. */
  63355. equalsFloats(r: number, g: number, b: number): boolean;
  63356. /**
  63357. * Multiplies in place each rgb value by scale
  63358. * @param scale defines the scaling factor
  63359. * @returns the updated Color3
  63360. */
  63361. scale(scale: number): Color3;
  63362. /**
  63363. * Multiplies the rgb values by scale and stores the result into "result"
  63364. * @param scale defines the scaling factor
  63365. * @param result defines the Color3 object where to store the result
  63366. * @returns the unmodified current Color3
  63367. */
  63368. scaleToRef(scale: number, result: Color3): Color3;
  63369. /**
  63370. * Scale the current Color3 values by a factor and add the result to a given Color3
  63371. * @param scale defines the scale factor
  63372. * @param result defines color to store the result into
  63373. * @returns the unmodified current Color3
  63374. */
  63375. scaleAndAddToRef(scale: number, result: Color3): Color3;
  63376. /**
  63377. * Clamps the rgb values by the min and max values and stores the result into "result"
  63378. * @param min defines minimum clamping value (default is 0)
  63379. * @param max defines maximum clamping value (default is 1)
  63380. * @param result defines color to store the result into
  63381. * @returns the original Color3
  63382. */
  63383. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  63384. /**
  63385. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  63386. * @param otherColor defines the second operand
  63387. * @returns the new Color3
  63388. */
  63389. add(otherColor: DeepImmutable<Color3>): Color3;
  63390. /**
  63391. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  63392. * @param otherColor defines the second operand
  63393. * @param result defines Color3 object to store the result into
  63394. * @returns the unmodified current Color3
  63395. */
  63396. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63397. /**
  63398. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  63399. * @param otherColor defines the second operand
  63400. * @returns the new Color3
  63401. */
  63402. subtract(otherColor: DeepImmutable<Color3>): Color3;
  63403. /**
  63404. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  63405. * @param otherColor defines the second operand
  63406. * @param result defines Color3 object to store the result into
  63407. * @returns the unmodified current Color3
  63408. */
  63409. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63410. /**
  63411. * Copy the current object
  63412. * @returns a new Color3 copied the current one
  63413. */
  63414. clone(): Color3;
  63415. /**
  63416. * Copies the rgb values from the source in the current Color3
  63417. * @param source defines the source Color3 object
  63418. * @returns the updated Color3 object
  63419. */
  63420. copyFrom(source: DeepImmutable<Color3>): Color3;
  63421. /**
  63422. * Updates the Color3 rgb values from the given floats
  63423. * @param r defines the red component to read from
  63424. * @param g defines the green component to read from
  63425. * @param b defines the blue component to read from
  63426. * @returns the current Color3 object
  63427. */
  63428. copyFromFloats(r: number, g: number, b: number): Color3;
  63429. /**
  63430. * Updates the Color3 rgb values from the given floats
  63431. * @param r defines the red component to read from
  63432. * @param g defines the green component to read from
  63433. * @param b defines the blue component to read from
  63434. * @returns the current Color3 object
  63435. */
  63436. set(r: number, g: number, b: number): Color3;
  63437. /**
  63438. * Compute the Color3 hexadecimal code as a string
  63439. * @returns a string containing the hexadecimal representation of the Color3 object
  63440. */
  63441. toHexString(): string;
  63442. /**
  63443. * Computes a new Color3 converted from the current one to linear space
  63444. * @returns a new Color3 object
  63445. */
  63446. toLinearSpace(): Color3;
  63447. /**
  63448. * Converts current color in rgb space to HSV values
  63449. * @returns a new color3 representing the HSV values
  63450. */
  63451. toHSV(): Color3;
  63452. /**
  63453. * Converts current color in rgb space to HSV values
  63454. * @param result defines the Color3 where to store the HSV values
  63455. */
  63456. toHSVToRef(result: Color3): void;
  63457. /**
  63458. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  63459. * @param convertedColor defines the Color3 object where to store the linear space version
  63460. * @returns the unmodified Color3
  63461. */
  63462. toLinearSpaceToRef(convertedColor: Color3): Color3;
  63463. /**
  63464. * Computes a new Color3 converted from the current one to gamma space
  63465. * @returns a new Color3 object
  63466. */
  63467. toGammaSpace(): Color3;
  63468. /**
  63469. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  63470. * @param convertedColor defines the Color3 object where to store the gamma space version
  63471. * @returns the unmodified Color3
  63472. */
  63473. toGammaSpaceToRef(convertedColor: Color3): Color3;
  63474. private static _BlackReadOnly;
  63475. /**
  63476. * Convert Hue, saturation and value to a Color3 (RGB)
  63477. * @param hue defines the hue
  63478. * @param saturation defines the saturation
  63479. * @param value defines the value
  63480. * @param result defines the Color3 where to store the RGB values
  63481. */
  63482. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  63483. /**
  63484. * Creates a new Color3 from the string containing valid hexadecimal values
  63485. * @param hex defines a string containing valid hexadecimal values
  63486. * @returns a new Color3 object
  63487. */
  63488. static FromHexString(hex: string): Color3;
  63489. /**
  63490. * Creates a new Color3 from the starting index of the given array
  63491. * @param array defines the source array
  63492. * @param offset defines an offset in the source array
  63493. * @returns a new Color3 object
  63494. */
  63495. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  63496. /**
  63497. * Creates a new Color3 from integer values (< 256)
  63498. * @param r defines the red component to read from (value between 0 and 255)
  63499. * @param g defines the green component to read from (value between 0 and 255)
  63500. * @param b defines the blue component to read from (value between 0 and 255)
  63501. * @returns a new Color3 object
  63502. */
  63503. static FromInts(r: number, g: number, b: number): Color3;
  63504. /**
  63505. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63506. * @param start defines the start Color3 value
  63507. * @param end defines the end Color3 value
  63508. * @param amount defines the gradient value between start and end
  63509. * @returns a new Color3 object
  63510. */
  63511. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  63512. /**
  63513. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63514. * @param left defines the start value
  63515. * @param right defines the end value
  63516. * @param amount defines the gradient factor
  63517. * @param result defines the Color3 object where to store the result
  63518. */
  63519. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  63520. /**
  63521. * Returns a Color3 value containing a red color
  63522. * @returns a new Color3 object
  63523. */
  63524. static Red(): Color3;
  63525. /**
  63526. * Returns a Color3 value containing a green color
  63527. * @returns a new Color3 object
  63528. */
  63529. static Green(): Color3;
  63530. /**
  63531. * Returns a Color3 value containing a blue color
  63532. * @returns a new Color3 object
  63533. */
  63534. static Blue(): Color3;
  63535. /**
  63536. * Returns a Color3 value containing a black color
  63537. * @returns a new Color3 object
  63538. */
  63539. static Black(): Color3;
  63540. /**
  63541. * Gets a Color3 value containing a black color that must not be updated
  63542. */
  63543. static readonly BlackReadOnly: DeepImmutable<Color3>;
  63544. /**
  63545. * Returns a Color3 value containing a white color
  63546. * @returns a new Color3 object
  63547. */
  63548. static White(): Color3;
  63549. /**
  63550. * Returns a Color3 value containing a purple color
  63551. * @returns a new Color3 object
  63552. */
  63553. static Purple(): Color3;
  63554. /**
  63555. * Returns a Color3 value containing a magenta color
  63556. * @returns a new Color3 object
  63557. */
  63558. static Magenta(): Color3;
  63559. /**
  63560. * Returns a Color3 value containing a yellow color
  63561. * @returns a new Color3 object
  63562. */
  63563. static Yellow(): Color3;
  63564. /**
  63565. * Returns a Color3 value containing a gray color
  63566. * @returns a new Color3 object
  63567. */
  63568. static Gray(): Color3;
  63569. /**
  63570. * Returns a Color3 value containing a teal color
  63571. * @returns a new Color3 object
  63572. */
  63573. static Teal(): Color3;
  63574. /**
  63575. * Returns a Color3 value containing a random color
  63576. * @returns a new Color3 object
  63577. */
  63578. static Random(): Color3;
  63579. }
  63580. /**
  63581. * Class used to hold a RBGA color
  63582. */
  63583. export class Color4 {
  63584. /**
  63585. * Defines the red component (between 0 and 1, default is 0)
  63586. */
  63587. r: number;
  63588. /**
  63589. * Defines the green component (between 0 and 1, default is 0)
  63590. */
  63591. g: number;
  63592. /**
  63593. * Defines the blue component (between 0 and 1, default is 0)
  63594. */
  63595. b: number;
  63596. /**
  63597. * Defines the alpha component (between 0 and 1, default is 1)
  63598. */
  63599. a: number;
  63600. /**
  63601. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  63602. * @param r defines the red component (between 0 and 1, default is 0)
  63603. * @param g defines the green component (between 0 and 1, default is 0)
  63604. * @param b defines the blue component (between 0 and 1, default is 0)
  63605. * @param a defines the alpha component (between 0 and 1, default is 1)
  63606. */
  63607. constructor(
  63608. /**
  63609. * Defines the red component (between 0 and 1, default is 0)
  63610. */
  63611. r?: number,
  63612. /**
  63613. * Defines the green component (between 0 and 1, default is 0)
  63614. */
  63615. g?: number,
  63616. /**
  63617. * Defines the blue component (between 0 and 1, default is 0)
  63618. */
  63619. b?: number,
  63620. /**
  63621. * Defines the alpha component (between 0 and 1, default is 1)
  63622. */
  63623. a?: number);
  63624. /**
  63625. * Adds in place the given Color4 values to the current Color4 object
  63626. * @param right defines the second operand
  63627. * @returns the current updated Color4 object
  63628. */
  63629. addInPlace(right: DeepImmutable<Color4>): Color4;
  63630. /**
  63631. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  63632. * @returns the new array
  63633. */
  63634. asArray(): number[];
  63635. /**
  63636. * Stores from the starting index in the given array the Color4 successive values
  63637. * @param array defines the array where to store the r,g,b components
  63638. * @param index defines an optional index in the target array to define where to start storing values
  63639. * @returns the current Color4 object
  63640. */
  63641. toArray(array: number[], index?: number): Color4;
  63642. /**
  63643. * Determines equality between Color4 objects
  63644. * @param otherColor defines the second operand
  63645. * @returns true if the rgba values are equal to the given ones
  63646. */
  63647. equals(otherColor: DeepImmutable<Color4>): boolean;
  63648. /**
  63649. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63650. * @param right defines the second operand
  63651. * @returns a new Color4 object
  63652. */
  63653. add(right: DeepImmutable<Color4>): Color4;
  63654. /**
  63655. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63656. * @param right defines the second operand
  63657. * @returns a new Color4 object
  63658. */
  63659. subtract(right: DeepImmutable<Color4>): Color4;
  63660. /**
  63661. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63662. * @param right defines the second operand
  63663. * @param result defines the Color4 object where to store the result
  63664. * @returns the current Color4 object
  63665. */
  63666. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63667. /**
  63668. * Creates a new Color4 with the current Color4 values multiplied by scale
  63669. * @param scale defines the scaling factor to apply
  63670. * @returns a new Color4 object
  63671. */
  63672. scale(scale: number): Color4;
  63673. /**
  63674. * Multiplies the current Color4 values by scale and stores the result in "result"
  63675. * @param scale defines the scaling factor to apply
  63676. * @param result defines the Color4 object where to store the result
  63677. * @returns the current unmodified Color4
  63678. */
  63679. scaleToRef(scale: number, result: Color4): Color4;
  63680. /**
  63681. * Scale the current Color4 values by a factor and add the result to a given Color4
  63682. * @param scale defines the scale factor
  63683. * @param result defines the Color4 object where to store the result
  63684. * @returns the unmodified current Color4
  63685. */
  63686. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63687. /**
  63688. * Clamps the rgb values by the min and max values and stores the result into "result"
  63689. * @param min defines minimum clamping value (default is 0)
  63690. * @param max defines maximum clamping value (default is 1)
  63691. * @param result defines color to store the result into.
  63692. * @returns the cuurent Color4
  63693. */
  63694. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63695. /**
  63696. * Multipy an Color4 value by another and return a new Color4 object
  63697. * @param color defines the Color4 value to multiply by
  63698. * @returns a new Color4 object
  63699. */
  63700. multiply(color: Color4): Color4;
  63701. /**
  63702. * Multipy a Color4 value by another and push the result in a reference value
  63703. * @param color defines the Color4 value to multiply by
  63704. * @param result defines the Color4 to fill the result in
  63705. * @returns the result Color4
  63706. */
  63707. multiplyToRef(color: Color4, result: Color4): Color4;
  63708. /**
  63709. * Creates a string with the Color4 current values
  63710. * @returns the string representation of the Color4 object
  63711. */
  63712. toString(): string;
  63713. /**
  63714. * Returns the string "Color4"
  63715. * @returns "Color4"
  63716. */
  63717. getClassName(): string;
  63718. /**
  63719. * Compute the Color4 hash code
  63720. * @returns an unique number that can be used to hash Color4 objects
  63721. */
  63722. getHashCode(): number;
  63723. /**
  63724. * Creates a new Color4 copied from the current one
  63725. * @returns a new Color4 object
  63726. */
  63727. clone(): Color4;
  63728. /**
  63729. * Copies the given Color4 values into the current one
  63730. * @param source defines the source Color4 object
  63731. * @returns the current updated Color4 object
  63732. */
  63733. copyFrom(source: Color4): Color4;
  63734. /**
  63735. * Copies the given float values into the current one
  63736. * @param r defines the red component to read from
  63737. * @param g defines the green component to read from
  63738. * @param b defines the blue component to read from
  63739. * @param a defines the alpha component to read from
  63740. * @returns the current updated Color4 object
  63741. */
  63742. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63743. /**
  63744. * Copies the given float values into the current one
  63745. * @param r defines the red component to read from
  63746. * @param g defines the green component to read from
  63747. * @param b defines the blue component to read from
  63748. * @param a defines the alpha component to read from
  63749. * @returns the current updated Color4 object
  63750. */
  63751. set(r: number, g: number, b: number, a: number): Color4;
  63752. /**
  63753. * Compute the Color4 hexadecimal code as a string
  63754. * @returns a string containing the hexadecimal representation of the Color4 object
  63755. */
  63756. toHexString(): string;
  63757. /**
  63758. * Computes a new Color4 converted from the current one to linear space
  63759. * @returns a new Color4 object
  63760. */
  63761. toLinearSpace(): Color4;
  63762. /**
  63763. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63764. * @param convertedColor defines the Color4 object where to store the linear space version
  63765. * @returns the unmodified Color4
  63766. */
  63767. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63768. /**
  63769. * Computes a new Color4 converted from the current one to gamma space
  63770. * @returns a new Color4 object
  63771. */
  63772. toGammaSpace(): Color4;
  63773. /**
  63774. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63775. * @param convertedColor defines the Color4 object where to store the gamma space version
  63776. * @returns the unmodified Color4
  63777. */
  63778. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63779. /**
  63780. * Creates a new Color4 from the string containing valid hexadecimal values
  63781. * @param hex defines a string containing valid hexadecimal values
  63782. * @returns a new Color4 object
  63783. */
  63784. static FromHexString(hex: string): Color4;
  63785. /**
  63786. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63787. * @param left defines the start value
  63788. * @param right defines the end value
  63789. * @param amount defines the gradient factor
  63790. * @returns a new Color4 object
  63791. */
  63792. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63793. /**
  63794. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63795. * @param left defines the start value
  63796. * @param right defines the end value
  63797. * @param amount defines the gradient factor
  63798. * @param result defines the Color4 object where to store data
  63799. */
  63800. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63801. /**
  63802. * Creates a new Color4 from a Color3 and an alpha value
  63803. * @param color3 defines the source Color3 to read from
  63804. * @param alpha defines the alpha component (1.0 by default)
  63805. * @returns a new Color4 object
  63806. */
  63807. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63808. /**
  63809. * Creates a new Color4 from the starting index element of the given array
  63810. * @param array defines the source array to read from
  63811. * @param offset defines the offset in the source array
  63812. * @returns a new Color4 object
  63813. */
  63814. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63815. /**
  63816. * Creates a new Color3 from integer values (< 256)
  63817. * @param r defines the red component to read from (value between 0 and 255)
  63818. * @param g defines the green component to read from (value between 0 and 255)
  63819. * @param b defines the blue component to read from (value between 0 and 255)
  63820. * @param a defines the alpha component to read from (value between 0 and 255)
  63821. * @returns a new Color3 object
  63822. */
  63823. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63824. /**
  63825. * Check the content of a given array and convert it to an array containing RGBA data
  63826. * If the original array was already containing count * 4 values then it is returned directly
  63827. * @param colors defines the array to check
  63828. * @param count defines the number of RGBA data to expect
  63829. * @returns an array containing count * 4 values (RGBA)
  63830. */
  63831. static CheckColors4(colors: number[], count: number): number[];
  63832. }
  63833. /**
  63834. * Class representing a vector containing 2 coordinates
  63835. */
  63836. export class Vector2 {
  63837. /** defines the first coordinate */
  63838. x: number;
  63839. /** defines the second coordinate */
  63840. y: number;
  63841. /**
  63842. * Creates a new Vector2 from the given x and y coordinates
  63843. * @param x defines the first coordinate
  63844. * @param y defines the second coordinate
  63845. */
  63846. constructor(
  63847. /** defines the first coordinate */
  63848. x?: number,
  63849. /** defines the second coordinate */
  63850. y?: number);
  63851. /**
  63852. * Gets a string with the Vector2 coordinates
  63853. * @returns a string with the Vector2 coordinates
  63854. */
  63855. toString(): string;
  63856. /**
  63857. * Gets class name
  63858. * @returns the string "Vector2"
  63859. */
  63860. getClassName(): string;
  63861. /**
  63862. * Gets current vector hash code
  63863. * @returns the Vector2 hash code as a number
  63864. */
  63865. getHashCode(): number;
  63866. /**
  63867. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63868. * @param array defines the source array
  63869. * @param index defines the offset in source array
  63870. * @returns the current Vector2
  63871. */
  63872. toArray(array: FloatArray, index?: number): Vector2;
  63873. /**
  63874. * Copy the current vector to an array
  63875. * @returns a new array with 2 elements: the Vector2 coordinates.
  63876. */
  63877. asArray(): number[];
  63878. /**
  63879. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63880. * @param source defines the source Vector2
  63881. * @returns the current updated Vector2
  63882. */
  63883. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63884. /**
  63885. * Sets the Vector2 coordinates with the given floats
  63886. * @param x defines the first coordinate
  63887. * @param y defines the second coordinate
  63888. * @returns the current updated Vector2
  63889. */
  63890. copyFromFloats(x: number, y: number): Vector2;
  63891. /**
  63892. * Sets the Vector2 coordinates with the given floats
  63893. * @param x defines the first coordinate
  63894. * @param y defines the second coordinate
  63895. * @returns the current updated Vector2
  63896. */
  63897. set(x: number, y: number): Vector2;
  63898. /**
  63899. * Add another vector with the current one
  63900. * @param otherVector defines the other vector
  63901. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63902. */
  63903. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63904. /**
  63905. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63906. * @param otherVector defines the other vector
  63907. * @param result defines the target vector
  63908. * @returns the unmodified current Vector2
  63909. */
  63910. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63911. /**
  63912. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63913. * @param otherVector defines the other vector
  63914. * @returns the current updated Vector2
  63915. */
  63916. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63917. /**
  63918. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63919. * @param otherVector defines the other vector
  63920. * @returns a new Vector2
  63921. */
  63922. addVector3(otherVector: Vector3): Vector2;
  63923. /**
  63924. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63925. * @param otherVector defines the other vector
  63926. * @returns a new Vector2
  63927. */
  63928. subtract(otherVector: Vector2): Vector2;
  63929. /**
  63930. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63931. * @param otherVector defines the other vector
  63932. * @param result defines the target vector
  63933. * @returns the unmodified current Vector2
  63934. */
  63935. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63936. /**
  63937. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63938. * @param otherVector defines the other vector
  63939. * @returns the current updated Vector2
  63940. */
  63941. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63942. /**
  63943. * Multiplies in place the current Vector2 coordinates by the given ones
  63944. * @param otherVector defines the other vector
  63945. * @returns the current updated Vector2
  63946. */
  63947. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63948. /**
  63949. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63950. * @param otherVector defines the other vector
  63951. * @returns a new Vector2
  63952. */
  63953. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63954. /**
  63955. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63956. * @param otherVector defines the other vector
  63957. * @param result defines the target vector
  63958. * @returns the unmodified current Vector2
  63959. */
  63960. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63961. /**
  63962. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63963. * @param x defines the first coordinate
  63964. * @param y defines the second coordinate
  63965. * @returns a new Vector2
  63966. */
  63967. multiplyByFloats(x: number, y: number): Vector2;
  63968. /**
  63969. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63970. * @param otherVector defines the other vector
  63971. * @returns a new Vector2
  63972. */
  63973. divide(otherVector: Vector2): Vector2;
  63974. /**
  63975. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63976. * @param otherVector defines the other vector
  63977. * @param result defines the target vector
  63978. * @returns the unmodified current Vector2
  63979. */
  63980. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63981. /**
  63982. * Divides the current Vector2 coordinates by the given ones
  63983. * @param otherVector defines the other vector
  63984. * @returns the current updated Vector2
  63985. */
  63986. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63987. /**
  63988. * Gets a new Vector2 with current Vector2 negated coordinates
  63989. * @returns a new Vector2
  63990. */
  63991. negate(): Vector2;
  63992. /**
  63993. * Multiply the Vector2 coordinates by scale
  63994. * @param scale defines the scaling factor
  63995. * @returns the current updated Vector2
  63996. */
  63997. scaleInPlace(scale: number): Vector2;
  63998. /**
  63999. * Returns a new Vector2 scaled by "scale" from the current Vector2
  64000. * @param scale defines the scaling factor
  64001. * @returns a new Vector2
  64002. */
  64003. scale(scale: number): Vector2;
  64004. /**
  64005. * Scale the current Vector2 values by a factor to a given Vector2
  64006. * @param scale defines the scale factor
  64007. * @param result defines the Vector2 object where to store the result
  64008. * @returns the unmodified current Vector2
  64009. */
  64010. scaleToRef(scale: number, result: Vector2): Vector2;
  64011. /**
  64012. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  64013. * @param scale defines the scale factor
  64014. * @param result defines the Vector2 object where to store the result
  64015. * @returns the unmodified current Vector2
  64016. */
  64017. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  64018. /**
  64019. * Gets a boolean if two vectors are equals
  64020. * @param otherVector defines the other vector
  64021. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  64022. */
  64023. equals(otherVector: DeepImmutable<Vector2>): boolean;
  64024. /**
  64025. * Gets a boolean if two vectors are equals (using an epsilon value)
  64026. * @param otherVector defines the other vector
  64027. * @param epsilon defines the minimal distance to consider equality
  64028. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  64029. */
  64030. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  64031. /**
  64032. * Gets a new Vector2 from current Vector2 floored values
  64033. * @returns a new Vector2
  64034. */
  64035. floor(): Vector2;
  64036. /**
  64037. * Gets a new Vector2 from current Vector2 floored values
  64038. * @returns a new Vector2
  64039. */
  64040. fract(): Vector2;
  64041. /**
  64042. * Gets the length of the vector
  64043. * @returns the vector length (float)
  64044. */
  64045. length(): number;
  64046. /**
  64047. * Gets the vector squared length
  64048. * @returns the vector squared length (float)
  64049. */
  64050. lengthSquared(): number;
  64051. /**
  64052. * Normalize the vector
  64053. * @returns the current updated Vector2
  64054. */
  64055. normalize(): Vector2;
  64056. /**
  64057. * Gets a new Vector2 copied from the Vector2
  64058. * @returns a new Vector2
  64059. */
  64060. clone(): Vector2;
  64061. /**
  64062. * Gets a new Vector2(0, 0)
  64063. * @returns a new Vector2
  64064. */
  64065. static Zero(): Vector2;
  64066. /**
  64067. * Gets a new Vector2(1, 1)
  64068. * @returns a new Vector2
  64069. */
  64070. static One(): Vector2;
  64071. /**
  64072. * Gets a new Vector2 set from the given index element of the given array
  64073. * @param array defines the data source
  64074. * @param offset defines the offset in the data source
  64075. * @returns a new Vector2
  64076. */
  64077. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  64078. /**
  64079. * Sets "result" from the given index element of the given array
  64080. * @param array defines the data source
  64081. * @param offset defines the offset in the data source
  64082. * @param result defines the target vector
  64083. */
  64084. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  64085. /**
  64086. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  64087. * @param value1 defines 1st point of control
  64088. * @param value2 defines 2nd point of control
  64089. * @param value3 defines 3rd point of control
  64090. * @param value4 defines 4th point of control
  64091. * @param amount defines the interpolation factor
  64092. * @returns a new Vector2
  64093. */
  64094. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  64095. /**
  64096. * 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".
  64097. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  64098. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  64099. * @param value defines the value to clamp
  64100. * @param min defines the lower limit
  64101. * @param max defines the upper limit
  64102. * @returns a new Vector2
  64103. */
  64104. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  64105. /**
  64106. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  64107. * @param value1 defines the 1st control point
  64108. * @param tangent1 defines the outgoing tangent
  64109. * @param value2 defines the 2nd control point
  64110. * @param tangent2 defines the incoming tangent
  64111. * @param amount defines the interpolation factor
  64112. * @returns a new Vector2
  64113. */
  64114. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  64115. /**
  64116. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  64117. * @param start defines the start vector
  64118. * @param end defines the end vector
  64119. * @param amount defines the interpolation factor
  64120. * @returns a new Vector2
  64121. */
  64122. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  64123. /**
  64124. * Gets the dot product of the vector "left" and the vector "right"
  64125. * @param left defines first vector
  64126. * @param right defines second vector
  64127. * @returns the dot product (float)
  64128. */
  64129. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  64130. /**
  64131. * Returns a new Vector2 equal to the normalized given vector
  64132. * @param vector defines the vector to normalize
  64133. * @returns a new Vector2
  64134. */
  64135. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  64136. /**
  64137. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  64138. * @param left defines 1st vector
  64139. * @param right defines 2nd vector
  64140. * @returns a new Vector2
  64141. */
  64142. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  64143. /**
  64144. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  64145. * @param left defines 1st vector
  64146. * @param right defines 2nd vector
  64147. * @returns a new Vector2
  64148. */
  64149. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  64150. /**
  64151. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  64152. * @param vector defines the vector to transform
  64153. * @param transformation defines the matrix to apply
  64154. * @returns a new Vector2
  64155. */
  64156. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  64157. /**
  64158. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  64159. * @param vector defines the vector to transform
  64160. * @param transformation defines the matrix to apply
  64161. * @param result defines the target vector
  64162. */
  64163. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  64164. /**
  64165. * Determines if a given vector is included in a triangle
  64166. * @param p defines the vector to test
  64167. * @param p0 defines 1st triangle point
  64168. * @param p1 defines 2nd triangle point
  64169. * @param p2 defines 3rd triangle point
  64170. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  64171. */
  64172. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  64173. /**
  64174. * Gets the distance between the vectors "value1" and "value2"
  64175. * @param value1 defines first vector
  64176. * @param value2 defines second vector
  64177. * @returns the distance between vectors
  64178. */
  64179. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  64180. /**
  64181. * Returns the squared distance between the vectors "value1" and "value2"
  64182. * @param value1 defines first vector
  64183. * @param value2 defines second vector
  64184. * @returns the squared distance between vectors
  64185. */
  64186. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  64187. /**
  64188. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  64189. * @param value1 defines first vector
  64190. * @param value2 defines second vector
  64191. * @returns a new Vector2
  64192. */
  64193. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  64194. /**
  64195. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  64196. * @param p defines the middle point
  64197. * @param segA defines one point of the segment
  64198. * @param segB defines the other point of the segment
  64199. * @returns the shortest distance
  64200. */
  64201. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  64202. }
  64203. /**
  64204. * Classed used to store (x,y,z) vector representation
  64205. * A Vector3 is the main object used in 3D geometry
  64206. * It can represent etiher the coordinates of a point the space, either a direction
  64207. * Reminder: js uses a left handed forward facing system
  64208. */
  64209. export class Vector3 {
  64210. /**
  64211. * Defines the first coordinates (on X axis)
  64212. */
  64213. x: number;
  64214. /**
  64215. * Defines the second coordinates (on Y axis)
  64216. */
  64217. y: number;
  64218. /**
  64219. * Defines the third coordinates (on Z axis)
  64220. */
  64221. z: number;
  64222. private static _UpReadOnly;
  64223. private static _ZeroReadOnly;
  64224. /**
  64225. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  64226. * @param x defines the first coordinates (on X axis)
  64227. * @param y defines the second coordinates (on Y axis)
  64228. * @param z defines the third coordinates (on Z axis)
  64229. */
  64230. constructor(
  64231. /**
  64232. * Defines the first coordinates (on X axis)
  64233. */
  64234. x?: number,
  64235. /**
  64236. * Defines the second coordinates (on Y axis)
  64237. */
  64238. y?: number,
  64239. /**
  64240. * Defines the third coordinates (on Z axis)
  64241. */
  64242. z?: number);
  64243. /**
  64244. * Creates a string representation of the Vector3
  64245. * @returns a string with the Vector3 coordinates.
  64246. */
  64247. toString(): string;
  64248. /**
  64249. * Gets the class name
  64250. * @returns the string "Vector3"
  64251. */
  64252. getClassName(): string;
  64253. /**
  64254. * Creates the Vector3 hash code
  64255. * @returns a number which tends to be unique between Vector3 instances
  64256. */
  64257. getHashCode(): number;
  64258. /**
  64259. * Creates an array containing three elements : the coordinates of the Vector3
  64260. * @returns a new array of numbers
  64261. */
  64262. asArray(): number[];
  64263. /**
  64264. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  64265. * @param array defines the destination array
  64266. * @param index defines the offset in the destination array
  64267. * @returns the current Vector3
  64268. */
  64269. toArray(array: FloatArray, index?: number): Vector3;
  64270. /**
  64271. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  64272. * @returns a new Quaternion object, computed from the Vector3 coordinates
  64273. */
  64274. toQuaternion(): Quaternion;
  64275. /**
  64276. * Adds the given vector to the current Vector3
  64277. * @param otherVector defines the second operand
  64278. * @returns the current updated Vector3
  64279. */
  64280. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64281. /**
  64282. * Adds the given coordinates to the current Vector3
  64283. * @param x defines the x coordinate of the operand
  64284. * @param y defines the y coordinate of the operand
  64285. * @param z defines the z coordinate of the operand
  64286. * @returns the current updated Vector3
  64287. */
  64288. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64289. /**
  64290. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  64291. * @param otherVector defines the second operand
  64292. * @returns the resulting Vector3
  64293. */
  64294. add(otherVector: DeepImmutable<Vector3>): Vector3;
  64295. /**
  64296. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  64297. * @param otherVector defines the second operand
  64298. * @param result defines the Vector3 object where to store the result
  64299. * @returns the current Vector3
  64300. */
  64301. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64302. /**
  64303. * Subtract the given vector from the current Vector3
  64304. * @param otherVector defines the second operand
  64305. * @returns the current updated Vector3
  64306. */
  64307. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64308. /**
  64309. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  64310. * @param otherVector defines the second operand
  64311. * @returns the resulting Vector3
  64312. */
  64313. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  64314. /**
  64315. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  64316. * @param otherVector defines the second operand
  64317. * @param result defines the Vector3 object where to store the result
  64318. * @returns the current Vector3
  64319. */
  64320. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64321. /**
  64322. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  64323. * @param x defines the x coordinate of the operand
  64324. * @param y defines the y coordinate of the operand
  64325. * @param z defines the z coordinate of the operand
  64326. * @returns the resulting Vector3
  64327. */
  64328. subtractFromFloats(x: number, y: number, z: number): Vector3;
  64329. /**
  64330. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  64331. * @param x defines the x coordinate of the operand
  64332. * @param y defines the y coordinate of the operand
  64333. * @param z defines the z coordinate of the operand
  64334. * @param result defines the Vector3 object where to store the result
  64335. * @returns the current Vector3
  64336. */
  64337. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  64338. /**
  64339. * Gets a new Vector3 set with the current Vector3 negated coordinates
  64340. * @returns a new Vector3
  64341. */
  64342. negate(): Vector3;
  64343. /**
  64344. * Multiplies the Vector3 coordinates by the float "scale"
  64345. * @param scale defines the multiplier factor
  64346. * @returns the current updated Vector3
  64347. */
  64348. scaleInPlace(scale: number): Vector3;
  64349. /**
  64350. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  64351. * @param scale defines the multiplier factor
  64352. * @returns a new Vector3
  64353. */
  64354. scale(scale: number): Vector3;
  64355. /**
  64356. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  64357. * @param scale defines the multiplier factor
  64358. * @param result defines the Vector3 object where to store the result
  64359. * @returns the current Vector3
  64360. */
  64361. scaleToRef(scale: number, result: Vector3): Vector3;
  64362. /**
  64363. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  64364. * @param scale defines the scale factor
  64365. * @param result defines the Vector3 object where to store the result
  64366. * @returns the unmodified current Vector3
  64367. */
  64368. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  64369. /**
  64370. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  64371. * @param otherVector defines the second operand
  64372. * @returns true if both vectors are equals
  64373. */
  64374. equals(otherVector: DeepImmutable<Vector3>): boolean;
  64375. /**
  64376. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  64377. * @param otherVector defines the second operand
  64378. * @param epsilon defines the minimal distance to define values as equals
  64379. * @returns true if both vectors are distant less than epsilon
  64380. */
  64381. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  64382. /**
  64383. * Returns true if the current Vector3 coordinates equals the given floats
  64384. * @param x defines the x coordinate of the operand
  64385. * @param y defines the y coordinate of the operand
  64386. * @param z defines the z coordinate of the operand
  64387. * @returns true if both vectors are equals
  64388. */
  64389. equalsToFloats(x: number, y: number, z: number): boolean;
  64390. /**
  64391. * Multiplies the current Vector3 coordinates by the given ones
  64392. * @param otherVector defines the second operand
  64393. * @returns the current updated Vector3
  64394. */
  64395. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64396. /**
  64397. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  64398. * @param otherVector defines the second operand
  64399. * @returns the new Vector3
  64400. */
  64401. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  64402. /**
  64403. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  64404. * @param otherVector defines the second operand
  64405. * @param result defines the Vector3 object where to store the result
  64406. * @returns the current Vector3
  64407. */
  64408. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64409. /**
  64410. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  64411. * @param x defines the x coordinate of the operand
  64412. * @param y defines the y coordinate of the operand
  64413. * @param z defines the z coordinate of the operand
  64414. * @returns the new Vector3
  64415. */
  64416. multiplyByFloats(x: number, y: number, z: number): Vector3;
  64417. /**
  64418. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  64419. * @param otherVector defines the second operand
  64420. * @returns the new Vector3
  64421. */
  64422. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  64423. /**
  64424. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  64425. * @param otherVector defines the second operand
  64426. * @param result defines the Vector3 object where to store the result
  64427. * @returns the current Vector3
  64428. */
  64429. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64430. /**
  64431. * Divides the current Vector3 coordinates by the given ones.
  64432. * @param otherVector defines the second operand
  64433. * @returns the current updated Vector3
  64434. */
  64435. divideInPlace(otherVector: Vector3): Vector3;
  64436. /**
  64437. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  64438. * @param other defines the second operand
  64439. * @returns the current updated Vector3
  64440. */
  64441. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64442. /**
  64443. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  64444. * @param other defines the second operand
  64445. * @returns the current updated Vector3
  64446. */
  64447. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64448. /**
  64449. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  64450. * @param x defines the x coordinate of the operand
  64451. * @param y defines the y coordinate of the operand
  64452. * @param z defines the z coordinate of the operand
  64453. * @returns the current updated Vector3
  64454. */
  64455. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64456. /**
  64457. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  64458. * @param x defines the x coordinate of the operand
  64459. * @param y defines the y coordinate of the operand
  64460. * @param z defines the z coordinate of the operand
  64461. * @returns the current updated Vector3
  64462. */
  64463. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64464. /**
  64465. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  64466. * Check if is non uniform within a certain amount of decimal places to account for this
  64467. * @param epsilon the amount the values can differ
  64468. * @returns if the the vector is non uniform to a certain number of decimal places
  64469. */
  64470. isNonUniformWithinEpsilon(epsilon: number): boolean;
  64471. /**
  64472. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  64473. */
  64474. readonly isNonUniform: boolean;
  64475. /**
  64476. * Gets a new Vector3 from current Vector3 floored values
  64477. * @returns a new Vector3
  64478. */
  64479. floor(): Vector3;
  64480. /**
  64481. * Gets a new Vector3 from current Vector3 floored values
  64482. * @returns a new Vector3
  64483. */
  64484. fract(): Vector3;
  64485. /**
  64486. * Gets the length of the Vector3
  64487. * @returns the length of the Vector3
  64488. */
  64489. length(): number;
  64490. /**
  64491. * Gets the squared length of the Vector3
  64492. * @returns squared length of the Vector3
  64493. */
  64494. lengthSquared(): number;
  64495. /**
  64496. * Normalize the current Vector3.
  64497. * Please note that this is an in place operation.
  64498. * @returns the current updated Vector3
  64499. */
  64500. normalize(): Vector3;
  64501. /**
  64502. * Reorders the x y z properties of the vector in place
  64503. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  64504. * @returns the current updated vector
  64505. */
  64506. reorderInPlace(order: string): this;
  64507. /**
  64508. * Rotates the vector around 0,0,0 by a quaternion
  64509. * @param quaternion the rotation quaternion
  64510. * @param result vector to store the result
  64511. * @returns the resulting vector
  64512. */
  64513. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  64514. /**
  64515. * Rotates a vector around a given point
  64516. * @param quaternion the rotation quaternion
  64517. * @param point the point to rotate around
  64518. * @param result vector to store the result
  64519. * @returns the resulting vector
  64520. */
  64521. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  64522. /**
  64523. * Normalize the current Vector3 with the given input length.
  64524. * Please note that this is an in place operation.
  64525. * @param len the length of the vector
  64526. * @returns the current updated Vector3
  64527. */
  64528. normalizeFromLength(len: number): Vector3;
  64529. /**
  64530. * Normalize the current Vector3 to a new vector
  64531. * @returns the new Vector3
  64532. */
  64533. normalizeToNew(): Vector3;
  64534. /**
  64535. * Normalize the current Vector3 to the reference
  64536. * @param reference define the Vector3 to update
  64537. * @returns the updated Vector3
  64538. */
  64539. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  64540. /**
  64541. * Creates a new Vector3 copied from the current Vector3
  64542. * @returns the new Vector3
  64543. */
  64544. clone(): Vector3;
  64545. /**
  64546. * Copies the given vector coordinates to the current Vector3 ones
  64547. * @param source defines the source Vector3
  64548. * @returns the current updated Vector3
  64549. */
  64550. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  64551. /**
  64552. * Copies the given floats to the current Vector3 coordinates
  64553. * @param x defines the x coordinate of the operand
  64554. * @param y defines the y coordinate of the operand
  64555. * @param z defines the z coordinate of the operand
  64556. * @returns the current updated Vector3
  64557. */
  64558. copyFromFloats(x: number, y: number, z: number): Vector3;
  64559. /**
  64560. * Copies the given floats to the current Vector3 coordinates
  64561. * @param x defines the x coordinate of the operand
  64562. * @param y defines the y coordinate of the operand
  64563. * @param z defines the z coordinate of the operand
  64564. * @returns the current updated Vector3
  64565. */
  64566. set(x: number, y: number, z: number): Vector3;
  64567. /**
  64568. * Copies the given float to the current Vector3 coordinates
  64569. * @param v defines the x, y and z coordinates of the operand
  64570. * @returns the current updated Vector3
  64571. */
  64572. setAll(v: number): Vector3;
  64573. /**
  64574. * Get the clip factor between two vectors
  64575. * @param vector0 defines the first operand
  64576. * @param vector1 defines the second operand
  64577. * @param axis defines the axis to use
  64578. * @param size defines the size along the axis
  64579. * @returns the clip factor
  64580. */
  64581. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  64582. /**
  64583. * Get angle between two vectors
  64584. * @param vector0 angle between vector0 and vector1
  64585. * @param vector1 angle between vector0 and vector1
  64586. * @param normal direction of the normal
  64587. * @return the angle between vector0 and vector1
  64588. */
  64589. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  64590. /**
  64591. * Returns a new Vector3 set from the index "offset" of the given array
  64592. * @param array defines the source array
  64593. * @param offset defines the offset in the source array
  64594. * @returns the new Vector3
  64595. */
  64596. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  64597. /**
  64598. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  64599. * This function is deprecated. Use FromArray instead
  64600. * @param array defines the source array
  64601. * @param offset defines the offset in the source array
  64602. * @returns the new Vector3
  64603. */
  64604. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  64605. /**
  64606. * Sets the given vector "result" with the element values from the index "offset" of the given array
  64607. * @param array defines the source array
  64608. * @param offset defines the offset in the source array
  64609. * @param result defines the Vector3 where to store the result
  64610. */
  64611. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  64612. /**
  64613. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  64614. * This function is deprecated. Use FromArrayToRef instead.
  64615. * @param array defines the source array
  64616. * @param offset defines the offset in the source array
  64617. * @param result defines the Vector3 where to store the result
  64618. */
  64619. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  64620. /**
  64621. * Sets the given vector "result" with the given floats.
  64622. * @param x defines the x coordinate of the source
  64623. * @param y defines the y coordinate of the source
  64624. * @param z defines the z coordinate of the source
  64625. * @param result defines the Vector3 where to store the result
  64626. */
  64627. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  64628. /**
  64629. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  64630. * @returns a new empty Vector3
  64631. */
  64632. static Zero(): Vector3;
  64633. /**
  64634. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  64635. * @returns a new unit Vector3
  64636. */
  64637. static One(): Vector3;
  64638. /**
  64639. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64640. * @returns a new up Vector3
  64641. */
  64642. static Up(): Vector3;
  64643. /**
  64644. * Gets a up Vector3 that must not be updated
  64645. */
  64646. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64647. /**
  64648. * Gets a zero Vector3 that must not be updated
  64649. */
  64650. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64651. /**
  64652. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64653. * @returns a new down Vector3
  64654. */
  64655. static Down(): Vector3;
  64656. /**
  64657. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64658. * @returns a new forward Vector3
  64659. */
  64660. static Forward(): Vector3;
  64661. /**
  64662. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64663. * @returns a new forward Vector3
  64664. */
  64665. static Backward(): Vector3;
  64666. /**
  64667. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64668. * @returns a new right Vector3
  64669. */
  64670. static Right(): Vector3;
  64671. /**
  64672. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64673. * @returns a new left Vector3
  64674. */
  64675. static Left(): Vector3;
  64676. /**
  64677. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64679. * @param vector defines the Vector3 to transform
  64680. * @param transformation defines the transformation matrix
  64681. * @returns the transformed Vector3
  64682. */
  64683. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64684. /**
  64685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64686. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64687. * @param vector defines the Vector3 to transform
  64688. * @param transformation defines the transformation matrix
  64689. * @param result defines the Vector3 where to store the result
  64690. */
  64691. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64692. /**
  64693. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64694. * This method computes tranformed coordinates only, not transformed direction vectors
  64695. * @param x define the x coordinate of the source vector
  64696. * @param y define the y coordinate of the source vector
  64697. * @param z define the z coordinate of the source vector
  64698. * @param transformation defines the transformation matrix
  64699. * @param result defines the Vector3 where to store the result
  64700. */
  64701. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64702. /**
  64703. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64705. * @param vector defines the Vector3 to transform
  64706. * @param transformation defines the transformation matrix
  64707. * @returns the new Vector3
  64708. */
  64709. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64710. /**
  64711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64713. * @param vector defines the Vector3 to transform
  64714. * @param transformation defines the transformation matrix
  64715. * @param result defines the Vector3 where to store the result
  64716. */
  64717. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64718. /**
  64719. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64720. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64721. * @param x define the x coordinate of the source vector
  64722. * @param y define the y coordinate of the source vector
  64723. * @param z define the z coordinate of the source vector
  64724. * @param transformation defines the transformation matrix
  64725. * @param result defines the Vector3 where to store the result
  64726. */
  64727. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64728. /**
  64729. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64730. * @param value1 defines the first control point
  64731. * @param value2 defines the second control point
  64732. * @param value3 defines the third control point
  64733. * @param value4 defines the fourth control point
  64734. * @param amount defines the amount on the spline to use
  64735. * @returns the new Vector3
  64736. */
  64737. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64738. /**
  64739. * 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"
  64740. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64741. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64742. * @param value defines the current value
  64743. * @param min defines the lower range value
  64744. * @param max defines the upper range value
  64745. * @returns the new Vector3
  64746. */
  64747. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64748. /**
  64749. * 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"
  64750. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64751. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64752. * @param value defines the current value
  64753. * @param min defines the lower range value
  64754. * @param max defines the upper range value
  64755. * @param result defines the Vector3 where to store the result
  64756. */
  64757. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64758. /**
  64759. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64760. * @param value1 defines the first control point
  64761. * @param tangent1 defines the first tangent vector
  64762. * @param value2 defines the second control point
  64763. * @param tangent2 defines the second tangent vector
  64764. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64765. * @returns the new Vector3
  64766. */
  64767. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64768. /**
  64769. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64770. * @param start defines the start value
  64771. * @param end defines the end value
  64772. * @param amount max defines amount between both (between 0 and 1)
  64773. * @returns the new Vector3
  64774. */
  64775. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64776. /**
  64777. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64778. * @param start defines the start value
  64779. * @param end defines the end value
  64780. * @param amount max defines amount between both (between 0 and 1)
  64781. * @param result defines the Vector3 where to store the result
  64782. */
  64783. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64784. /**
  64785. * Returns the dot product (float) between the vectors "left" and "right"
  64786. * @param left defines the left operand
  64787. * @param right defines the right operand
  64788. * @returns the dot product
  64789. */
  64790. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64791. /**
  64792. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64793. * The cross product is then orthogonal to both "left" and "right"
  64794. * @param left defines the left operand
  64795. * @param right defines the right operand
  64796. * @returns the cross product
  64797. */
  64798. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64799. /**
  64800. * Sets the given vector "result" with the cross product of "left" and "right"
  64801. * The cross product is then orthogonal to both "left" and "right"
  64802. * @param left defines the left operand
  64803. * @param right defines the right operand
  64804. * @param result defines the Vector3 where to store the result
  64805. */
  64806. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64807. /**
  64808. * Returns a new Vector3 as the normalization of the given vector
  64809. * @param vector defines the Vector3 to normalize
  64810. * @returns the new Vector3
  64811. */
  64812. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64813. /**
  64814. * Sets the given vector "result" with the normalization of the given first vector
  64815. * @param vector defines the Vector3 to normalize
  64816. * @param result defines the Vector3 where to store the result
  64817. */
  64818. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64819. /**
  64820. * Project a Vector3 onto screen space
  64821. * @param vector defines the Vector3 to project
  64822. * @param world defines the world matrix to use
  64823. * @param transform defines the transform (view x projection) matrix to use
  64824. * @param viewport defines the screen viewport to use
  64825. * @returns the new Vector3
  64826. */
  64827. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64828. /** @hidden */
  64829. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64830. /**
  64831. * Unproject from screen space to object space
  64832. * @param source defines the screen space Vector3 to use
  64833. * @param viewportWidth defines the current width of the viewport
  64834. * @param viewportHeight defines the current height of the viewport
  64835. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64836. * @param transform defines the transform (view x projection) matrix to use
  64837. * @returns the new Vector3
  64838. */
  64839. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64840. /**
  64841. * Unproject from screen space to object space
  64842. * @param source defines the screen space Vector3 to use
  64843. * @param viewportWidth defines the current width of the viewport
  64844. * @param viewportHeight defines the current height of the viewport
  64845. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64846. * @param view defines the view matrix to use
  64847. * @param projection defines the projection matrix to use
  64848. * @returns the new Vector3
  64849. */
  64850. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64851. /**
  64852. * Unproject from screen space to object space
  64853. * @param source defines the screen space Vector3 to use
  64854. * @param viewportWidth defines the current width of the viewport
  64855. * @param viewportHeight defines the current height of the viewport
  64856. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64857. * @param view defines the view matrix to use
  64858. * @param projection defines the projection matrix to use
  64859. * @param result defines the Vector3 where to store the result
  64860. */
  64861. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64862. /**
  64863. * Unproject from screen space to object space
  64864. * @param sourceX defines the screen space x coordinate to use
  64865. * @param sourceY defines the screen space y coordinate to use
  64866. * @param sourceZ defines the screen space z coordinate to use
  64867. * @param viewportWidth defines the current width of the viewport
  64868. * @param viewportHeight defines the current height of the viewport
  64869. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64870. * @param view defines the view matrix to use
  64871. * @param projection defines the projection matrix to use
  64872. * @param result defines the Vector3 where to store the result
  64873. */
  64874. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64875. /**
  64876. * Gets the minimal coordinate values between two Vector3
  64877. * @param left defines the first operand
  64878. * @param right defines the second operand
  64879. * @returns the new Vector3
  64880. */
  64881. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64882. /**
  64883. * Gets the maximal coordinate values between two Vector3
  64884. * @param left defines the first operand
  64885. * @param right defines the second operand
  64886. * @returns the new Vector3
  64887. */
  64888. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64889. /**
  64890. * Returns the distance between the vectors "value1" and "value2"
  64891. * @param value1 defines the first operand
  64892. * @param value2 defines the second operand
  64893. * @returns the distance
  64894. */
  64895. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64896. /**
  64897. * Returns the squared distance between the vectors "value1" and "value2"
  64898. * @param value1 defines the first operand
  64899. * @param value2 defines the second operand
  64900. * @returns the squared distance
  64901. */
  64902. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64903. /**
  64904. * Returns a new Vector3 located at the center between "value1" and "value2"
  64905. * @param value1 defines the first operand
  64906. * @param value2 defines the second operand
  64907. * @returns the new Vector3
  64908. */
  64909. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64910. /**
  64911. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64912. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64913. * to something in order to rotate it from its local system to the given target system
  64914. * Note: axis1, axis2 and axis3 are normalized during this operation
  64915. * @param axis1 defines the first axis
  64916. * @param axis2 defines the second axis
  64917. * @param axis3 defines the third axis
  64918. * @returns a new Vector3
  64919. */
  64920. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64921. /**
  64922. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64923. * @param axis1 defines the first axis
  64924. * @param axis2 defines the second axis
  64925. * @param axis3 defines the third axis
  64926. * @param ref defines the Vector3 where to store the result
  64927. */
  64928. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64929. }
  64930. /**
  64931. * Vector4 class created for EulerAngle class conversion to Quaternion
  64932. */
  64933. export class Vector4 {
  64934. /** x value of the vector */
  64935. x: number;
  64936. /** y value of the vector */
  64937. y: number;
  64938. /** z value of the vector */
  64939. z: number;
  64940. /** w value of the vector */
  64941. w: number;
  64942. /**
  64943. * Creates a Vector4 object from the given floats.
  64944. * @param x x value of the vector
  64945. * @param y y value of the vector
  64946. * @param z z value of the vector
  64947. * @param w w value of the vector
  64948. */
  64949. constructor(
  64950. /** x value of the vector */
  64951. x: number,
  64952. /** y value of the vector */
  64953. y: number,
  64954. /** z value of the vector */
  64955. z: number,
  64956. /** w value of the vector */
  64957. w: number);
  64958. /**
  64959. * Returns the string with the Vector4 coordinates.
  64960. * @returns a string containing all the vector values
  64961. */
  64962. toString(): string;
  64963. /**
  64964. * Returns the string "Vector4".
  64965. * @returns "Vector4"
  64966. */
  64967. getClassName(): string;
  64968. /**
  64969. * Returns the Vector4 hash code.
  64970. * @returns a unique hash code
  64971. */
  64972. getHashCode(): number;
  64973. /**
  64974. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64975. * @returns the resulting array
  64976. */
  64977. asArray(): number[];
  64978. /**
  64979. * Populates the given array from the given index with the Vector4 coordinates.
  64980. * @param array array to populate
  64981. * @param index index of the array to start at (default: 0)
  64982. * @returns the Vector4.
  64983. */
  64984. toArray(array: FloatArray, index?: number): Vector4;
  64985. /**
  64986. * Adds the given vector to the current Vector4.
  64987. * @param otherVector the vector to add
  64988. * @returns the updated Vector4.
  64989. */
  64990. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64991. /**
  64992. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64993. * @param otherVector the vector to add
  64994. * @returns the resulting vector
  64995. */
  64996. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64997. /**
  64998. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64999. * @param otherVector the vector to add
  65000. * @param result the vector to store the result
  65001. * @returns the current Vector4.
  65002. */
  65003. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65004. /**
  65005. * Subtract in place the given vector from the current Vector4.
  65006. * @param otherVector the vector to subtract
  65007. * @returns the updated Vector4.
  65008. */
  65009. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  65010. /**
  65011. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  65012. * @param otherVector the vector to add
  65013. * @returns the new vector with the result
  65014. */
  65015. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  65016. /**
  65017. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  65018. * @param otherVector the vector to subtract
  65019. * @param result the vector to store the result
  65020. * @returns the current Vector4.
  65021. */
  65022. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65023. /**
  65024. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  65025. */
  65026. /**
  65027. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  65028. * @param x value to subtract
  65029. * @param y value to subtract
  65030. * @param z value to subtract
  65031. * @param w value to subtract
  65032. * @returns new vector containing the result
  65033. */
  65034. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  65035. /**
  65036. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  65037. * @param x value to subtract
  65038. * @param y value to subtract
  65039. * @param z value to subtract
  65040. * @param w value to subtract
  65041. * @param result the vector to store the result in
  65042. * @returns the current Vector4.
  65043. */
  65044. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  65045. /**
  65046. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  65047. * @returns a new vector with the negated values
  65048. */
  65049. negate(): Vector4;
  65050. /**
  65051. * Multiplies the current Vector4 coordinates by scale (float).
  65052. * @param scale the number to scale with
  65053. * @returns the updated Vector4.
  65054. */
  65055. scaleInPlace(scale: number): Vector4;
  65056. /**
  65057. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  65058. * @param scale the number to scale with
  65059. * @returns a new vector with the result
  65060. */
  65061. scale(scale: number): Vector4;
  65062. /**
  65063. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  65064. * @param scale the number to scale with
  65065. * @param result a vector to store the result in
  65066. * @returns the current Vector4.
  65067. */
  65068. scaleToRef(scale: number, result: Vector4): Vector4;
  65069. /**
  65070. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  65071. * @param scale defines the scale factor
  65072. * @param result defines the Vector4 object where to store the result
  65073. * @returns the unmodified current Vector4
  65074. */
  65075. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  65076. /**
  65077. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  65078. * @param otherVector the vector to compare against
  65079. * @returns true if they are equal
  65080. */
  65081. equals(otherVector: DeepImmutable<Vector4>): boolean;
  65082. /**
  65083. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  65084. * @param otherVector vector to compare against
  65085. * @param epsilon (Default: very small number)
  65086. * @returns true if they are equal
  65087. */
  65088. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  65089. /**
  65090. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  65091. * @param x x value to compare against
  65092. * @param y y value to compare against
  65093. * @param z z value to compare against
  65094. * @param w w value to compare against
  65095. * @returns true if equal
  65096. */
  65097. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  65098. /**
  65099. * Multiplies in place the current Vector4 by the given one.
  65100. * @param otherVector vector to multiple with
  65101. * @returns the updated Vector4.
  65102. */
  65103. multiplyInPlace(otherVector: Vector4): Vector4;
  65104. /**
  65105. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  65106. * @param otherVector vector to multiple with
  65107. * @returns resulting new vector
  65108. */
  65109. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  65110. /**
  65111. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  65112. * @param otherVector vector to multiple with
  65113. * @param result vector to store the result
  65114. * @returns the current Vector4.
  65115. */
  65116. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65117. /**
  65118. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  65119. * @param x x value multiply with
  65120. * @param y y value multiply with
  65121. * @param z z value multiply with
  65122. * @param w w value multiply with
  65123. * @returns resulting new vector
  65124. */
  65125. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  65126. /**
  65127. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  65128. * @param otherVector vector to devide with
  65129. * @returns resulting new vector
  65130. */
  65131. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  65132. /**
  65133. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  65134. * @param otherVector vector to devide with
  65135. * @param result vector to store the result
  65136. * @returns the current Vector4.
  65137. */
  65138. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65139. /**
  65140. * Divides the current Vector3 coordinates by the given ones.
  65141. * @param otherVector vector to devide with
  65142. * @returns the updated Vector3.
  65143. */
  65144. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  65145. /**
  65146. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  65147. * @param other defines the second operand
  65148. * @returns the current updated Vector4
  65149. */
  65150. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  65151. /**
  65152. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  65153. * @param other defines the second operand
  65154. * @returns the current updated Vector4
  65155. */
  65156. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  65157. /**
  65158. * Gets a new Vector4 from current Vector4 floored values
  65159. * @returns a new Vector4
  65160. */
  65161. floor(): Vector4;
  65162. /**
  65163. * Gets a new Vector4 from current Vector3 floored values
  65164. * @returns a new Vector4
  65165. */
  65166. fract(): Vector4;
  65167. /**
  65168. * Returns the Vector4 length (float).
  65169. * @returns the length
  65170. */
  65171. length(): number;
  65172. /**
  65173. * Returns the Vector4 squared length (float).
  65174. * @returns the length squared
  65175. */
  65176. lengthSquared(): number;
  65177. /**
  65178. * Normalizes in place the Vector4.
  65179. * @returns the updated Vector4.
  65180. */
  65181. normalize(): Vector4;
  65182. /**
  65183. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  65184. * @returns this converted to a new vector3
  65185. */
  65186. toVector3(): Vector3;
  65187. /**
  65188. * Returns a new Vector4 copied from the current one.
  65189. * @returns the new cloned vector
  65190. */
  65191. clone(): Vector4;
  65192. /**
  65193. * Updates the current Vector4 with the given one coordinates.
  65194. * @param source the source vector to copy from
  65195. * @returns the updated Vector4.
  65196. */
  65197. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  65198. /**
  65199. * Updates the current Vector4 coordinates with the given floats.
  65200. * @param x float to copy from
  65201. * @param y float to copy from
  65202. * @param z float to copy from
  65203. * @param w float to copy from
  65204. * @returns the updated Vector4.
  65205. */
  65206. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  65207. /**
  65208. * Updates the current Vector4 coordinates with the given floats.
  65209. * @param x float to set from
  65210. * @param y float to set from
  65211. * @param z float to set from
  65212. * @param w float to set from
  65213. * @returns the updated Vector4.
  65214. */
  65215. set(x: number, y: number, z: number, w: number): Vector4;
  65216. /**
  65217. * Copies the given float to the current Vector3 coordinates
  65218. * @param v defines the x, y, z and w coordinates of the operand
  65219. * @returns the current updated Vector3
  65220. */
  65221. setAll(v: number): Vector4;
  65222. /**
  65223. * Returns a new Vector4 set from the starting index of the given array.
  65224. * @param array the array to pull values from
  65225. * @param offset the offset into the array to start at
  65226. * @returns the new vector
  65227. */
  65228. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  65229. /**
  65230. * Updates the given vector "result" from the starting index of the given array.
  65231. * @param array the array to pull values from
  65232. * @param offset the offset into the array to start at
  65233. * @param result the vector to store the result in
  65234. */
  65235. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  65236. /**
  65237. * Updates the given vector "result" from the starting index of the given Float32Array.
  65238. * @param array the array to pull values from
  65239. * @param offset the offset into the array to start at
  65240. * @param result the vector to store the result in
  65241. */
  65242. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  65243. /**
  65244. * Updates the given vector "result" coordinates from the given floats.
  65245. * @param x float to set from
  65246. * @param y float to set from
  65247. * @param z float to set from
  65248. * @param w float to set from
  65249. * @param result the vector to the floats in
  65250. */
  65251. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  65252. /**
  65253. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  65254. * @returns the new vector
  65255. */
  65256. static Zero(): Vector4;
  65257. /**
  65258. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  65259. * @returns the new vector
  65260. */
  65261. static One(): Vector4;
  65262. /**
  65263. * Returns a new normalized Vector4 from the given one.
  65264. * @param vector the vector to normalize
  65265. * @returns the vector
  65266. */
  65267. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  65268. /**
  65269. * Updates the given vector "result" from the normalization of the given one.
  65270. * @param vector the vector to normalize
  65271. * @param result the vector to store the result in
  65272. */
  65273. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  65274. /**
  65275. * Returns a vector with the minimum values from the left and right vectors
  65276. * @param left left vector to minimize
  65277. * @param right right vector to minimize
  65278. * @returns a new vector with the minimum of the left and right vector values
  65279. */
  65280. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  65281. /**
  65282. * Returns a vector with the maximum values from the left and right vectors
  65283. * @param left left vector to maximize
  65284. * @param right right vector to maximize
  65285. * @returns a new vector with the maximum of the left and right vector values
  65286. */
  65287. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  65288. /**
  65289. * Returns the distance (float) between the vectors "value1" and "value2".
  65290. * @param value1 value to calulate the distance between
  65291. * @param value2 value to calulate the distance between
  65292. * @return the distance between the two vectors
  65293. */
  65294. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  65295. /**
  65296. * Returns the squared distance (float) between the vectors "value1" and "value2".
  65297. * @param value1 value to calulate the distance between
  65298. * @param value2 value to calulate the distance between
  65299. * @return the distance between the two vectors squared
  65300. */
  65301. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  65302. /**
  65303. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  65304. * @param value1 value to calulate the center between
  65305. * @param value2 value to calulate the center between
  65306. * @return the center between the two vectors
  65307. */
  65308. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  65309. /**
  65310. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  65311. * This methods computes transformed normalized direction vectors only.
  65312. * @param vector the vector to transform
  65313. * @param transformation the transformation matrix to apply
  65314. * @returns the new vector
  65315. */
  65316. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  65317. /**
  65318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  65319. * This methods computes transformed normalized direction vectors only.
  65320. * @param vector the vector to transform
  65321. * @param transformation the transformation matrix to apply
  65322. * @param result the vector to store the result in
  65323. */
  65324. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  65325. /**
  65326. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  65327. * This methods computes transformed normalized direction vectors only.
  65328. * @param x value to transform
  65329. * @param y value to transform
  65330. * @param z value to transform
  65331. * @param w value to transform
  65332. * @param transformation the transformation matrix to apply
  65333. * @param result the vector to store the results in
  65334. */
  65335. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  65336. /**
  65337. * Creates a new Vector4 from a Vector3
  65338. * @param source defines the source data
  65339. * @param w defines the 4th component (default is 0)
  65340. * @returns a new Vector4
  65341. */
  65342. static FromVector3(source: Vector3, w?: number): Vector4;
  65343. }
  65344. /**
  65345. * Interface for the size containing width and height
  65346. */
  65347. export interface ISize {
  65348. /**
  65349. * Width
  65350. */
  65351. width: number;
  65352. /**
  65353. * Heighht
  65354. */
  65355. height: number;
  65356. }
  65357. /**
  65358. * Size containing widht and height
  65359. */
  65360. export class Size implements ISize {
  65361. /**
  65362. * Width
  65363. */
  65364. width: number;
  65365. /**
  65366. * Height
  65367. */
  65368. height: number;
  65369. /**
  65370. * Creates a Size object from the given width and height (floats).
  65371. * @param width width of the new size
  65372. * @param height height of the new size
  65373. */
  65374. constructor(width: number, height: number);
  65375. /**
  65376. * Returns a string with the Size width and height
  65377. * @returns a string with the Size width and height
  65378. */
  65379. toString(): string;
  65380. /**
  65381. * "Size"
  65382. * @returns the string "Size"
  65383. */
  65384. getClassName(): string;
  65385. /**
  65386. * Returns the Size hash code.
  65387. * @returns a hash code for a unique width and height
  65388. */
  65389. getHashCode(): number;
  65390. /**
  65391. * Updates the current size from the given one.
  65392. * @param src the given size
  65393. */
  65394. copyFrom(src: Size): void;
  65395. /**
  65396. * Updates in place the current Size from the given floats.
  65397. * @param width width of the new size
  65398. * @param height height of the new size
  65399. * @returns the updated Size.
  65400. */
  65401. copyFromFloats(width: number, height: number): Size;
  65402. /**
  65403. * Updates in place the current Size from the given floats.
  65404. * @param width width to set
  65405. * @param height height to set
  65406. * @returns the updated Size.
  65407. */
  65408. set(width: number, height: number): Size;
  65409. /**
  65410. * Multiplies the width and height by numbers
  65411. * @param w factor to multiple the width by
  65412. * @param h factor to multiple the height by
  65413. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  65414. */
  65415. multiplyByFloats(w: number, h: number): Size;
  65416. /**
  65417. * Clones the size
  65418. * @returns a new Size copied from the given one.
  65419. */
  65420. clone(): Size;
  65421. /**
  65422. * True if the current Size and the given one width and height are strictly equal.
  65423. * @param other the other size to compare against
  65424. * @returns True if the current Size and the given one width and height are strictly equal.
  65425. */
  65426. equals(other: Size): boolean;
  65427. /**
  65428. * The surface of the Size : width * height (float).
  65429. */
  65430. readonly surface: number;
  65431. /**
  65432. * Create a new size of zero
  65433. * @returns a new Size set to (0.0, 0.0)
  65434. */
  65435. static Zero(): Size;
  65436. /**
  65437. * Sums the width and height of two sizes
  65438. * @param otherSize size to add to this size
  65439. * @returns a new Size set as the addition result of the current Size and the given one.
  65440. */
  65441. add(otherSize: Size): Size;
  65442. /**
  65443. * Subtracts the width and height of two
  65444. * @param otherSize size to subtract to this size
  65445. * @returns a new Size set as the subtraction result of the given one from the current Size.
  65446. */
  65447. subtract(otherSize: Size): Size;
  65448. /**
  65449. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  65450. * @param start starting size to lerp between
  65451. * @param end end size to lerp between
  65452. * @param amount amount to lerp between the start and end values
  65453. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  65454. */
  65455. static Lerp(start: Size, end: Size, amount: number): Size;
  65456. }
  65457. /**
  65458. * Class used to store quaternion data
  65459. * @see https://en.wikipedia.org/wiki/Quaternion
  65460. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  65461. */
  65462. export class Quaternion {
  65463. /** defines the first component (0 by default) */
  65464. x: number;
  65465. /** defines the second component (0 by default) */
  65466. y: number;
  65467. /** defines the third component (0 by default) */
  65468. z: number;
  65469. /** defines the fourth component (1.0 by default) */
  65470. w: number;
  65471. /**
  65472. * Creates a new Quaternion from the given floats
  65473. * @param x defines the first component (0 by default)
  65474. * @param y defines the second component (0 by default)
  65475. * @param z defines the third component (0 by default)
  65476. * @param w defines the fourth component (1.0 by default)
  65477. */
  65478. constructor(
  65479. /** defines the first component (0 by default) */
  65480. x?: number,
  65481. /** defines the second component (0 by default) */
  65482. y?: number,
  65483. /** defines the third component (0 by default) */
  65484. z?: number,
  65485. /** defines the fourth component (1.0 by default) */
  65486. w?: number);
  65487. /**
  65488. * Gets a string representation for the current quaternion
  65489. * @returns a string with the Quaternion coordinates
  65490. */
  65491. toString(): string;
  65492. /**
  65493. * Gets the class name of the quaternion
  65494. * @returns the string "Quaternion"
  65495. */
  65496. getClassName(): string;
  65497. /**
  65498. * Gets a hash code for this quaternion
  65499. * @returns the quaternion hash code
  65500. */
  65501. getHashCode(): number;
  65502. /**
  65503. * Copy the quaternion to an array
  65504. * @returns a new array populated with 4 elements from the quaternion coordinates
  65505. */
  65506. asArray(): number[];
  65507. /**
  65508. * Check if two quaternions are equals
  65509. * @param otherQuaternion defines the second operand
  65510. * @return true if the current quaternion and the given one coordinates are strictly equals
  65511. */
  65512. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  65513. /**
  65514. * Clone the current quaternion
  65515. * @returns a new quaternion copied from the current one
  65516. */
  65517. clone(): Quaternion;
  65518. /**
  65519. * Copy a quaternion to the current one
  65520. * @param other defines the other quaternion
  65521. * @returns the updated current quaternion
  65522. */
  65523. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  65524. /**
  65525. * Updates the current quaternion with the given float coordinates
  65526. * @param x defines the x coordinate
  65527. * @param y defines the y coordinate
  65528. * @param z defines the z coordinate
  65529. * @param w defines the w coordinate
  65530. * @returns the updated current quaternion
  65531. */
  65532. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  65533. /**
  65534. * Updates the current quaternion from the given float coordinates
  65535. * @param x defines the x coordinate
  65536. * @param y defines the y coordinate
  65537. * @param z defines the z coordinate
  65538. * @param w defines the w coordinate
  65539. * @returns the updated current quaternion
  65540. */
  65541. set(x: number, y: number, z: number, w: number): Quaternion;
  65542. /**
  65543. * Adds two quaternions
  65544. * @param other defines the second operand
  65545. * @returns a new quaternion as the addition result of the given one and the current quaternion
  65546. */
  65547. add(other: DeepImmutable<Quaternion>): Quaternion;
  65548. /**
  65549. * Add a quaternion to the current one
  65550. * @param other defines the quaternion to add
  65551. * @returns the current quaternion
  65552. */
  65553. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  65554. /**
  65555. * Subtract two quaternions
  65556. * @param other defines the second operand
  65557. * @returns a new quaternion as the subtraction result of the given one from the current one
  65558. */
  65559. subtract(other: Quaternion): Quaternion;
  65560. /**
  65561. * Multiplies the current quaternion by a scale factor
  65562. * @param value defines the scale factor
  65563. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  65564. */
  65565. scale(value: number): Quaternion;
  65566. /**
  65567. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  65568. * @param scale defines the scale factor
  65569. * @param result defines the Quaternion object where to store the result
  65570. * @returns the unmodified current quaternion
  65571. */
  65572. scaleToRef(scale: number, result: Quaternion): Quaternion;
  65573. /**
  65574. * Multiplies in place the current quaternion by a scale factor
  65575. * @param value defines the scale factor
  65576. * @returns the current modified quaternion
  65577. */
  65578. scaleInPlace(value: number): Quaternion;
  65579. /**
  65580. * Scale the current quaternion values by a factor and add the result to a given quaternion
  65581. * @param scale defines the scale factor
  65582. * @param result defines the Quaternion object where to store the result
  65583. * @returns the unmodified current quaternion
  65584. */
  65585. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  65586. /**
  65587. * Multiplies two quaternions
  65588. * @param q1 defines the second operand
  65589. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  65590. */
  65591. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  65592. /**
  65593. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  65594. * @param q1 defines the second operand
  65595. * @param result defines the target quaternion
  65596. * @returns the current quaternion
  65597. */
  65598. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  65599. /**
  65600. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  65601. * @param q1 defines the second operand
  65602. * @returns the currentupdated quaternion
  65603. */
  65604. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  65605. /**
  65606. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  65607. * @param ref defines the target quaternion
  65608. * @returns the current quaternion
  65609. */
  65610. conjugateToRef(ref: Quaternion): Quaternion;
  65611. /**
  65612. * Conjugates in place (1-q) the current quaternion
  65613. * @returns the current updated quaternion
  65614. */
  65615. conjugateInPlace(): Quaternion;
  65616. /**
  65617. * Conjugates in place (1-q) the current quaternion
  65618. * @returns a new quaternion
  65619. */
  65620. conjugate(): Quaternion;
  65621. /**
  65622. * Gets length of current quaternion
  65623. * @returns the quaternion length (float)
  65624. */
  65625. length(): number;
  65626. /**
  65627. * Normalize in place the current quaternion
  65628. * @returns the current updated quaternion
  65629. */
  65630. normalize(): Quaternion;
  65631. /**
  65632. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  65633. * @param order is a reserved parameter and is ignore for now
  65634. * @returns a new Vector3 containing the Euler angles
  65635. */
  65636. toEulerAngles(order?: string): Vector3;
  65637. /**
  65638. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65639. * @param result defines the vector which will be filled with the Euler angles
  65640. * @param order is a reserved parameter and is ignore for now
  65641. * @returns the current unchanged quaternion
  65642. */
  65643. toEulerAnglesToRef(result: Vector3): Quaternion;
  65644. /**
  65645. * Updates the given rotation matrix with the current quaternion values
  65646. * @param result defines the target matrix
  65647. * @returns the current unchanged quaternion
  65648. */
  65649. toRotationMatrix(result: Matrix): Quaternion;
  65650. /**
  65651. * Updates the current quaternion from the given rotation matrix values
  65652. * @param matrix defines the source matrix
  65653. * @returns the current updated quaternion
  65654. */
  65655. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65656. /**
  65657. * Creates a new quaternion from a rotation matrix
  65658. * @param matrix defines the source matrix
  65659. * @returns a new quaternion created from the given rotation matrix values
  65660. */
  65661. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65662. /**
  65663. * Updates the given quaternion with the given rotation matrix values
  65664. * @param matrix defines the source matrix
  65665. * @param result defines the target quaternion
  65666. */
  65667. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65668. /**
  65669. * Returns the dot product (float) between the quaternions "left" and "right"
  65670. * @param left defines the left operand
  65671. * @param right defines the right operand
  65672. * @returns the dot product
  65673. */
  65674. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65675. /**
  65676. * Checks if the two quaternions are close to each other
  65677. * @param quat0 defines the first quaternion to check
  65678. * @param quat1 defines the second quaternion to check
  65679. * @returns true if the two quaternions are close to each other
  65680. */
  65681. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65682. /**
  65683. * Creates an empty quaternion
  65684. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65685. */
  65686. static Zero(): Quaternion;
  65687. /**
  65688. * Inverse a given quaternion
  65689. * @param q defines the source quaternion
  65690. * @returns a new quaternion as the inverted current quaternion
  65691. */
  65692. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65693. /**
  65694. * Inverse a given quaternion
  65695. * @param q defines the source quaternion
  65696. * @param result the quaternion the result will be stored in
  65697. * @returns the result quaternion
  65698. */
  65699. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65700. /**
  65701. * Creates an identity quaternion
  65702. * @returns the identity quaternion
  65703. */
  65704. static Identity(): Quaternion;
  65705. /**
  65706. * Gets a boolean indicating if the given quaternion is identity
  65707. * @param quaternion defines the quaternion to check
  65708. * @returns true if the quaternion is identity
  65709. */
  65710. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65711. /**
  65712. * Creates a quaternion from a rotation around an axis
  65713. * @param axis defines the axis to use
  65714. * @param angle defines the angle to use
  65715. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65716. */
  65717. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65718. /**
  65719. * Creates a rotation around an axis and stores it into the given quaternion
  65720. * @param axis defines the axis to use
  65721. * @param angle defines the angle to use
  65722. * @param result defines the target quaternion
  65723. * @returns the target quaternion
  65724. */
  65725. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65726. /**
  65727. * Creates a new quaternion from data stored into an array
  65728. * @param array defines the data source
  65729. * @param offset defines the offset in the source array where the data starts
  65730. * @returns a new quaternion
  65731. */
  65732. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65733. /**
  65734. * Create a quaternion from Euler rotation angles
  65735. * @param x Pitch
  65736. * @param y Yaw
  65737. * @param z Roll
  65738. * @returns the new Quaternion
  65739. */
  65740. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65741. /**
  65742. * Updates a quaternion from Euler rotation angles
  65743. * @param x Pitch
  65744. * @param y Yaw
  65745. * @param z Roll
  65746. * @param result the quaternion to store the result
  65747. * @returns the updated quaternion
  65748. */
  65749. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65750. /**
  65751. * Create a quaternion from Euler rotation vector
  65752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65753. * @returns the new Quaternion
  65754. */
  65755. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65756. /**
  65757. * Updates a quaternion from Euler rotation vector
  65758. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65759. * @param result the quaternion to store the result
  65760. * @returns the updated quaternion
  65761. */
  65762. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65763. /**
  65764. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65765. * @param yaw defines the rotation around Y axis
  65766. * @param pitch defines the rotation around X axis
  65767. * @param roll defines the rotation around Z axis
  65768. * @returns the new quaternion
  65769. */
  65770. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65771. /**
  65772. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65773. * @param yaw defines the rotation around Y axis
  65774. * @param pitch defines the rotation around X axis
  65775. * @param roll defines the rotation around Z axis
  65776. * @param result defines the target quaternion
  65777. */
  65778. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65779. /**
  65780. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65781. * @param alpha defines the rotation around first axis
  65782. * @param beta defines the rotation around second axis
  65783. * @param gamma defines the rotation around third axis
  65784. * @returns the new quaternion
  65785. */
  65786. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65787. /**
  65788. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65789. * @param alpha defines the rotation around first axis
  65790. * @param beta defines the rotation around second axis
  65791. * @param gamma defines the rotation around third axis
  65792. * @param result defines the target quaternion
  65793. */
  65794. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65795. /**
  65796. * 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)
  65797. * @param axis1 defines the first axis
  65798. * @param axis2 defines the second axis
  65799. * @param axis3 defines the third axis
  65800. * @returns the new quaternion
  65801. */
  65802. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65803. /**
  65804. * 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
  65805. * @param axis1 defines the first axis
  65806. * @param axis2 defines the second axis
  65807. * @param axis3 defines the third axis
  65808. * @param ref defines the target quaternion
  65809. */
  65810. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65811. /**
  65812. * Interpolates between two quaternions
  65813. * @param left defines first quaternion
  65814. * @param right defines second quaternion
  65815. * @param amount defines the gradient to use
  65816. * @returns the new interpolated quaternion
  65817. */
  65818. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65819. /**
  65820. * Interpolates between two quaternions and stores it into a target quaternion
  65821. * @param left defines first quaternion
  65822. * @param right defines second quaternion
  65823. * @param amount defines the gradient to use
  65824. * @param result defines the target quaternion
  65825. */
  65826. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65827. /**
  65828. * Interpolate between two quaternions using Hermite interpolation
  65829. * @param value1 defines first quaternion
  65830. * @param tangent1 defines the incoming tangent
  65831. * @param value2 defines second quaternion
  65832. * @param tangent2 defines the outgoing tangent
  65833. * @param amount defines the target quaternion
  65834. * @returns the new interpolated quaternion
  65835. */
  65836. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65837. }
  65838. /**
  65839. * Class used to store matrix data (4x4)
  65840. */
  65841. export class Matrix {
  65842. private static _updateFlagSeed;
  65843. private static _identityReadOnly;
  65844. private _isIdentity;
  65845. private _isIdentityDirty;
  65846. private _isIdentity3x2;
  65847. private _isIdentity3x2Dirty;
  65848. /**
  65849. * Gets the update flag of the matrix which is an unique number for the matrix.
  65850. * It will be incremented every time the matrix data change.
  65851. * You can use it to speed the comparison between two versions of the same matrix.
  65852. */
  65853. updateFlag: number;
  65854. private readonly _m;
  65855. /**
  65856. * Gets the internal data of the matrix
  65857. */
  65858. readonly m: DeepImmutable<Float32Array>;
  65859. /** @hidden */
  65860. _markAsUpdated(): void;
  65861. /** @hidden */
  65862. private _updateIdentityStatus;
  65863. /**
  65864. * Creates an empty matrix (filled with zeros)
  65865. */
  65866. constructor();
  65867. /**
  65868. * Check if the current matrix is identity
  65869. * @returns true is the matrix is the identity matrix
  65870. */
  65871. isIdentity(): boolean;
  65872. /**
  65873. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65874. * @returns true is the matrix is the identity matrix
  65875. */
  65876. isIdentityAs3x2(): boolean;
  65877. /**
  65878. * Gets the determinant of the matrix
  65879. * @returns the matrix determinant
  65880. */
  65881. determinant(): number;
  65882. /**
  65883. * Returns the matrix as a Float32Array
  65884. * @returns the matrix underlying array
  65885. */
  65886. toArray(): DeepImmutable<Float32Array>;
  65887. /**
  65888. * Returns the matrix as a Float32Array
  65889. * @returns the matrix underlying array.
  65890. */
  65891. asArray(): DeepImmutable<Float32Array>;
  65892. /**
  65893. * Inverts the current matrix in place
  65894. * @returns the current inverted matrix
  65895. */
  65896. invert(): Matrix;
  65897. /**
  65898. * Sets all the matrix elements to zero
  65899. * @returns the current matrix
  65900. */
  65901. reset(): Matrix;
  65902. /**
  65903. * Adds the current matrix with a second one
  65904. * @param other defines the matrix to add
  65905. * @returns a new matrix as the addition of the current matrix and the given one
  65906. */
  65907. add(other: DeepImmutable<Matrix>): Matrix;
  65908. /**
  65909. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65910. * @param other defines the matrix to add
  65911. * @param result defines the target matrix
  65912. * @returns the current matrix
  65913. */
  65914. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65915. /**
  65916. * Adds in place the given matrix to the current matrix
  65917. * @param other defines the second operand
  65918. * @returns the current updated matrix
  65919. */
  65920. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65921. /**
  65922. * Sets the given matrix to the current inverted Matrix
  65923. * @param other defines the target matrix
  65924. * @returns the unmodified current matrix
  65925. */
  65926. invertToRef(other: Matrix): Matrix;
  65927. /**
  65928. * add a value at the specified position in the current Matrix
  65929. * @param index the index of the value within the matrix. between 0 and 15.
  65930. * @param value the value to be added
  65931. * @returns the current updated matrix
  65932. */
  65933. addAtIndex(index: number, value: number): Matrix;
  65934. /**
  65935. * mutiply the specified position in the current Matrix by a value
  65936. * @param index the index of the value within the matrix. between 0 and 15.
  65937. * @param value the value to be added
  65938. * @returns the current updated matrix
  65939. */
  65940. multiplyAtIndex(index: number, value: number): Matrix;
  65941. /**
  65942. * Inserts the translation vector (using 3 floats) in the current matrix
  65943. * @param x defines the 1st component of the translation
  65944. * @param y defines the 2nd component of the translation
  65945. * @param z defines the 3rd component of the translation
  65946. * @returns the current updated matrix
  65947. */
  65948. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65949. /**
  65950. * Adds the translation vector (using 3 floats) in the current matrix
  65951. * @param x defines the 1st component of the translation
  65952. * @param y defines the 2nd component of the translation
  65953. * @param z defines the 3rd component of the translation
  65954. * @returns the current updated matrix
  65955. */
  65956. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65957. /**
  65958. * Inserts the translation vector in the current matrix
  65959. * @param vector3 defines the translation to insert
  65960. * @returns the current updated matrix
  65961. */
  65962. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65963. /**
  65964. * Gets the translation value of the current matrix
  65965. * @returns a new Vector3 as the extracted translation from the matrix
  65966. */
  65967. getTranslation(): Vector3;
  65968. /**
  65969. * Fill a Vector3 with the extracted translation from the matrix
  65970. * @param result defines the Vector3 where to store the translation
  65971. * @returns the current matrix
  65972. */
  65973. getTranslationToRef(result: Vector3): Matrix;
  65974. /**
  65975. * Remove rotation and scaling part from the matrix
  65976. * @returns the updated matrix
  65977. */
  65978. removeRotationAndScaling(): Matrix;
  65979. /**
  65980. * Multiply two matrices
  65981. * @param other defines the second operand
  65982. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65983. */
  65984. multiply(other: DeepImmutable<Matrix>): Matrix;
  65985. /**
  65986. * Copy the current matrix from the given one
  65987. * @param other defines the source matrix
  65988. * @returns the current updated matrix
  65989. */
  65990. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65991. /**
  65992. * Populates the given array from the starting index with the current matrix values
  65993. * @param array defines the target array
  65994. * @param offset defines the offset in the target array where to start storing values
  65995. * @returns the current matrix
  65996. */
  65997. copyToArray(array: Float32Array, offset?: number): Matrix;
  65998. /**
  65999. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  66000. * @param other defines the second operand
  66001. * @param result defines the matrix where to store the multiplication
  66002. * @returns the current matrix
  66003. */
  66004. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  66005. /**
  66006. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  66007. * @param other defines the second operand
  66008. * @param result defines the array where to store the multiplication
  66009. * @param offset defines the offset in the target array where to start storing values
  66010. * @returns the current matrix
  66011. */
  66012. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  66013. /**
  66014. * Check equality between this matrix and a second one
  66015. * @param value defines the second matrix to compare
  66016. * @returns true is the current matrix and the given one values are strictly equal
  66017. */
  66018. equals(value: DeepImmutable<Matrix>): boolean;
  66019. /**
  66020. * Clone the current matrix
  66021. * @returns a new matrix from the current matrix
  66022. */
  66023. clone(): Matrix;
  66024. /**
  66025. * Returns the name of the current matrix class
  66026. * @returns the string "Matrix"
  66027. */
  66028. getClassName(): string;
  66029. /**
  66030. * Gets the hash code of the current matrix
  66031. * @returns the hash code
  66032. */
  66033. getHashCode(): number;
  66034. /**
  66035. * Decomposes the current Matrix into a translation, rotation and scaling components
  66036. * @param scale defines the scale vector3 given as a reference to update
  66037. * @param rotation defines the rotation quaternion given as a reference to update
  66038. * @param translation defines the translation vector3 given as a reference to update
  66039. * @returns true if operation was successful
  66040. */
  66041. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  66042. /**
  66043. * Gets specific row of the matrix
  66044. * @param index defines the number of the row to get
  66045. * @returns the index-th row of the current matrix as a new Vector4
  66046. */
  66047. getRow(index: number): Nullable<Vector4>;
  66048. /**
  66049. * Sets the index-th row of the current matrix to the vector4 values
  66050. * @param index defines the number of the row to set
  66051. * @param row defines the target vector4
  66052. * @returns the updated current matrix
  66053. */
  66054. setRow(index: number, row: Vector4): Matrix;
  66055. /**
  66056. * Compute the transpose of the matrix
  66057. * @returns the new transposed matrix
  66058. */
  66059. transpose(): Matrix;
  66060. /**
  66061. * Compute the transpose of the matrix and store it in a given matrix
  66062. * @param result defines the target matrix
  66063. * @returns the current matrix
  66064. */
  66065. transposeToRef(result: Matrix): Matrix;
  66066. /**
  66067. * Sets the index-th row of the current matrix with the given 4 x float values
  66068. * @param index defines the row index
  66069. * @param x defines the x component to set
  66070. * @param y defines the y component to set
  66071. * @param z defines the z component to set
  66072. * @param w defines the w component to set
  66073. * @returns the updated current matrix
  66074. */
  66075. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  66076. /**
  66077. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  66078. * @param scale defines the scale factor
  66079. * @returns a new matrix
  66080. */
  66081. scale(scale: number): Matrix;
  66082. /**
  66083. * Scale the current matrix values by a factor to a given result matrix
  66084. * @param scale defines the scale factor
  66085. * @param result defines the matrix to store the result
  66086. * @returns the current matrix
  66087. */
  66088. scaleToRef(scale: number, result: Matrix): Matrix;
  66089. /**
  66090. * Scale the current matrix values by a factor and add the result to a given matrix
  66091. * @param scale defines the scale factor
  66092. * @param result defines the Matrix to store the result
  66093. * @returns the current matrix
  66094. */
  66095. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  66096. /**
  66097. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  66098. * @param ref matrix to store the result
  66099. */
  66100. toNormalMatrix(ref: Matrix): void;
  66101. /**
  66102. * Gets only rotation part of the current matrix
  66103. * @returns a new matrix sets to the extracted rotation matrix from the current one
  66104. */
  66105. getRotationMatrix(): Matrix;
  66106. /**
  66107. * Extracts the rotation matrix from the current one and sets it as the given "result"
  66108. * @param result defines the target matrix to store data to
  66109. * @returns the current matrix
  66110. */
  66111. getRotationMatrixToRef(result: Matrix): Matrix;
  66112. /**
  66113. * Toggles model matrix from being right handed to left handed in place and vice versa
  66114. */
  66115. toggleModelMatrixHandInPlace(): void;
  66116. /**
  66117. * Toggles projection matrix from being right handed to left handed in place and vice versa
  66118. */
  66119. toggleProjectionMatrixHandInPlace(): void;
  66120. /**
  66121. * Creates a matrix from an array
  66122. * @param array defines the source array
  66123. * @param offset defines an offset in the source array
  66124. * @returns a new Matrix set from the starting index of the given array
  66125. */
  66126. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  66127. /**
  66128. * Copy the content of an array into a given matrix
  66129. * @param array defines the source array
  66130. * @param offset defines an offset in the source array
  66131. * @param result defines the target matrix
  66132. */
  66133. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  66134. /**
  66135. * Stores an array into a matrix after having multiplied each component by a given factor
  66136. * @param array defines the source array
  66137. * @param offset defines the offset in the source array
  66138. * @param scale defines the scaling factor
  66139. * @param result defines the target matrix
  66140. */
  66141. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  66142. /**
  66143. * Gets an identity matrix that must not be updated
  66144. */
  66145. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  66146. /**
  66147. * Stores a list of values (16) inside a given matrix
  66148. * @param initialM11 defines 1st value of 1st row
  66149. * @param initialM12 defines 2nd value of 1st row
  66150. * @param initialM13 defines 3rd value of 1st row
  66151. * @param initialM14 defines 4th value of 1st row
  66152. * @param initialM21 defines 1st value of 2nd row
  66153. * @param initialM22 defines 2nd value of 2nd row
  66154. * @param initialM23 defines 3rd value of 2nd row
  66155. * @param initialM24 defines 4th value of 2nd row
  66156. * @param initialM31 defines 1st value of 3rd row
  66157. * @param initialM32 defines 2nd value of 3rd row
  66158. * @param initialM33 defines 3rd value of 3rd row
  66159. * @param initialM34 defines 4th value of 3rd row
  66160. * @param initialM41 defines 1st value of 4th row
  66161. * @param initialM42 defines 2nd value of 4th row
  66162. * @param initialM43 defines 3rd value of 4th row
  66163. * @param initialM44 defines 4th value of 4th row
  66164. * @param result defines the target matrix
  66165. */
  66166. 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;
  66167. /**
  66168. * Creates new matrix from a list of values (16)
  66169. * @param initialM11 defines 1st value of 1st row
  66170. * @param initialM12 defines 2nd value of 1st row
  66171. * @param initialM13 defines 3rd value of 1st row
  66172. * @param initialM14 defines 4th value of 1st row
  66173. * @param initialM21 defines 1st value of 2nd row
  66174. * @param initialM22 defines 2nd value of 2nd row
  66175. * @param initialM23 defines 3rd value of 2nd row
  66176. * @param initialM24 defines 4th value of 2nd row
  66177. * @param initialM31 defines 1st value of 3rd row
  66178. * @param initialM32 defines 2nd value of 3rd row
  66179. * @param initialM33 defines 3rd value of 3rd row
  66180. * @param initialM34 defines 4th value of 3rd row
  66181. * @param initialM41 defines 1st value of 4th row
  66182. * @param initialM42 defines 2nd value of 4th row
  66183. * @param initialM43 defines 3rd value of 4th row
  66184. * @param initialM44 defines 4th value of 4th row
  66185. * @returns the new matrix
  66186. */
  66187. 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;
  66188. /**
  66189. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  66190. * @param scale defines the scale vector3
  66191. * @param rotation defines the rotation quaternion
  66192. * @param translation defines the translation vector3
  66193. * @returns a new matrix
  66194. */
  66195. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  66196. /**
  66197. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  66198. * @param scale defines the scale vector3
  66199. * @param rotation defines the rotation quaternion
  66200. * @param translation defines the translation vector3
  66201. * @param result defines the target matrix
  66202. */
  66203. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  66204. /**
  66205. * Creates a new identity matrix
  66206. * @returns a new identity matrix
  66207. */
  66208. static Identity(): Matrix;
  66209. /**
  66210. * Creates a new identity matrix and stores the result in a given matrix
  66211. * @param result defines the target matrix
  66212. */
  66213. static IdentityToRef(result: Matrix): void;
  66214. /**
  66215. * Creates a new zero matrix
  66216. * @returns a new zero matrix
  66217. */
  66218. static Zero(): Matrix;
  66219. /**
  66220. * Creates a new rotation matrix for "angle" radians around the X axis
  66221. * @param angle defines the angle (in radians) to use
  66222. * @return the new matrix
  66223. */
  66224. static RotationX(angle: number): Matrix;
  66225. /**
  66226. * Creates a new matrix as the invert of a given matrix
  66227. * @param source defines the source matrix
  66228. * @returns the new matrix
  66229. */
  66230. static Invert(source: DeepImmutable<Matrix>): Matrix;
  66231. /**
  66232. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  66233. * @param angle defines the angle (in radians) to use
  66234. * @param result defines the target matrix
  66235. */
  66236. static RotationXToRef(angle: number, result: Matrix): void;
  66237. /**
  66238. * Creates a new rotation matrix for "angle" radians around the Y axis
  66239. * @param angle defines the angle (in radians) to use
  66240. * @return the new matrix
  66241. */
  66242. static RotationY(angle: number): Matrix;
  66243. /**
  66244. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  66245. * @param angle defines the angle (in radians) to use
  66246. * @param result defines the target matrix
  66247. */
  66248. static RotationYToRef(angle: number, result: Matrix): void;
  66249. /**
  66250. * Creates a new rotation matrix for "angle" radians around the Z axis
  66251. * @param angle defines the angle (in radians) to use
  66252. * @return the new matrix
  66253. */
  66254. static RotationZ(angle: number): Matrix;
  66255. /**
  66256. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  66257. * @param angle defines the angle (in radians) to use
  66258. * @param result defines the target matrix
  66259. */
  66260. static RotationZToRef(angle: number, result: Matrix): void;
  66261. /**
  66262. * Creates a new rotation matrix for "angle" radians around the given axis
  66263. * @param axis defines the axis to use
  66264. * @param angle defines the angle (in radians) to use
  66265. * @return the new matrix
  66266. */
  66267. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  66268. /**
  66269. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  66270. * @param axis defines the axis to use
  66271. * @param angle defines the angle (in radians) to use
  66272. * @param result defines the target matrix
  66273. */
  66274. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  66275. /**
  66276. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  66277. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  66278. * @param from defines the vector to align
  66279. * @param to defines the vector to align to
  66280. * @param result defines the target matrix
  66281. */
  66282. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  66283. /**
  66284. * Creates a rotation matrix
  66285. * @param yaw defines the yaw angle in radians (Y axis)
  66286. * @param pitch defines the pitch angle in radians (X axis)
  66287. * @param roll defines the roll angle in radians (X axis)
  66288. * @returns the new rotation matrix
  66289. */
  66290. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  66291. /**
  66292. * Creates a rotation matrix and stores it in a given matrix
  66293. * @param yaw defines the yaw angle in radians (Y axis)
  66294. * @param pitch defines the pitch angle in radians (X axis)
  66295. * @param roll defines the roll angle in radians (X axis)
  66296. * @param result defines the target matrix
  66297. */
  66298. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  66299. /**
  66300. * Creates a scaling matrix
  66301. * @param x defines the scale factor on X axis
  66302. * @param y defines the scale factor on Y axis
  66303. * @param z defines the scale factor on Z axis
  66304. * @returns the new matrix
  66305. */
  66306. static Scaling(x: number, y: number, z: number): Matrix;
  66307. /**
  66308. * Creates a scaling matrix and stores it in a given matrix
  66309. * @param x defines the scale factor on X axis
  66310. * @param y defines the scale factor on Y axis
  66311. * @param z defines the scale factor on Z axis
  66312. * @param result defines the target matrix
  66313. */
  66314. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  66315. /**
  66316. * Creates a translation matrix
  66317. * @param x defines the translation on X axis
  66318. * @param y defines the translation on Y axis
  66319. * @param z defines the translationon Z axis
  66320. * @returns the new matrix
  66321. */
  66322. static Translation(x: number, y: number, z: number): Matrix;
  66323. /**
  66324. * Creates a translation matrix and stores it in a given matrix
  66325. * @param x defines the translation on X axis
  66326. * @param y defines the translation on Y axis
  66327. * @param z defines the translationon Z axis
  66328. * @param result defines the target matrix
  66329. */
  66330. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  66331. /**
  66332. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66333. * @param startValue defines the start value
  66334. * @param endValue defines the end value
  66335. * @param gradient defines the gradient factor
  66336. * @returns the new matrix
  66337. */
  66338. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66339. /**
  66340. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66341. * @param startValue defines the start value
  66342. * @param endValue defines the end value
  66343. * @param gradient defines the gradient factor
  66344. * @param result defines the Matrix object where to store data
  66345. */
  66346. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66347. /**
  66348. * Builds a new matrix whose values are computed by:
  66349. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66350. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66351. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66352. * @param startValue defines the first matrix
  66353. * @param endValue defines the second matrix
  66354. * @param gradient defines the gradient between the two matrices
  66355. * @returns the new matrix
  66356. */
  66357. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66358. /**
  66359. * Update a matrix to values which are computed by:
  66360. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66361. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66362. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66363. * @param startValue defines the first matrix
  66364. * @param endValue defines the second matrix
  66365. * @param gradient defines the gradient between the two matrices
  66366. * @param result defines the target matrix
  66367. */
  66368. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66369. /**
  66370. * 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"
  66371. * This function works in left handed mode
  66372. * @param eye defines the final position of the entity
  66373. * @param target defines where the entity should look at
  66374. * @param up defines the up vector for the entity
  66375. * @returns the new matrix
  66376. */
  66377. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66378. /**
  66379. * 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".
  66380. * This function works in left handed mode
  66381. * @param eye defines the final position of the entity
  66382. * @param target defines where the entity should look at
  66383. * @param up defines the up vector for the entity
  66384. * @param result defines the target matrix
  66385. */
  66386. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66387. /**
  66388. * 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"
  66389. * This function works in right handed mode
  66390. * @param eye defines the final position of the entity
  66391. * @param target defines where the entity should look at
  66392. * @param up defines the up vector for the entity
  66393. * @returns the new matrix
  66394. */
  66395. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66396. /**
  66397. * 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".
  66398. * This function works in right handed mode
  66399. * @param eye defines the final position of the entity
  66400. * @param target defines where the entity should look at
  66401. * @param up defines the up vector for the entity
  66402. * @param result defines the target matrix
  66403. */
  66404. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66405. /**
  66406. * Create a left-handed orthographic projection matrix
  66407. * @param width defines the viewport width
  66408. * @param height defines the viewport height
  66409. * @param znear defines the near clip plane
  66410. * @param zfar defines the far clip plane
  66411. * @returns a new matrix as a left-handed orthographic projection matrix
  66412. */
  66413. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66414. /**
  66415. * Store a left-handed orthographic projection to a given matrix
  66416. * @param width defines the viewport width
  66417. * @param height defines the viewport height
  66418. * @param znear defines the near clip plane
  66419. * @param zfar defines the far clip plane
  66420. * @param result defines the target matrix
  66421. */
  66422. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  66423. /**
  66424. * Create a left-handed orthographic projection matrix
  66425. * @param left defines the viewport left coordinate
  66426. * @param right defines the viewport right coordinate
  66427. * @param bottom defines the viewport bottom coordinate
  66428. * @param top defines the viewport top coordinate
  66429. * @param znear defines the near clip plane
  66430. * @param zfar defines the far clip plane
  66431. * @returns a new matrix as a left-handed orthographic projection matrix
  66432. */
  66433. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66434. /**
  66435. * Stores a left-handed orthographic projection into a given matrix
  66436. * @param left defines the viewport left coordinate
  66437. * @param right defines the viewport right coordinate
  66438. * @param bottom defines the viewport bottom coordinate
  66439. * @param top defines the viewport top coordinate
  66440. * @param znear defines the near clip plane
  66441. * @param zfar defines the far clip plane
  66442. * @param result defines the target matrix
  66443. */
  66444. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66445. /**
  66446. * Creates a right-handed orthographic projection matrix
  66447. * @param left defines the viewport left coordinate
  66448. * @param right defines the viewport right coordinate
  66449. * @param bottom defines the viewport bottom coordinate
  66450. * @param top defines the viewport top coordinate
  66451. * @param znear defines the near clip plane
  66452. * @param zfar defines the far clip plane
  66453. * @returns a new matrix as a right-handed orthographic projection matrix
  66454. */
  66455. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66456. /**
  66457. * Stores a right-handed orthographic projection into a given matrix
  66458. * @param left defines the viewport left coordinate
  66459. * @param right defines the viewport right coordinate
  66460. * @param bottom defines the viewport bottom coordinate
  66461. * @param top defines the viewport top coordinate
  66462. * @param znear defines the near clip plane
  66463. * @param zfar defines the far clip plane
  66464. * @param result defines the target matrix
  66465. */
  66466. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66467. /**
  66468. * Creates a left-handed perspective projection matrix
  66469. * @param width defines the viewport width
  66470. * @param height defines the viewport height
  66471. * @param znear defines the near clip plane
  66472. * @param zfar defines the far clip plane
  66473. * @returns a new matrix as a left-handed perspective projection matrix
  66474. */
  66475. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66476. /**
  66477. * Creates a left-handed perspective projection matrix
  66478. * @param fov defines the horizontal field of view
  66479. * @param aspect defines the aspect ratio
  66480. * @param znear defines the near clip plane
  66481. * @param zfar defines the far clip plane
  66482. * @returns a new matrix as a left-handed perspective projection matrix
  66483. */
  66484. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66485. /**
  66486. * Stores a left-handed perspective projection into a given matrix
  66487. * @param fov defines the horizontal field of view
  66488. * @param aspect defines the aspect ratio
  66489. * @param znear defines the near clip plane
  66490. * @param zfar defines the far clip plane
  66491. * @param result defines the target matrix
  66492. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66493. */
  66494. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66495. /**
  66496. * Creates a right-handed perspective projection matrix
  66497. * @param fov defines the horizontal field of view
  66498. * @param aspect defines the aspect ratio
  66499. * @param znear defines the near clip plane
  66500. * @param zfar defines the far clip plane
  66501. * @returns a new matrix as a right-handed perspective projection matrix
  66502. */
  66503. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66504. /**
  66505. * Stores a right-handed perspective projection into a given matrix
  66506. * @param fov defines the horizontal field of view
  66507. * @param aspect defines the aspect ratio
  66508. * @param znear defines the near clip plane
  66509. * @param zfar defines the far clip plane
  66510. * @param result defines the target matrix
  66511. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66512. */
  66513. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66514. /**
  66515. * Stores a perspective projection for WebVR info a given matrix
  66516. * @param fov defines the field of view
  66517. * @param znear defines the near clip plane
  66518. * @param zfar defines the far clip plane
  66519. * @param result defines the target matrix
  66520. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  66521. */
  66522. static PerspectiveFovWebVRToRef(fov: {
  66523. upDegrees: number;
  66524. downDegrees: number;
  66525. leftDegrees: number;
  66526. rightDegrees: number;
  66527. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  66528. /**
  66529. * Computes a complete transformation matrix
  66530. * @param viewport defines the viewport to use
  66531. * @param world defines the world matrix
  66532. * @param view defines the view matrix
  66533. * @param projection defines the projection matrix
  66534. * @param zmin defines the near clip plane
  66535. * @param zmax defines the far clip plane
  66536. * @returns the transformation matrix
  66537. */
  66538. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  66539. /**
  66540. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  66541. * @param matrix defines the matrix to use
  66542. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  66543. */
  66544. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  66545. /**
  66546. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  66547. * @param matrix defines the matrix to use
  66548. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  66549. */
  66550. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  66551. /**
  66552. * Compute the transpose of a given matrix
  66553. * @param matrix defines the matrix to transpose
  66554. * @returns the new matrix
  66555. */
  66556. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  66557. /**
  66558. * Compute the transpose of a matrix and store it in a target matrix
  66559. * @param matrix defines the matrix to transpose
  66560. * @param result defines the target matrix
  66561. */
  66562. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  66563. /**
  66564. * Computes a reflection matrix from a plane
  66565. * @param plane defines the reflection plane
  66566. * @returns a new matrix
  66567. */
  66568. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  66569. /**
  66570. * Computes a reflection matrix from a plane
  66571. * @param plane defines the reflection plane
  66572. * @param result defines the target matrix
  66573. */
  66574. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  66575. /**
  66576. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  66577. * @param xaxis defines the value of the 1st axis
  66578. * @param yaxis defines the value of the 2nd axis
  66579. * @param zaxis defines the value of the 3rd axis
  66580. * @param result defines the target matrix
  66581. */
  66582. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  66583. /**
  66584. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  66585. * @param quat defines the quaternion to use
  66586. * @param result defines the target matrix
  66587. */
  66588. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  66589. }
  66590. /**
  66591. * Represens a plane by the equation ax + by + cz + d = 0
  66592. */
  66593. export class Plane {
  66594. /**
  66595. * Normal of the plane (a,b,c)
  66596. */
  66597. normal: Vector3;
  66598. /**
  66599. * d component of the plane
  66600. */
  66601. d: number;
  66602. /**
  66603. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  66604. * @param a a component of the plane
  66605. * @param b b component of the plane
  66606. * @param c c component of the plane
  66607. * @param d d component of the plane
  66608. */
  66609. constructor(a: number, b: number, c: number, d: number);
  66610. /**
  66611. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  66612. */
  66613. asArray(): number[];
  66614. /**
  66615. * @returns a new plane copied from the current Plane.
  66616. */
  66617. clone(): Plane;
  66618. /**
  66619. * @returns the string "Plane".
  66620. */
  66621. getClassName(): string;
  66622. /**
  66623. * @returns the Plane hash code.
  66624. */
  66625. getHashCode(): number;
  66626. /**
  66627. * Normalize the current Plane in place.
  66628. * @returns the updated Plane.
  66629. */
  66630. normalize(): Plane;
  66631. /**
  66632. * Applies a transformation the plane and returns the result
  66633. * @param transformation the transformation matrix to be applied to the plane
  66634. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  66635. */
  66636. transform(transformation: DeepImmutable<Matrix>): Plane;
  66637. /**
  66638. * Calcualtte the dot product between the point and the plane normal
  66639. * @param point point to calculate the dot product with
  66640. * @returns the dot product (float) of the point coordinates and the plane normal.
  66641. */
  66642. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66643. /**
  66644. * Updates the current Plane from the plane defined by the three given points.
  66645. * @param point1 one of the points used to contruct the plane
  66646. * @param point2 one of the points used to contruct the plane
  66647. * @param point3 one of the points used to contruct the plane
  66648. * @returns the updated Plane.
  66649. */
  66650. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66651. /**
  66652. * Checks if the plane is facing a given direction
  66653. * @param direction the direction to check if the plane is facing
  66654. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66655. * @returns True is the vector "direction" is the same side than the plane normal.
  66656. */
  66657. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66658. /**
  66659. * Calculates the distance to a point
  66660. * @param point point to calculate distance to
  66661. * @returns the signed distance (float) from the given point to the Plane.
  66662. */
  66663. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66664. /**
  66665. * Creates a plane from an array
  66666. * @param array the array to create a plane from
  66667. * @returns a new Plane from the given array.
  66668. */
  66669. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66670. /**
  66671. * Creates a plane from three points
  66672. * @param point1 point used to create the plane
  66673. * @param point2 point used to create the plane
  66674. * @param point3 point used to create the plane
  66675. * @returns a new Plane defined by the three given points.
  66676. */
  66677. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66678. /**
  66679. * Creates a plane from an origin point and a normal
  66680. * @param origin origin of the plane to be constructed
  66681. * @param normal normal of the plane to be constructed
  66682. * @returns a new Plane the normal vector to this plane at the given origin point.
  66683. * Note : the vector "normal" is updated because normalized.
  66684. */
  66685. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66686. /**
  66687. * Calculates the distance from a plane and a point
  66688. * @param origin origin of the plane to be constructed
  66689. * @param normal normal of the plane to be constructed
  66690. * @param point point to calculate distance to
  66691. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66692. */
  66693. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66694. }
  66695. /**
  66696. * Class used to represent a viewport on screen
  66697. */
  66698. export class Viewport {
  66699. /** viewport left coordinate */
  66700. x: number;
  66701. /** viewport top coordinate */
  66702. y: number;
  66703. /**viewport width */
  66704. width: number;
  66705. /** viewport height */
  66706. height: number;
  66707. /**
  66708. * Creates a Viewport object located at (x, y) and sized (width, height)
  66709. * @param x defines viewport left coordinate
  66710. * @param y defines viewport top coordinate
  66711. * @param width defines the viewport width
  66712. * @param height defines the viewport height
  66713. */
  66714. constructor(
  66715. /** viewport left coordinate */
  66716. x: number,
  66717. /** viewport top coordinate */
  66718. y: number,
  66719. /**viewport width */
  66720. width: number,
  66721. /** viewport height */
  66722. height: number);
  66723. /**
  66724. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66725. * @param renderWidth defines the rendering width
  66726. * @param renderHeight defines the rendering height
  66727. * @returns a new Viewport
  66728. */
  66729. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66730. /**
  66731. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66732. * @param renderWidth defines the rendering width
  66733. * @param renderHeight defines the rendering height
  66734. * @param ref defines the target viewport
  66735. * @returns the current viewport
  66736. */
  66737. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66738. /**
  66739. * Returns a new Viewport copied from the current one
  66740. * @returns a new Viewport
  66741. */
  66742. clone(): Viewport;
  66743. }
  66744. /**
  66745. * Reprasents a camera frustum
  66746. */
  66747. export class Frustum {
  66748. /**
  66749. * Gets the planes representing the frustum
  66750. * @param transform matrix to be applied to the returned planes
  66751. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66752. */
  66753. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66754. /**
  66755. * Gets the near frustum plane transformed by the transform matrix
  66756. * @param transform transformation matrix to be applied to the resulting frustum plane
  66757. * @param frustumPlane the resuling frustum plane
  66758. */
  66759. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66760. /**
  66761. * Gets the far frustum plane transformed by the transform matrix
  66762. * @param transform transformation matrix to be applied to the resulting frustum plane
  66763. * @param frustumPlane the resuling frustum plane
  66764. */
  66765. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66766. /**
  66767. * Gets the left frustum plane transformed by the transform matrix
  66768. * @param transform transformation matrix to be applied to the resulting frustum plane
  66769. * @param frustumPlane the resuling frustum plane
  66770. */
  66771. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66772. /**
  66773. * Gets the right frustum plane transformed by the transform matrix
  66774. * @param transform transformation matrix to be applied to the resulting frustum plane
  66775. * @param frustumPlane the resuling frustum plane
  66776. */
  66777. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66778. /**
  66779. * Gets the top frustum plane transformed by the transform matrix
  66780. * @param transform transformation matrix to be applied to the resulting frustum plane
  66781. * @param frustumPlane the resuling frustum plane
  66782. */
  66783. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66784. /**
  66785. * Gets the bottom frustum plane transformed by the transform matrix
  66786. * @param transform transformation matrix to be applied to the resulting frustum plane
  66787. * @param frustumPlane the resuling frustum plane
  66788. */
  66789. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66790. /**
  66791. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66792. * @param transform transformation matrix to be applied to the resulting frustum planes
  66793. * @param frustumPlanes the resuling frustum planes
  66794. */
  66795. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66796. }
  66797. /** Defines supported spaces */
  66798. export enum Space {
  66799. /** Local (object) space */
  66800. LOCAL = 0,
  66801. /** World space */
  66802. WORLD = 1,
  66803. /** Bone space */
  66804. BONE = 2
  66805. }
  66806. /** Defines the 3 main axes */
  66807. export class Axis {
  66808. /** X axis */
  66809. static X: Vector3;
  66810. /** Y axis */
  66811. static Y: Vector3;
  66812. /** Z axis */
  66813. static Z: Vector3;
  66814. }
  66815. /** Class used to represent a Bezier curve */
  66816. export class BezierCurve {
  66817. /**
  66818. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66819. * @param t defines the time
  66820. * @param x1 defines the left coordinate on X axis
  66821. * @param y1 defines the left coordinate on Y axis
  66822. * @param x2 defines the right coordinate on X axis
  66823. * @param y2 defines the right coordinate on Y axis
  66824. * @returns the interpolated value
  66825. */
  66826. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66827. }
  66828. /**
  66829. * Defines potential orientation for back face culling
  66830. */
  66831. export enum Orientation {
  66832. /**
  66833. * Clockwise
  66834. */
  66835. CW = 0,
  66836. /** Counter clockwise */
  66837. CCW = 1
  66838. }
  66839. /**
  66840. * Defines angle representation
  66841. */
  66842. export class Angle {
  66843. private _radians;
  66844. /**
  66845. * Creates an Angle object of "radians" radians (float).
  66846. * @param radians the angle in radians
  66847. */
  66848. constructor(radians: number);
  66849. /**
  66850. * Get value in degrees
  66851. * @returns the Angle value in degrees (float)
  66852. */
  66853. degrees(): number;
  66854. /**
  66855. * Get value in radians
  66856. * @returns the Angle value in radians (float)
  66857. */
  66858. radians(): number;
  66859. /**
  66860. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66861. * @param a defines first vector
  66862. * @param b defines second vector
  66863. * @returns a new Angle
  66864. */
  66865. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66866. /**
  66867. * Gets a new Angle object from the given float in radians
  66868. * @param radians defines the angle value in radians
  66869. * @returns a new Angle
  66870. */
  66871. static FromRadians(radians: number): Angle;
  66872. /**
  66873. * Gets a new Angle object from the given float in degrees
  66874. * @param degrees defines the angle value in degrees
  66875. * @returns a new Angle
  66876. */
  66877. static FromDegrees(degrees: number): Angle;
  66878. }
  66879. /**
  66880. * This represents an arc in a 2d space.
  66881. */
  66882. export class Arc2 {
  66883. /** Defines the start point of the arc */
  66884. startPoint: Vector2;
  66885. /** Defines the mid point of the arc */
  66886. midPoint: Vector2;
  66887. /** Defines the end point of the arc */
  66888. endPoint: Vector2;
  66889. /**
  66890. * Defines the center point of the arc.
  66891. */
  66892. centerPoint: Vector2;
  66893. /**
  66894. * Defines the radius of the arc.
  66895. */
  66896. radius: number;
  66897. /**
  66898. * Defines the angle of the arc (from mid point to end point).
  66899. */
  66900. angle: Angle;
  66901. /**
  66902. * Defines the start angle of the arc (from start point to middle point).
  66903. */
  66904. startAngle: Angle;
  66905. /**
  66906. * Defines the orientation of the arc (clock wise/counter clock wise).
  66907. */
  66908. orientation: Orientation;
  66909. /**
  66910. * Creates an Arc object from the three given points : start, middle and end.
  66911. * @param startPoint Defines the start point of the arc
  66912. * @param midPoint Defines the midlle point of the arc
  66913. * @param endPoint Defines the end point of the arc
  66914. */
  66915. constructor(
  66916. /** Defines the start point of the arc */
  66917. startPoint: Vector2,
  66918. /** Defines the mid point of the arc */
  66919. midPoint: Vector2,
  66920. /** Defines the end point of the arc */
  66921. endPoint: Vector2);
  66922. }
  66923. /**
  66924. * Represents a 2D path made up of multiple 2D points
  66925. */
  66926. export class Path2 {
  66927. private _points;
  66928. private _length;
  66929. /**
  66930. * If the path start and end point are the same
  66931. */
  66932. closed: boolean;
  66933. /**
  66934. * Creates a Path2 object from the starting 2D coordinates x and y.
  66935. * @param x the starting points x value
  66936. * @param y the starting points y value
  66937. */
  66938. constructor(x: number, y: number);
  66939. /**
  66940. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66941. * @param x the added points x value
  66942. * @param y the added points y value
  66943. * @returns the updated Path2.
  66944. */
  66945. addLineTo(x: number, y: number): Path2;
  66946. /**
  66947. * 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.
  66948. * @param midX middle point x value
  66949. * @param midY middle point y value
  66950. * @param endX end point x value
  66951. * @param endY end point y value
  66952. * @param numberOfSegments (default: 36)
  66953. * @returns the updated Path2.
  66954. */
  66955. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66956. /**
  66957. * Closes the Path2.
  66958. * @returns the Path2.
  66959. */
  66960. close(): Path2;
  66961. /**
  66962. * Gets the sum of the distance between each sequential point in the path
  66963. * @returns the Path2 total length (float).
  66964. */
  66965. length(): number;
  66966. /**
  66967. * Gets the points which construct the path
  66968. * @returns the Path2 internal array of points.
  66969. */
  66970. getPoints(): Vector2[];
  66971. /**
  66972. * Retreives the point at the distance aways from the starting point
  66973. * @param normalizedLengthPosition the length along the path to retreive the point from
  66974. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66975. */
  66976. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66977. /**
  66978. * Creates a new path starting from an x and y position
  66979. * @param x starting x value
  66980. * @param y starting y value
  66981. * @returns a new Path2 starting at the coordinates (x, y).
  66982. */
  66983. static StartingAt(x: number, y: number): Path2;
  66984. }
  66985. /**
  66986. * Represents a 3D path made up of multiple 3D points
  66987. */
  66988. export class Path3D {
  66989. /**
  66990. * an array of Vector3, the curve axis of the Path3D
  66991. */
  66992. path: Vector3[];
  66993. private _curve;
  66994. private _distances;
  66995. private _tangents;
  66996. private _normals;
  66997. private _binormals;
  66998. private _raw;
  66999. /**
  67000. * new Path3D(path, normal, raw)
  67001. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  67002. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  67003. * @param path an array of Vector3, the curve axis of the Path3D
  67004. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  67005. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  67006. */
  67007. constructor(
  67008. /**
  67009. * an array of Vector3, the curve axis of the Path3D
  67010. */
  67011. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  67012. /**
  67013. * Returns the Path3D array of successive Vector3 designing its curve.
  67014. * @returns the Path3D array of successive Vector3 designing its curve.
  67015. */
  67016. getCurve(): Vector3[];
  67017. /**
  67018. * Returns an array populated with tangent vectors on each Path3D curve point.
  67019. * @returns an array populated with tangent vectors on each Path3D curve point.
  67020. */
  67021. getTangents(): Vector3[];
  67022. /**
  67023. * Returns an array populated with normal vectors on each Path3D curve point.
  67024. * @returns an array populated with normal vectors on each Path3D curve point.
  67025. */
  67026. getNormals(): Vector3[];
  67027. /**
  67028. * Returns an array populated with binormal vectors on each Path3D curve point.
  67029. * @returns an array populated with binormal vectors on each Path3D curve point.
  67030. */
  67031. getBinormals(): Vector3[];
  67032. /**
  67033. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  67034. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  67035. */
  67036. getDistances(): number[];
  67037. /**
  67038. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  67039. * @param path path which all values are copied into the curves points
  67040. * @param firstNormal which should be projected onto the curve
  67041. * @returns the same object updated.
  67042. */
  67043. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  67044. private _compute;
  67045. private _getFirstNonNullVector;
  67046. private _getLastNonNullVector;
  67047. private _normalVector;
  67048. }
  67049. /**
  67050. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  67051. * A Curve3 is designed from a series of successive Vector3.
  67052. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  67053. */
  67054. export class Curve3 {
  67055. private _points;
  67056. private _length;
  67057. /**
  67058. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  67059. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  67060. * @param v1 (Vector3) the control point
  67061. * @param v2 (Vector3) the end point of the Quadratic Bezier
  67062. * @param nbPoints (integer) the wanted number of points in the curve
  67063. * @returns the created Curve3
  67064. */
  67065. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  67066. /**
  67067. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  67068. * @param v0 (Vector3) the origin point of the Cubic Bezier
  67069. * @param v1 (Vector3) the first control point
  67070. * @param v2 (Vector3) the second control point
  67071. * @param v3 (Vector3) the end point of the Cubic Bezier
  67072. * @param nbPoints (integer) the wanted number of points in the curve
  67073. * @returns the created Curve3
  67074. */
  67075. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  67076. /**
  67077. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  67078. * @param p1 (Vector3) the origin point of the Hermite Spline
  67079. * @param t1 (Vector3) the tangent vector at the origin point
  67080. * @param p2 (Vector3) the end point of the Hermite Spline
  67081. * @param t2 (Vector3) the tangent vector at the end point
  67082. * @param nbPoints (integer) the wanted number of points in the curve
  67083. * @returns the created Curve3
  67084. */
  67085. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  67086. /**
  67087. * Returns a Curve3 object along a CatmullRom Spline curve :
  67088. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  67089. * @param nbPoints (integer) the wanted number of points between each curve control points
  67090. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  67091. * @returns the created Curve3
  67092. */
  67093. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  67094. /**
  67095. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  67096. * A Curve3 is designed from a series of successive Vector3.
  67097. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  67098. * @param points points which make up the curve
  67099. */
  67100. constructor(points: Vector3[]);
  67101. /**
  67102. * @returns the Curve3 stored array of successive Vector3
  67103. */
  67104. getPoints(): Vector3[];
  67105. /**
  67106. * @returns the computed length (float) of the curve.
  67107. */
  67108. length(): number;
  67109. /**
  67110. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  67111. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  67112. * curveA and curveB keep unchanged.
  67113. * @param curve the curve to continue from this curve
  67114. * @returns the newly constructed curve
  67115. */
  67116. continue(curve: DeepImmutable<Curve3>): Curve3;
  67117. private _computeLength;
  67118. }
  67119. /**
  67120. * Contains position and normal vectors for a vertex
  67121. */
  67122. export class PositionNormalVertex {
  67123. /** the position of the vertex (defaut: 0,0,0) */
  67124. position: Vector3;
  67125. /** the normal of the vertex (defaut: 0,1,0) */
  67126. normal: Vector3;
  67127. /**
  67128. * Creates a PositionNormalVertex
  67129. * @param position the position of the vertex (defaut: 0,0,0)
  67130. * @param normal the normal of the vertex (defaut: 0,1,0)
  67131. */
  67132. constructor(
  67133. /** the position of the vertex (defaut: 0,0,0) */
  67134. position?: Vector3,
  67135. /** the normal of the vertex (defaut: 0,1,0) */
  67136. normal?: Vector3);
  67137. /**
  67138. * Clones the PositionNormalVertex
  67139. * @returns the cloned PositionNormalVertex
  67140. */
  67141. clone(): PositionNormalVertex;
  67142. }
  67143. /**
  67144. * Contains position, normal and uv vectors for a vertex
  67145. */
  67146. export class PositionNormalTextureVertex {
  67147. /** the position of the vertex (defaut: 0,0,0) */
  67148. position: Vector3;
  67149. /** the normal of the vertex (defaut: 0,1,0) */
  67150. normal: Vector3;
  67151. /** the uv of the vertex (default: 0,0) */
  67152. uv: Vector2;
  67153. /**
  67154. * Creates a PositionNormalTextureVertex
  67155. * @param position the position of the vertex (defaut: 0,0,0)
  67156. * @param normal the normal of the vertex (defaut: 0,1,0)
  67157. * @param uv the uv of the vertex (default: 0,0)
  67158. */
  67159. constructor(
  67160. /** the position of the vertex (defaut: 0,0,0) */
  67161. position?: Vector3,
  67162. /** the normal of the vertex (defaut: 0,1,0) */
  67163. normal?: Vector3,
  67164. /** the uv of the vertex (default: 0,0) */
  67165. uv?: Vector2);
  67166. /**
  67167. * Clones the PositionNormalTextureVertex
  67168. * @returns the cloned PositionNormalTextureVertex
  67169. */
  67170. clone(): PositionNormalTextureVertex;
  67171. }
  67172. /**
  67173. * @hidden
  67174. */
  67175. export class Tmp {
  67176. static Color3: Color3[];
  67177. static Color4: Color4[];
  67178. static Vector2: Vector2[];
  67179. static Vector3: Vector3[];
  67180. static Vector4: Vector4[];
  67181. static Quaternion: Quaternion[];
  67182. static Matrix: Matrix[];
  67183. }
  67184. }
  67185. declare module BABYLON {
  67186. /**
  67187. * Class used to enable access to offline support
  67188. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67189. */
  67190. export interface IOfflineProvider {
  67191. /**
  67192. * Gets a boolean indicating if scene must be saved in the database
  67193. */
  67194. enableSceneOffline: boolean;
  67195. /**
  67196. * Gets a boolean indicating if textures must be saved in the database
  67197. */
  67198. enableTexturesOffline: boolean;
  67199. /**
  67200. * Open the offline support and make it available
  67201. * @param successCallback defines the callback to call on success
  67202. * @param errorCallback defines the callback to call on error
  67203. */
  67204. open(successCallback: () => void, errorCallback: () => void): void;
  67205. /**
  67206. * Loads an image from the offline support
  67207. * @param url defines the url to load from
  67208. * @param image defines the target DOM image
  67209. */
  67210. loadImage(url: string, image: HTMLImageElement): void;
  67211. /**
  67212. * Loads a file from offline support
  67213. * @param url defines the URL to load from
  67214. * @param sceneLoaded defines a callback to call on success
  67215. * @param progressCallBack defines a callback to call when progress changed
  67216. * @param errorCallback defines a callback to call on error
  67217. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67218. */
  67219. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67220. }
  67221. }
  67222. declare module BABYLON {
  67223. /**
  67224. * A class serves as a medium between the observable and its observers
  67225. */
  67226. export class EventState {
  67227. /**
  67228. * Create a new EventState
  67229. * @param mask defines the mask associated with this state
  67230. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67231. * @param target defines the original target of the state
  67232. * @param currentTarget defines the current target of the state
  67233. */
  67234. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67235. /**
  67236. * Initialize the current event state
  67237. * @param mask defines the mask associated with this state
  67238. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67239. * @param target defines the original target of the state
  67240. * @param currentTarget defines the current target of the state
  67241. * @returns the current event state
  67242. */
  67243. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67244. /**
  67245. * An Observer can set this property to true to prevent subsequent observers of being notified
  67246. */
  67247. skipNextObservers: boolean;
  67248. /**
  67249. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67250. */
  67251. mask: number;
  67252. /**
  67253. * The object that originally notified the event
  67254. */
  67255. target?: any;
  67256. /**
  67257. * The current object in the bubbling phase
  67258. */
  67259. currentTarget?: any;
  67260. /**
  67261. * This will be populated with the return value of the last function that was executed.
  67262. * If it is the first function in the callback chain it will be the event data.
  67263. */
  67264. lastReturnValue?: any;
  67265. }
  67266. /**
  67267. * Represent an Observer registered to a given Observable object.
  67268. */
  67269. export class Observer<T> {
  67270. /**
  67271. * Defines the callback to call when the observer is notified
  67272. */
  67273. callback: (eventData: T, eventState: EventState) => void;
  67274. /**
  67275. * Defines the mask of the observer (used to filter notifications)
  67276. */
  67277. mask: number;
  67278. /**
  67279. * Defines the current scope used to restore the JS context
  67280. */
  67281. scope: any;
  67282. /** @hidden */
  67283. _willBeUnregistered: boolean;
  67284. /**
  67285. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  67286. */
  67287. unregisterOnNextCall: boolean;
  67288. /**
  67289. * Creates a new observer
  67290. * @param callback defines the callback to call when the observer is notified
  67291. * @param mask defines the mask of the observer (used to filter notifications)
  67292. * @param scope defines the current scope used to restore the JS context
  67293. */
  67294. constructor(
  67295. /**
  67296. * Defines the callback to call when the observer is notified
  67297. */
  67298. callback: (eventData: T, eventState: EventState) => void,
  67299. /**
  67300. * Defines the mask of the observer (used to filter notifications)
  67301. */
  67302. mask: number,
  67303. /**
  67304. * Defines the current scope used to restore the JS context
  67305. */
  67306. scope?: any);
  67307. }
  67308. /**
  67309. * Represent a list of observers registered to multiple Observables object.
  67310. */
  67311. export class MultiObserver<T> {
  67312. private _observers;
  67313. private _observables;
  67314. /**
  67315. * Release associated resources
  67316. */
  67317. dispose(): void;
  67318. /**
  67319. * Raise a callback when one of the observable will notify
  67320. * @param observables defines a list of observables to watch
  67321. * @param callback defines the callback to call on notification
  67322. * @param mask defines the mask used to filter notifications
  67323. * @param scope defines the current scope used to restore the JS context
  67324. * @returns the new MultiObserver
  67325. */
  67326. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67327. }
  67328. /**
  67329. * The Observable class is a simple implementation of the Observable pattern.
  67330. *
  67331. * 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.
  67332. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67333. * 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).
  67334. * 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.
  67335. */
  67336. export class Observable<T> {
  67337. private _observers;
  67338. private _eventState;
  67339. private _onObserverAdded;
  67340. /**
  67341. * Gets the list of observers
  67342. */
  67343. readonly observers: Array<Observer<T>>;
  67344. /**
  67345. * Creates a new observable
  67346. * @param onObserverAdded defines a callback to call when a new observer is added
  67347. */
  67348. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67349. /**
  67350. * Create a new Observer with the specified callback
  67351. * @param callback the callback that will be executed for that Observer
  67352. * @param mask the mask used to filter observers
  67353. * @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.
  67354. * @param scope optional scope for the callback to be called from
  67355. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67356. * @returns the new observer created for the callback
  67357. */
  67358. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67359. /**
  67360. * Create a new Observer with the specified callback and unregisters after the next notification
  67361. * @param callback the callback that will be executed for that Observer
  67362. * @returns the new observer created for the callback
  67363. */
  67364. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67365. /**
  67366. * Remove an Observer from the Observable object
  67367. * @param observer the instance of the Observer to remove
  67368. * @returns false if it doesn't belong to this Observable
  67369. */
  67370. remove(observer: Nullable<Observer<T>>): boolean;
  67371. /**
  67372. * Remove a callback from the Observable object
  67373. * @param callback the callback to remove
  67374. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67375. * @returns false if it doesn't belong to this Observable
  67376. */
  67377. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67378. private _deferUnregister;
  67379. private _remove;
  67380. /**
  67381. * Moves the observable to the top of the observer list making it get called first when notified
  67382. * @param observer the observer to move
  67383. */
  67384. makeObserverTopPriority(observer: Observer<T>): void;
  67385. /**
  67386. * Moves the observable to the bottom of the observer list making it get called last when notified
  67387. * @param observer the observer to move
  67388. */
  67389. makeObserverBottomPriority(observer: Observer<T>): void;
  67390. /**
  67391. * Notify all Observers by calling their respective callback with the given data
  67392. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67393. * @param eventData defines the data to send to all observers
  67394. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67395. * @param target defines the original target of the state
  67396. * @param currentTarget defines the current target of the state
  67397. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67398. */
  67399. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67400. /**
  67401. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67402. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67403. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67404. * and it is crucial that all callbacks will be executed.
  67405. * The order of the callbacks is kept, callbacks are not executed parallel.
  67406. *
  67407. * @param eventData The data to be sent to each callback
  67408. * @param mask is used to filter observers defaults to -1
  67409. * @param target defines the callback target (see EventState)
  67410. * @param currentTarget defines he current object in the bubbling phase
  67411. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67412. */
  67413. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67414. /**
  67415. * Notify a specific observer
  67416. * @param observer defines the observer to notify
  67417. * @param eventData defines the data to be sent to each callback
  67418. * @param mask is used to filter observers defaults to -1
  67419. */
  67420. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67421. /**
  67422. * Gets a boolean indicating if the observable has at least one observer
  67423. * @returns true is the Observable has at least one Observer registered
  67424. */
  67425. hasObservers(): boolean;
  67426. /**
  67427. * Clear the list of observers
  67428. */
  67429. clear(): void;
  67430. /**
  67431. * Clone the current observable
  67432. * @returns a new observable
  67433. */
  67434. clone(): Observable<T>;
  67435. /**
  67436. * Does this observable handles observer registered with a given mask
  67437. * @param mask defines the mask to be tested
  67438. * @return whether or not one observer registered with the given mask is handeled
  67439. **/
  67440. hasSpecificMask(mask?: number): boolean;
  67441. }
  67442. }
  67443. declare module BABYLON {
  67444. /**
  67445. * Class used to help managing file picking and drag'n'drop
  67446. * File Storage
  67447. */
  67448. export class FilesInputStore {
  67449. /**
  67450. * List of files ready to be loaded
  67451. */
  67452. static FilesToLoad: {
  67453. [key: string]: File;
  67454. };
  67455. }
  67456. }
  67457. declare module BABYLON {
  67458. /** Defines the cross module used constants to avoid circular dependncies */
  67459. export class Constants {
  67460. /** Defines that alpha blending is disabled */
  67461. static readonly ALPHA_DISABLE: number;
  67462. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67463. static readonly ALPHA_ADD: number;
  67464. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67465. static readonly ALPHA_COMBINE: number;
  67466. /** Defines that alpha blending to DEST - SRC * DEST */
  67467. static readonly ALPHA_SUBTRACT: number;
  67468. /** Defines that alpha blending to SRC * DEST */
  67469. static readonly ALPHA_MULTIPLY: number;
  67470. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67471. static readonly ALPHA_MAXIMIZED: number;
  67472. /** Defines that alpha blending to SRC + DEST */
  67473. static readonly ALPHA_ONEONE: number;
  67474. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67475. static readonly ALPHA_PREMULTIPLIED: number;
  67476. /**
  67477. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67478. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67479. */
  67480. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67481. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67482. static readonly ALPHA_INTERPOLATE: number;
  67483. /**
  67484. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67485. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67486. */
  67487. static readonly ALPHA_SCREENMODE: number;
  67488. /** Defines that the ressource is not delayed*/
  67489. static readonly DELAYLOADSTATE_NONE: number;
  67490. /** Defines that the ressource was successfully delay loaded */
  67491. static readonly DELAYLOADSTATE_LOADED: number;
  67492. /** Defines that the ressource is currently delay loading */
  67493. static readonly DELAYLOADSTATE_LOADING: number;
  67494. /** Defines that the ressource is delayed and has not started loading */
  67495. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67496. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67497. static readonly NEVER: number;
  67498. /** 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 */
  67499. static readonly ALWAYS: number;
  67500. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67501. static readonly LESS: number;
  67502. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67503. static readonly EQUAL: number;
  67504. /** 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 */
  67505. static readonly LEQUAL: number;
  67506. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67507. static readonly GREATER: number;
  67508. /** 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 */
  67509. static readonly GEQUAL: number;
  67510. /** 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 */
  67511. static readonly NOTEQUAL: number;
  67512. /** Passed to stencilOperation to specify that stencil value must be kept */
  67513. static readonly KEEP: number;
  67514. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67515. static readonly REPLACE: number;
  67516. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67517. static readonly INCR: number;
  67518. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67519. static readonly DECR: number;
  67520. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67521. static readonly INVERT: number;
  67522. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67523. static readonly INCR_WRAP: number;
  67524. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67525. static readonly DECR_WRAP: number;
  67526. /** Texture is not repeating outside of 0..1 UVs */
  67527. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67528. /** Texture is repeating outside of 0..1 UVs */
  67529. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67530. /** Texture is repeating and mirrored */
  67531. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67532. /** ALPHA */
  67533. static readonly TEXTUREFORMAT_ALPHA: number;
  67534. /** LUMINANCE */
  67535. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67536. /** LUMINANCE_ALPHA */
  67537. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67538. /** RGB */
  67539. static readonly TEXTUREFORMAT_RGB: number;
  67540. /** RGBA */
  67541. static readonly TEXTUREFORMAT_RGBA: number;
  67542. /** RED */
  67543. static readonly TEXTUREFORMAT_RED: number;
  67544. /** RED (2nd reference) */
  67545. static readonly TEXTUREFORMAT_R: number;
  67546. /** RG */
  67547. static readonly TEXTUREFORMAT_RG: number;
  67548. /** RED_INTEGER */
  67549. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67550. /** RED_INTEGER (2nd reference) */
  67551. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67552. /** RG_INTEGER */
  67553. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67554. /** RGB_INTEGER */
  67555. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67556. /** RGBA_INTEGER */
  67557. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67558. /** UNSIGNED_BYTE */
  67559. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67560. /** UNSIGNED_BYTE (2nd reference) */
  67561. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67562. /** FLOAT */
  67563. static readonly TEXTURETYPE_FLOAT: number;
  67564. /** HALF_FLOAT */
  67565. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67566. /** BYTE */
  67567. static readonly TEXTURETYPE_BYTE: number;
  67568. /** SHORT */
  67569. static readonly TEXTURETYPE_SHORT: number;
  67570. /** UNSIGNED_SHORT */
  67571. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67572. /** INT */
  67573. static readonly TEXTURETYPE_INT: number;
  67574. /** UNSIGNED_INT */
  67575. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67576. /** UNSIGNED_SHORT_4_4_4_4 */
  67577. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67578. /** UNSIGNED_SHORT_5_5_5_1 */
  67579. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67580. /** UNSIGNED_SHORT_5_6_5 */
  67581. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67582. /** UNSIGNED_INT_2_10_10_10_REV */
  67583. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67584. /** UNSIGNED_INT_24_8 */
  67585. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67586. /** UNSIGNED_INT_10F_11F_11F_REV */
  67587. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67588. /** UNSIGNED_INT_5_9_9_9_REV */
  67589. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67590. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67591. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67592. /** nearest is mag = nearest and min = nearest and mip = linear */
  67593. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67594. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67595. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67596. /** Trilinear is mag = linear and min = linear and mip = linear */
  67597. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67598. /** nearest is mag = nearest and min = nearest and mip = linear */
  67599. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67600. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67601. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67602. /** Trilinear is mag = linear and min = linear and mip = linear */
  67603. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67604. /** mag = nearest and min = nearest and mip = nearest */
  67605. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67606. /** mag = nearest and min = linear and mip = nearest */
  67607. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67608. /** mag = nearest and min = linear and mip = linear */
  67609. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67610. /** mag = nearest and min = linear and mip = none */
  67611. static readonly TEXTURE_NEAREST_LINEAR: number;
  67612. /** mag = nearest and min = nearest and mip = none */
  67613. static readonly TEXTURE_NEAREST_NEAREST: number;
  67614. /** mag = linear and min = nearest and mip = nearest */
  67615. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67616. /** mag = linear and min = nearest and mip = linear */
  67617. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67618. /** mag = linear and min = linear and mip = none */
  67619. static readonly TEXTURE_LINEAR_LINEAR: number;
  67620. /** mag = linear and min = nearest and mip = none */
  67621. static readonly TEXTURE_LINEAR_NEAREST: number;
  67622. /** Explicit coordinates mode */
  67623. static readonly TEXTURE_EXPLICIT_MODE: number;
  67624. /** Spherical coordinates mode */
  67625. static readonly TEXTURE_SPHERICAL_MODE: number;
  67626. /** Planar coordinates mode */
  67627. static readonly TEXTURE_PLANAR_MODE: number;
  67628. /** Cubic coordinates mode */
  67629. static readonly TEXTURE_CUBIC_MODE: number;
  67630. /** Projection coordinates mode */
  67631. static readonly TEXTURE_PROJECTION_MODE: number;
  67632. /** Skybox coordinates mode */
  67633. static readonly TEXTURE_SKYBOX_MODE: number;
  67634. /** Inverse Cubic coordinates mode */
  67635. static readonly TEXTURE_INVCUBIC_MODE: number;
  67636. /** Equirectangular coordinates mode */
  67637. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67638. /** Equirectangular Fixed coordinates mode */
  67639. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67640. /** Equirectangular Fixed Mirrored coordinates mode */
  67641. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67642. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67643. static readonly SCALEMODE_FLOOR: number;
  67644. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67645. static readonly SCALEMODE_NEAREST: number;
  67646. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67647. static readonly SCALEMODE_CEILING: number;
  67648. /**
  67649. * The dirty texture flag value
  67650. */
  67651. static readonly MATERIAL_TextureDirtyFlag: number;
  67652. /**
  67653. * The dirty light flag value
  67654. */
  67655. static readonly MATERIAL_LightDirtyFlag: number;
  67656. /**
  67657. * The dirty fresnel flag value
  67658. */
  67659. static readonly MATERIAL_FresnelDirtyFlag: number;
  67660. /**
  67661. * The dirty attribute flag value
  67662. */
  67663. static readonly MATERIAL_AttributesDirtyFlag: number;
  67664. /**
  67665. * The dirty misc flag value
  67666. */
  67667. static readonly MATERIAL_MiscDirtyFlag: number;
  67668. /**
  67669. * The all dirty flag value
  67670. */
  67671. static readonly MATERIAL_AllDirtyFlag: number;
  67672. /**
  67673. * Returns the triangle fill mode
  67674. */
  67675. static readonly MATERIAL_TriangleFillMode: number;
  67676. /**
  67677. * Returns the wireframe mode
  67678. */
  67679. static readonly MATERIAL_WireFrameFillMode: number;
  67680. /**
  67681. * Returns the point fill mode
  67682. */
  67683. static readonly MATERIAL_PointFillMode: number;
  67684. /**
  67685. * Returns the point list draw mode
  67686. */
  67687. static readonly MATERIAL_PointListDrawMode: number;
  67688. /**
  67689. * Returns the line list draw mode
  67690. */
  67691. static readonly MATERIAL_LineListDrawMode: number;
  67692. /**
  67693. * Returns the line loop draw mode
  67694. */
  67695. static readonly MATERIAL_LineLoopDrawMode: number;
  67696. /**
  67697. * Returns the line strip draw mode
  67698. */
  67699. static readonly MATERIAL_LineStripDrawMode: number;
  67700. /**
  67701. * Returns the triangle strip draw mode
  67702. */
  67703. static readonly MATERIAL_TriangleStripDrawMode: number;
  67704. /**
  67705. * Returns the triangle fan draw mode
  67706. */
  67707. static readonly MATERIAL_TriangleFanDrawMode: number;
  67708. /**
  67709. * Stores the clock-wise side orientation
  67710. */
  67711. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67712. /**
  67713. * Stores the counter clock-wise side orientation
  67714. */
  67715. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67716. /**
  67717. * Nothing
  67718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67719. */
  67720. static readonly ACTION_NothingTrigger: number;
  67721. /**
  67722. * On pick
  67723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67724. */
  67725. static readonly ACTION_OnPickTrigger: number;
  67726. /**
  67727. * On left pick
  67728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67729. */
  67730. static readonly ACTION_OnLeftPickTrigger: number;
  67731. /**
  67732. * On right pick
  67733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67734. */
  67735. static readonly ACTION_OnRightPickTrigger: number;
  67736. /**
  67737. * On center pick
  67738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67739. */
  67740. static readonly ACTION_OnCenterPickTrigger: number;
  67741. /**
  67742. * On pick down
  67743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67744. */
  67745. static readonly ACTION_OnPickDownTrigger: number;
  67746. /**
  67747. * On double pick
  67748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67749. */
  67750. static readonly ACTION_OnDoublePickTrigger: number;
  67751. /**
  67752. * On pick up
  67753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67754. */
  67755. static readonly ACTION_OnPickUpTrigger: number;
  67756. /**
  67757. * On pick out.
  67758. * This trigger will only be raised if you also declared a OnPickDown
  67759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67760. */
  67761. static readonly ACTION_OnPickOutTrigger: number;
  67762. /**
  67763. * On long press
  67764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67765. */
  67766. static readonly ACTION_OnLongPressTrigger: number;
  67767. /**
  67768. * On pointer over
  67769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67770. */
  67771. static readonly ACTION_OnPointerOverTrigger: number;
  67772. /**
  67773. * On pointer out
  67774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67775. */
  67776. static readonly ACTION_OnPointerOutTrigger: number;
  67777. /**
  67778. * On every frame
  67779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67780. */
  67781. static readonly ACTION_OnEveryFrameTrigger: number;
  67782. /**
  67783. * On intersection enter
  67784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67785. */
  67786. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67787. /**
  67788. * On intersection exit
  67789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67790. */
  67791. static readonly ACTION_OnIntersectionExitTrigger: number;
  67792. /**
  67793. * On key down
  67794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67795. */
  67796. static readonly ACTION_OnKeyDownTrigger: number;
  67797. /**
  67798. * On key up
  67799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67800. */
  67801. static readonly ACTION_OnKeyUpTrigger: number;
  67802. /**
  67803. * Billboard mode will only apply to Y axis
  67804. */
  67805. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67806. /**
  67807. * Billboard mode will apply to all axes
  67808. */
  67809. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67810. /**
  67811. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67812. */
  67813. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67814. /**
  67815. * Gets or sets base Assets URL
  67816. */
  67817. static PARTICLES_BaseAssetsUrl: string;
  67818. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67819. * Test order :
  67820. * Is the bounding sphere outside the frustum ?
  67821. * If not, are the bounding box vertices outside the frustum ?
  67822. * It not, then the cullable object is in the frustum.
  67823. */
  67824. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67825. /** Culling strategy : Bounding Sphere Only.
  67826. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67827. * It's also less accurate than the standard because some not visible objects can still be selected.
  67828. * Test : is the bounding sphere outside the frustum ?
  67829. * If not, then the cullable object is in the frustum.
  67830. */
  67831. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67832. /** Culling strategy : Optimistic Inclusion.
  67833. * This in an inclusion test first, then the standard exclusion test.
  67834. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67835. * 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.
  67836. * Anyway, it's as accurate as the standard strategy.
  67837. * Test :
  67838. * Is the cullable object bounding sphere center in the frustum ?
  67839. * If not, apply the default culling strategy.
  67840. */
  67841. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67842. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67843. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67844. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67845. * 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.
  67846. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67847. * Test :
  67848. * Is the cullable object bounding sphere center in the frustum ?
  67849. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67850. */
  67851. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67852. /**
  67853. * No logging while loading
  67854. */
  67855. static readonly SCENELOADER_NO_LOGGING: number;
  67856. /**
  67857. * Minimal logging while loading
  67858. */
  67859. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67860. /**
  67861. * Summary logging while loading
  67862. */
  67863. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67864. /**
  67865. * Detailled logging while loading
  67866. */
  67867. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67868. }
  67869. }
  67870. declare module BABYLON {
  67871. /**
  67872. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67873. * Babylon.js
  67874. */
  67875. export class DomManagement {
  67876. /**
  67877. * Checks if the window object exists
  67878. * @returns true if the window object exists
  67879. */
  67880. static IsWindowObjectExist(): boolean;
  67881. /**
  67882. * Extracts text content from a DOM element hierarchy
  67883. * @param element defines the root element
  67884. * @returns a string
  67885. */
  67886. static GetDOMTextContent(element: HTMLElement): string;
  67887. }
  67888. }
  67889. declare module BABYLON {
  67890. /**
  67891. * Logger used througouht the application to allow configuration of
  67892. * the log level required for the messages.
  67893. */
  67894. export class Logger {
  67895. /**
  67896. * No log
  67897. */
  67898. static readonly NoneLogLevel: number;
  67899. /**
  67900. * Only message logs
  67901. */
  67902. static readonly MessageLogLevel: number;
  67903. /**
  67904. * Only warning logs
  67905. */
  67906. static readonly WarningLogLevel: number;
  67907. /**
  67908. * Only error logs
  67909. */
  67910. static readonly ErrorLogLevel: number;
  67911. /**
  67912. * All logs
  67913. */
  67914. static readonly AllLogLevel: number;
  67915. private static _LogCache;
  67916. /**
  67917. * Gets a value indicating the number of loading errors
  67918. * @ignorenaming
  67919. */
  67920. static errorsCount: number;
  67921. /**
  67922. * Callback called when a new log is added
  67923. */
  67924. static OnNewCacheEntry: (entry: string) => void;
  67925. private static _AddLogEntry;
  67926. private static _FormatMessage;
  67927. private static _LogDisabled;
  67928. private static _LogEnabled;
  67929. private static _WarnDisabled;
  67930. private static _WarnEnabled;
  67931. private static _ErrorDisabled;
  67932. private static _ErrorEnabled;
  67933. /**
  67934. * Log a message to the console
  67935. */
  67936. static Log: (message: string) => void;
  67937. /**
  67938. * Write a warning message to the console
  67939. */
  67940. static Warn: (message: string) => void;
  67941. /**
  67942. * Write an error message to the console
  67943. */
  67944. static Error: (message: string) => void;
  67945. /**
  67946. * Gets current log cache (list of logs)
  67947. */
  67948. static readonly LogCache: string;
  67949. /**
  67950. * Clears the log cache
  67951. */
  67952. static ClearLogCache(): void;
  67953. /**
  67954. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67955. */
  67956. static LogLevels: number;
  67957. }
  67958. }
  67959. declare module BABYLON {
  67960. /** @hidden */
  67961. export class _TypeStore {
  67962. /** @hidden */
  67963. static RegisteredTypes: {
  67964. [key: string]: Object;
  67965. };
  67966. /** @hidden */
  67967. static GetClass(fqdn: string): any;
  67968. }
  67969. }
  67970. declare module BABYLON {
  67971. /**
  67972. * Class containing a set of static utilities functions for deep copy.
  67973. */
  67974. export class DeepCopier {
  67975. /**
  67976. * Tries to copy an object by duplicating every property
  67977. * @param source defines the source object
  67978. * @param destination defines the target object
  67979. * @param doNotCopyList defines a list of properties to avoid
  67980. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67981. */
  67982. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67983. }
  67984. }
  67985. declare module BABYLON {
  67986. /**
  67987. * Class containing a set of static utilities functions for precision date
  67988. */
  67989. export class PrecisionDate {
  67990. /**
  67991. * Gets either window.performance.now() if supported or Date.now() else
  67992. */
  67993. static readonly Now: number;
  67994. }
  67995. }
  67996. declare module BABYLON {
  67997. /** @hidden */
  67998. export class _DevTools {
  67999. static WarnImport(name: string): string;
  68000. }
  68001. }
  68002. declare module BABYLON {
  68003. /**
  68004. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  68005. */
  68006. export class WebRequest {
  68007. private _xhr;
  68008. /**
  68009. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68010. * i.e. when loading files, where the server/service expects an Authorization header
  68011. */
  68012. static CustomRequestHeaders: {
  68013. [key: string]: string;
  68014. };
  68015. /**
  68016. * Add callback functions in this array to update all the requests before they get sent to the network
  68017. */
  68018. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  68019. private _injectCustomRequestHeaders;
  68020. /**
  68021. * Gets or sets a function to be called when loading progress changes
  68022. */
  68023. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68024. /**
  68025. * Returns client's state
  68026. */
  68027. readonly readyState: number;
  68028. /**
  68029. * Returns client's status
  68030. */
  68031. readonly status: number;
  68032. /**
  68033. * Returns client's status as a text
  68034. */
  68035. readonly statusText: string;
  68036. /**
  68037. * Returns client's response
  68038. */
  68039. readonly response: any;
  68040. /**
  68041. * Returns client's response url
  68042. */
  68043. readonly responseURL: string;
  68044. /**
  68045. * Returns client's response as text
  68046. */
  68047. readonly responseText: string;
  68048. /**
  68049. * Gets or sets the expected response type
  68050. */
  68051. responseType: XMLHttpRequestResponseType;
  68052. /** @hidden */
  68053. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  68054. /** @hidden */
  68055. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  68056. /**
  68057. * Cancels any network activity
  68058. */
  68059. abort(): void;
  68060. /**
  68061. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68062. * @param body defines an optional request body
  68063. */
  68064. send(body?: Document | BodyInit | null): void;
  68065. /**
  68066. * Sets the request method, request URL
  68067. * @param method defines the method to use (GET, POST, etc..)
  68068. * @param url defines the url to connect with
  68069. */
  68070. open(method: string, url: string): void;
  68071. }
  68072. }
  68073. declare module BABYLON {
  68074. /**
  68075. * Class used to evalaute queries containing `and` and `or` operators
  68076. */
  68077. export class AndOrNotEvaluator {
  68078. /**
  68079. * Evaluate a query
  68080. * @param query defines the query to evaluate
  68081. * @param evaluateCallback defines the callback used to filter result
  68082. * @returns true if the query matches
  68083. */
  68084. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68085. private static _HandleParenthesisContent;
  68086. private static _SimplifyNegation;
  68087. }
  68088. }
  68089. declare module BABYLON {
  68090. /**
  68091. * Class used to store custom tags
  68092. */
  68093. export class Tags {
  68094. /**
  68095. * Adds support for tags on the given object
  68096. * @param obj defines the object to use
  68097. */
  68098. static EnableFor(obj: any): void;
  68099. /**
  68100. * Removes tags support
  68101. * @param obj defines the object to use
  68102. */
  68103. static DisableFor(obj: any): void;
  68104. /**
  68105. * Gets a boolean indicating if the given object has tags
  68106. * @param obj defines the object to use
  68107. * @returns a boolean
  68108. */
  68109. static HasTags(obj: any): boolean;
  68110. /**
  68111. * Gets the tags available on a given object
  68112. * @param obj defines the object to use
  68113. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68114. * @returns the tags
  68115. */
  68116. static GetTags(obj: any, asString?: boolean): any;
  68117. /**
  68118. * Adds tags to an object
  68119. * @param obj defines the object to use
  68120. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68121. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68122. */
  68123. static AddTagsTo(obj: any, tagsString: string): void;
  68124. /**
  68125. * @hidden
  68126. */
  68127. static _AddTagTo(obj: any, tag: string): void;
  68128. /**
  68129. * Removes specific tags from a specific object
  68130. * @param obj defines the object to use
  68131. * @param tagsString defines the tags to remove
  68132. */
  68133. static RemoveTagsFrom(obj: any, tagsString: string): void;
  68134. /**
  68135. * @hidden
  68136. */
  68137. static _RemoveTagFrom(obj: any, tag: string): void;
  68138. /**
  68139. * Defines if tags hosted on an object match a given query
  68140. * @param obj defines the object to use
  68141. * @param tagsQuery defines the tag query
  68142. * @returns a boolean
  68143. */
  68144. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  68145. }
  68146. }
  68147. declare module BABYLON {
  68148. /**
  68149. * Manages the defines for the Material
  68150. */
  68151. export class MaterialDefines {
  68152. /** @hidden */
  68153. protected _keys: string[];
  68154. private _isDirty;
  68155. /** @hidden */
  68156. _renderId: number;
  68157. /** @hidden */
  68158. _areLightsDirty: boolean;
  68159. /** @hidden */
  68160. _areAttributesDirty: boolean;
  68161. /** @hidden */
  68162. _areTexturesDirty: boolean;
  68163. /** @hidden */
  68164. _areFresnelDirty: boolean;
  68165. /** @hidden */
  68166. _areMiscDirty: boolean;
  68167. /** @hidden */
  68168. _areImageProcessingDirty: boolean;
  68169. /** @hidden */
  68170. _normals: boolean;
  68171. /** @hidden */
  68172. _uvs: boolean;
  68173. /** @hidden */
  68174. _needNormals: boolean;
  68175. /** @hidden */
  68176. _needUVs: boolean;
  68177. [id: string]: any;
  68178. /**
  68179. * Specifies if the material needs to be re-calculated
  68180. */
  68181. readonly isDirty: boolean;
  68182. /**
  68183. * Marks the material to indicate that it has been re-calculated
  68184. */
  68185. markAsProcessed(): void;
  68186. /**
  68187. * Marks the material to indicate that it needs to be re-calculated
  68188. */
  68189. markAsUnprocessed(): void;
  68190. /**
  68191. * Marks the material to indicate all of its defines need to be re-calculated
  68192. */
  68193. markAllAsDirty(): void;
  68194. /**
  68195. * Marks the material to indicate that image processing needs to be re-calculated
  68196. */
  68197. markAsImageProcessingDirty(): void;
  68198. /**
  68199. * Marks the material to indicate the lights need to be re-calculated
  68200. */
  68201. markAsLightDirty(): void;
  68202. /**
  68203. * Marks the attribute state as changed
  68204. */
  68205. markAsAttributesDirty(): void;
  68206. /**
  68207. * Marks the texture state as changed
  68208. */
  68209. markAsTexturesDirty(): void;
  68210. /**
  68211. * Marks the fresnel state as changed
  68212. */
  68213. markAsFresnelDirty(): void;
  68214. /**
  68215. * Marks the misc state as changed
  68216. */
  68217. markAsMiscDirty(): void;
  68218. /**
  68219. * Rebuilds the material defines
  68220. */
  68221. rebuild(): void;
  68222. /**
  68223. * Specifies if two material defines are equal
  68224. * @param other - A material define instance to compare to
  68225. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  68226. */
  68227. isEqual(other: MaterialDefines): boolean;
  68228. /**
  68229. * Clones this instance's defines to another instance
  68230. * @param other - material defines to clone values to
  68231. */
  68232. cloneTo(other: MaterialDefines): void;
  68233. /**
  68234. * Resets the material define values
  68235. */
  68236. reset(): void;
  68237. /**
  68238. * Converts the material define values to a string
  68239. * @returns - String of material define information
  68240. */
  68241. toString(): string;
  68242. }
  68243. }
  68244. declare module BABYLON {
  68245. /**
  68246. * Class used to store and describe the pipeline context associated with an effect
  68247. */
  68248. export interface IPipelineContext {
  68249. /**
  68250. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68251. */
  68252. isAsync: boolean;
  68253. /**
  68254. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68255. */
  68256. isReady: boolean;
  68257. /** @hidden */
  68258. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68259. }
  68260. }
  68261. declare module BABYLON {
  68262. /**
  68263. * Class used to store gfx data (like WebGLBuffer)
  68264. */
  68265. export class DataBuffer {
  68266. /**
  68267. * Gets or sets the number of objects referencing this buffer
  68268. */
  68269. references: number;
  68270. /** Gets or sets the size of the underlying buffer */
  68271. capacity: number;
  68272. /**
  68273. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  68274. */
  68275. is32Bits: boolean;
  68276. /**
  68277. * Gets the underlying buffer
  68278. */
  68279. readonly underlyingResource: any;
  68280. }
  68281. }
  68282. declare module BABYLON {
  68283. /** @hidden */
  68284. export interface IShaderProcessor {
  68285. attributeProcessor?: (attribute: string) => string;
  68286. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68287. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68288. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68289. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68290. lineProcessor?: (line: string, isFragment: boolean) => string;
  68291. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68292. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68293. }
  68294. }
  68295. declare module BABYLON {
  68296. /** @hidden */
  68297. export interface ProcessingOptions {
  68298. defines: string[];
  68299. indexParameters: any;
  68300. isFragment: boolean;
  68301. shouldUseHighPrecisionShader: boolean;
  68302. supportsUniformBuffers: boolean;
  68303. shadersRepository: string;
  68304. includesShadersStore: {
  68305. [key: string]: string;
  68306. };
  68307. processor?: IShaderProcessor;
  68308. version: string;
  68309. platformName: string;
  68310. lookForClosingBracketForUniformBuffer?: boolean;
  68311. }
  68312. }
  68313. declare module BABYLON {
  68314. /** @hidden */
  68315. export class ShaderCodeNode {
  68316. line: string;
  68317. children: ShaderCodeNode[];
  68318. additionalDefineKey?: string;
  68319. additionalDefineValue?: string;
  68320. isValid(preprocessors: {
  68321. [key: string]: string;
  68322. }): boolean;
  68323. process(preprocessors: {
  68324. [key: string]: string;
  68325. }, options: ProcessingOptions): string;
  68326. }
  68327. }
  68328. declare module BABYLON {
  68329. /** @hidden */
  68330. export class ShaderCodeCursor {
  68331. private _lines;
  68332. lineIndex: number;
  68333. readonly currentLine: string;
  68334. readonly canRead: boolean;
  68335. lines: string[];
  68336. }
  68337. }
  68338. declare module BABYLON {
  68339. /** @hidden */
  68340. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68341. process(preprocessors: {
  68342. [key: string]: string;
  68343. }, options: ProcessingOptions): string;
  68344. }
  68345. }
  68346. declare module BABYLON {
  68347. /** @hidden */
  68348. export class ShaderDefineExpression {
  68349. isTrue(preprocessors: {
  68350. [key: string]: string;
  68351. }): boolean;
  68352. }
  68353. }
  68354. declare module BABYLON {
  68355. /** @hidden */
  68356. export class ShaderCodeTestNode extends ShaderCodeNode {
  68357. testExpression: ShaderDefineExpression;
  68358. isValid(preprocessors: {
  68359. [key: string]: string;
  68360. }): boolean;
  68361. }
  68362. }
  68363. declare module BABYLON {
  68364. /** @hidden */
  68365. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68366. define: string;
  68367. not: boolean;
  68368. constructor(define: string, not?: boolean);
  68369. isTrue(preprocessors: {
  68370. [key: string]: string;
  68371. }): boolean;
  68372. }
  68373. }
  68374. declare module BABYLON {
  68375. /** @hidden */
  68376. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68377. leftOperand: ShaderDefineExpression;
  68378. rightOperand: ShaderDefineExpression;
  68379. isTrue(preprocessors: {
  68380. [key: string]: string;
  68381. }): boolean;
  68382. }
  68383. }
  68384. declare module BABYLON {
  68385. /** @hidden */
  68386. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68387. leftOperand: ShaderDefineExpression;
  68388. rightOperand: ShaderDefineExpression;
  68389. isTrue(preprocessors: {
  68390. [key: string]: string;
  68391. }): boolean;
  68392. }
  68393. }
  68394. declare module BABYLON {
  68395. /** @hidden */
  68396. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68397. define: string;
  68398. operand: string;
  68399. testValue: string;
  68400. constructor(define: string, operand: string, testValue: string);
  68401. isTrue(preprocessors: {
  68402. [key: string]: string;
  68403. }): boolean;
  68404. }
  68405. }
  68406. declare module BABYLON {
  68407. /** @hidden */
  68408. export class ShaderProcessor {
  68409. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68410. private static _ProcessPrecision;
  68411. private static _ExtractOperation;
  68412. private static _BuildSubExpression;
  68413. private static _BuildExpression;
  68414. private static _MoveCursorWithinIf;
  68415. private static _MoveCursor;
  68416. private static _EvaluatePreProcessors;
  68417. private static _PreparePreProcessors;
  68418. private static _ProcessShaderConversion;
  68419. private static _ProcessIncludes;
  68420. }
  68421. }
  68422. declare module BABYLON {
  68423. /**
  68424. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  68425. */
  68426. export class PerformanceMonitor {
  68427. private _enabled;
  68428. private _rollingFrameTime;
  68429. private _lastFrameTimeMs;
  68430. /**
  68431. * constructor
  68432. * @param frameSampleSize The number of samples required to saturate the sliding window
  68433. */
  68434. constructor(frameSampleSize?: number);
  68435. /**
  68436. * Samples current frame
  68437. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  68438. */
  68439. sampleFrame(timeMs?: number): void;
  68440. /**
  68441. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68442. */
  68443. readonly averageFrameTime: number;
  68444. /**
  68445. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68446. */
  68447. readonly averageFrameTimeVariance: number;
  68448. /**
  68449. * Returns the frame time of the most recent frame
  68450. */
  68451. readonly instantaneousFrameTime: number;
  68452. /**
  68453. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  68454. */
  68455. readonly averageFPS: number;
  68456. /**
  68457. * Returns the average framerate in frames per second using the most recent frame time
  68458. */
  68459. readonly instantaneousFPS: number;
  68460. /**
  68461. * Returns true if enough samples have been taken to completely fill the sliding window
  68462. */
  68463. readonly isSaturated: boolean;
  68464. /**
  68465. * Enables contributions to the sliding window sample set
  68466. */
  68467. enable(): void;
  68468. /**
  68469. * Disables contributions to the sliding window sample set
  68470. * Samples will not be interpolated over the disabled period
  68471. */
  68472. disable(): void;
  68473. /**
  68474. * Returns true if sampling is enabled
  68475. */
  68476. readonly isEnabled: boolean;
  68477. /**
  68478. * Resets performance monitor
  68479. */
  68480. reset(): void;
  68481. }
  68482. /**
  68483. * RollingAverage
  68484. *
  68485. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  68486. */
  68487. export class RollingAverage {
  68488. /**
  68489. * Current average
  68490. */
  68491. average: number;
  68492. /**
  68493. * Current variance
  68494. */
  68495. variance: number;
  68496. protected _samples: Array<number>;
  68497. protected _sampleCount: number;
  68498. protected _pos: number;
  68499. protected _m2: number;
  68500. /**
  68501. * constructor
  68502. * @param length The number of samples required to saturate the sliding window
  68503. */
  68504. constructor(length: number);
  68505. /**
  68506. * Adds a sample to the sample set
  68507. * @param v The sample value
  68508. */
  68509. add(v: number): void;
  68510. /**
  68511. * Returns previously added values or null if outside of history or outside the sliding window domain
  68512. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  68513. * @return Value previously recorded with add() or null if outside of range
  68514. */
  68515. history(i: number): number;
  68516. /**
  68517. * Returns true if enough samples have been taken to completely fill the sliding window
  68518. * @return true if sample-set saturated
  68519. */
  68520. isSaturated(): boolean;
  68521. /**
  68522. * Resets the rolling average (equivalent to 0 samples taken so far)
  68523. */
  68524. reset(): void;
  68525. /**
  68526. * Wraps a value around the sample range boundaries
  68527. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  68528. * @return Wrapped position in sample range
  68529. */
  68530. protected _wrapPosition(i: number): number;
  68531. }
  68532. }
  68533. declare module BABYLON {
  68534. /**
  68535. * This class implement a typical dictionary using a string as key and the generic type T as value.
  68536. * The underlying implementation relies on an associative array to ensure the best performances.
  68537. * The value can be anything including 'null' but except 'undefined'
  68538. */
  68539. export class StringDictionary<T> {
  68540. /**
  68541. * This will clear this dictionary and copy the content from the 'source' one.
  68542. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  68543. * @param source the dictionary to take the content from and copy to this dictionary
  68544. */
  68545. copyFrom(source: StringDictionary<T>): void;
  68546. /**
  68547. * Get a value based from its key
  68548. * @param key the given key to get the matching value from
  68549. * @return the value if found, otherwise undefined is returned
  68550. */
  68551. get(key: string): T | undefined;
  68552. /**
  68553. * Get a value from its key or add it if it doesn't exist.
  68554. * This method will ensure you that a given key/data will be present in the dictionary.
  68555. * @param key the given key to get the matching value from
  68556. * @param factory the factory that will create the value if the key is not present in the dictionary.
  68557. * The factory will only be invoked if there's no data for the given key.
  68558. * @return the value corresponding to the key.
  68559. */
  68560. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  68561. /**
  68562. * Get a value from its key if present in the dictionary otherwise add it
  68563. * @param key the key to get the value from
  68564. * @param val if there's no such key/value pair in the dictionary add it with this value
  68565. * @return the value corresponding to the key
  68566. */
  68567. getOrAdd(key: string, val: T): T;
  68568. /**
  68569. * Check if there's a given key in the dictionary
  68570. * @param key the key to check for
  68571. * @return true if the key is present, false otherwise
  68572. */
  68573. contains(key: string): boolean;
  68574. /**
  68575. * Add a new key and its corresponding value
  68576. * @param key the key to add
  68577. * @param value the value corresponding to the key
  68578. * @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
  68579. */
  68580. add(key: string, value: T): boolean;
  68581. /**
  68582. * Update a specific value associated to a key
  68583. * @param key defines the key to use
  68584. * @param value defines the value to store
  68585. * @returns true if the value was updated (or false if the key was not found)
  68586. */
  68587. set(key: string, value: T): boolean;
  68588. /**
  68589. * Get the element of the given key and remove it from the dictionary
  68590. * @param key defines the key to search
  68591. * @returns the value associated with the key or null if not found
  68592. */
  68593. getAndRemove(key: string): Nullable<T>;
  68594. /**
  68595. * Remove a key/value from the dictionary.
  68596. * @param key the key to remove
  68597. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  68598. */
  68599. remove(key: string): boolean;
  68600. /**
  68601. * Clear the whole content of the dictionary
  68602. */
  68603. clear(): void;
  68604. /**
  68605. * Gets the current count
  68606. */
  68607. readonly count: number;
  68608. /**
  68609. * Execute a callback on each key/val of the dictionary.
  68610. * Note that you can remove any element in this dictionary in the callback implementation
  68611. * @param callback the callback to execute on a given key/value pair
  68612. */
  68613. forEach(callback: (key: string, val: T) => void): void;
  68614. /**
  68615. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  68616. * If the callback returns null or undefined the method will iterate to the next key/value pair
  68617. * Note that you can remove any element in this dictionary in the callback implementation
  68618. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  68619. * @returns the first item
  68620. */
  68621. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  68622. private _count;
  68623. private _data;
  68624. }
  68625. }
  68626. declare module BABYLON {
  68627. /**
  68628. * Helper class that provides a small promise polyfill
  68629. */
  68630. export class PromisePolyfill {
  68631. /**
  68632. * Static function used to check if the polyfill is required
  68633. * If this is the case then the function will inject the polyfill to window.Promise
  68634. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  68635. */
  68636. static Apply(force?: boolean): void;
  68637. }
  68638. }
  68639. declare module BABYLON {
  68640. /**
  68641. * Class used to store data that will be store in GPU memory
  68642. */
  68643. export class Buffer {
  68644. private _engine;
  68645. private _buffer;
  68646. /** @hidden */
  68647. _data: Nullable<DataArray>;
  68648. private _updatable;
  68649. private _instanced;
  68650. /**
  68651. * Gets the byte stride.
  68652. */
  68653. readonly byteStride: number;
  68654. /**
  68655. * Constructor
  68656. * @param engine the engine
  68657. * @param data the data to use for this buffer
  68658. * @param updatable whether the data is updatable
  68659. * @param stride the stride (optional)
  68660. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68661. * @param instanced whether the buffer is instanced (optional)
  68662. * @param useBytes set to true if the stride in in bytes (optional)
  68663. */
  68664. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68665. /**
  68666. * Create a new VertexBuffer based on the current buffer
  68667. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68668. * @param offset defines offset in the buffer (0 by default)
  68669. * @param size defines the size in floats of attributes (position is 3 for instance)
  68670. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68671. * @param instanced defines if the vertex buffer contains indexed data
  68672. * @param useBytes defines if the offset and stride are in bytes
  68673. * @returns the new vertex buffer
  68674. */
  68675. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68676. /**
  68677. * Gets a boolean indicating if the Buffer is updatable?
  68678. * @returns true if the buffer is updatable
  68679. */
  68680. isUpdatable(): boolean;
  68681. /**
  68682. * Gets current buffer's data
  68683. * @returns a DataArray or null
  68684. */
  68685. getData(): Nullable<DataArray>;
  68686. /**
  68687. * Gets underlying native buffer
  68688. * @returns underlying native buffer
  68689. */
  68690. getBuffer(): Nullable<DataBuffer>;
  68691. /**
  68692. * Gets the stride in float32 units (i.e. byte stride / 4).
  68693. * May not be an integer if the byte stride is not divisible by 4.
  68694. * DEPRECATED. Use byteStride instead.
  68695. * @returns the stride in float32 units
  68696. */
  68697. getStrideSize(): number;
  68698. /**
  68699. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68700. * @param data defines the data to store
  68701. */
  68702. create(data?: Nullable<DataArray>): void;
  68703. /** @hidden */
  68704. _rebuild(): void;
  68705. /**
  68706. * Update current buffer data
  68707. * @param data defines the data to store
  68708. */
  68709. update(data: DataArray): void;
  68710. /**
  68711. * Updates the data directly.
  68712. * @param data the new data
  68713. * @param offset the new offset
  68714. * @param vertexCount the vertex count (optional)
  68715. * @param useBytes set to true if the offset is in bytes
  68716. */
  68717. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68718. /**
  68719. * Release all resources
  68720. */
  68721. dispose(): void;
  68722. }
  68723. /**
  68724. * Specialized buffer used to store vertex data
  68725. */
  68726. export class VertexBuffer {
  68727. /** @hidden */
  68728. _buffer: Buffer;
  68729. private _kind;
  68730. private _size;
  68731. private _ownsBuffer;
  68732. private _instanced;
  68733. private _instanceDivisor;
  68734. /**
  68735. * The byte type.
  68736. */
  68737. static readonly BYTE: number;
  68738. /**
  68739. * The unsigned byte type.
  68740. */
  68741. static readonly UNSIGNED_BYTE: number;
  68742. /**
  68743. * The short type.
  68744. */
  68745. static readonly SHORT: number;
  68746. /**
  68747. * The unsigned short type.
  68748. */
  68749. static readonly UNSIGNED_SHORT: number;
  68750. /**
  68751. * The integer type.
  68752. */
  68753. static readonly INT: number;
  68754. /**
  68755. * The unsigned integer type.
  68756. */
  68757. static readonly UNSIGNED_INT: number;
  68758. /**
  68759. * The float type.
  68760. */
  68761. static readonly FLOAT: number;
  68762. /**
  68763. * Gets or sets the instance divisor when in instanced mode
  68764. */
  68765. instanceDivisor: number;
  68766. /**
  68767. * Gets the byte stride.
  68768. */
  68769. readonly byteStride: number;
  68770. /**
  68771. * Gets the byte offset.
  68772. */
  68773. readonly byteOffset: number;
  68774. /**
  68775. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68776. */
  68777. readonly normalized: boolean;
  68778. /**
  68779. * Gets the data type of each component in the array.
  68780. */
  68781. readonly type: number;
  68782. /**
  68783. * Constructor
  68784. * @param engine the engine
  68785. * @param data the data to use for this vertex buffer
  68786. * @param kind the vertex buffer kind
  68787. * @param updatable whether the data is updatable
  68788. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68789. * @param stride the stride (optional)
  68790. * @param instanced whether the buffer is instanced (optional)
  68791. * @param offset the offset of the data (optional)
  68792. * @param size the number of components (optional)
  68793. * @param type the type of the component (optional)
  68794. * @param normalized whether the data contains normalized data (optional)
  68795. * @param useBytes set to true if stride and offset are in bytes (optional)
  68796. */
  68797. 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);
  68798. /** @hidden */
  68799. _rebuild(): void;
  68800. /**
  68801. * Returns the kind of the VertexBuffer (string)
  68802. * @returns a string
  68803. */
  68804. getKind(): string;
  68805. /**
  68806. * Gets a boolean indicating if the VertexBuffer is updatable?
  68807. * @returns true if the buffer is updatable
  68808. */
  68809. isUpdatable(): boolean;
  68810. /**
  68811. * Gets current buffer's data
  68812. * @returns a DataArray or null
  68813. */
  68814. getData(): Nullable<DataArray>;
  68815. /**
  68816. * Gets underlying native buffer
  68817. * @returns underlying native buffer
  68818. */
  68819. getBuffer(): Nullable<DataBuffer>;
  68820. /**
  68821. * Gets the stride in float32 units (i.e. byte stride / 4).
  68822. * May not be an integer if the byte stride is not divisible by 4.
  68823. * DEPRECATED. Use byteStride instead.
  68824. * @returns the stride in float32 units
  68825. */
  68826. getStrideSize(): number;
  68827. /**
  68828. * Returns the offset as a multiple of the type byte length.
  68829. * DEPRECATED. Use byteOffset instead.
  68830. * @returns the offset in bytes
  68831. */
  68832. getOffset(): number;
  68833. /**
  68834. * Returns the number of components per vertex attribute (integer)
  68835. * @returns the size in float
  68836. */
  68837. getSize(): number;
  68838. /**
  68839. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68840. * @returns true if this buffer is instanced
  68841. */
  68842. getIsInstanced(): boolean;
  68843. /**
  68844. * Returns the instancing divisor, zero for non-instanced (integer).
  68845. * @returns a number
  68846. */
  68847. getInstanceDivisor(): number;
  68848. /**
  68849. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68850. * @param data defines the data to store
  68851. */
  68852. create(data?: DataArray): void;
  68853. /**
  68854. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68855. * This function will create a new buffer if the current one is not updatable
  68856. * @param data defines the data to store
  68857. */
  68858. update(data: DataArray): void;
  68859. /**
  68860. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68861. * Returns the directly updated WebGLBuffer.
  68862. * @param data the new data
  68863. * @param offset the new offset
  68864. * @param useBytes set to true if the offset is in bytes
  68865. */
  68866. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68867. /**
  68868. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68869. */
  68870. dispose(): void;
  68871. /**
  68872. * Enumerates each value of this vertex buffer as numbers.
  68873. * @param count the number of values to enumerate
  68874. * @param callback the callback function called for each value
  68875. */
  68876. forEach(count: number, callback: (value: number, index: number) => void): void;
  68877. /**
  68878. * Positions
  68879. */
  68880. static readonly PositionKind: string;
  68881. /**
  68882. * Normals
  68883. */
  68884. static readonly NormalKind: string;
  68885. /**
  68886. * Tangents
  68887. */
  68888. static readonly TangentKind: string;
  68889. /**
  68890. * Texture coordinates
  68891. */
  68892. static readonly UVKind: string;
  68893. /**
  68894. * Texture coordinates 2
  68895. */
  68896. static readonly UV2Kind: string;
  68897. /**
  68898. * Texture coordinates 3
  68899. */
  68900. static readonly UV3Kind: string;
  68901. /**
  68902. * Texture coordinates 4
  68903. */
  68904. static readonly UV4Kind: string;
  68905. /**
  68906. * Texture coordinates 5
  68907. */
  68908. static readonly UV5Kind: string;
  68909. /**
  68910. * Texture coordinates 6
  68911. */
  68912. static readonly UV6Kind: string;
  68913. /**
  68914. * Colors
  68915. */
  68916. static readonly ColorKind: string;
  68917. /**
  68918. * Matrix indices (for bones)
  68919. */
  68920. static readonly MatricesIndicesKind: string;
  68921. /**
  68922. * Matrix weights (for bones)
  68923. */
  68924. static readonly MatricesWeightsKind: string;
  68925. /**
  68926. * Additional matrix indices (for bones)
  68927. */
  68928. static readonly MatricesIndicesExtraKind: string;
  68929. /**
  68930. * Additional matrix weights (for bones)
  68931. */
  68932. static readonly MatricesWeightsExtraKind: string;
  68933. /**
  68934. * Deduces the stride given a kind.
  68935. * @param kind The kind string to deduce
  68936. * @returns The deduced stride
  68937. */
  68938. static DeduceStride(kind: string): number;
  68939. /**
  68940. * Gets the byte length of the given type.
  68941. * @param type the type
  68942. * @returns the number of bytes
  68943. */
  68944. static GetTypeByteLength(type: number): number;
  68945. /**
  68946. * Enumerates each value of the given parameters as numbers.
  68947. * @param data the data to enumerate
  68948. * @param byteOffset the byte offset of the data
  68949. * @param byteStride the byte stride of the data
  68950. * @param componentCount the number of components per element
  68951. * @param componentType the type of the component
  68952. * @param count the number of values to enumerate
  68953. * @param normalized whether the data is normalized
  68954. * @param callback the callback function called for each value
  68955. */
  68956. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68957. private static _GetFloatValue;
  68958. }
  68959. }
  68960. declare module BABYLON {
  68961. /**
  68962. * Class representing spherical harmonics coefficients to the 3rd degree
  68963. */
  68964. export class SphericalHarmonics {
  68965. /**
  68966. * Defines whether or not the harmonics have been prescaled for rendering.
  68967. */
  68968. preScaled: boolean;
  68969. /**
  68970. * The l0,0 coefficients of the spherical harmonics
  68971. */
  68972. l00: Vector3;
  68973. /**
  68974. * The l1,-1 coefficients of the spherical harmonics
  68975. */
  68976. l1_1: Vector3;
  68977. /**
  68978. * The l1,0 coefficients of the spherical harmonics
  68979. */
  68980. l10: Vector3;
  68981. /**
  68982. * The l1,1 coefficients of the spherical harmonics
  68983. */
  68984. l11: Vector3;
  68985. /**
  68986. * The l2,-2 coefficients of the spherical harmonics
  68987. */
  68988. l2_2: Vector3;
  68989. /**
  68990. * The l2,-1 coefficients of the spherical harmonics
  68991. */
  68992. l2_1: Vector3;
  68993. /**
  68994. * The l2,0 coefficients of the spherical harmonics
  68995. */
  68996. l20: Vector3;
  68997. /**
  68998. * The l2,1 coefficients of the spherical harmonics
  68999. */
  69000. l21: Vector3;
  69001. /**
  69002. * The l2,2 coefficients of the spherical harmonics
  69003. */
  69004. l22: Vector3;
  69005. /**
  69006. * Adds a light to the spherical harmonics
  69007. * @param direction the direction of the light
  69008. * @param color the color of the light
  69009. * @param deltaSolidAngle the delta solid angle of the light
  69010. */
  69011. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  69012. /**
  69013. * Scales the spherical harmonics by the given amount
  69014. * @param scale the amount to scale
  69015. */
  69016. scaleInPlace(scale: number): void;
  69017. /**
  69018. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  69019. *
  69020. * ```
  69021. * E_lm = A_l * L_lm
  69022. * ```
  69023. *
  69024. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  69025. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  69026. * the scaling factors are given in equation 9.
  69027. */
  69028. convertIncidentRadianceToIrradiance(): void;
  69029. /**
  69030. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  69031. *
  69032. * ```
  69033. * L = (1/pi) * E * rho
  69034. * ```
  69035. *
  69036. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  69037. */
  69038. convertIrradianceToLambertianRadiance(): void;
  69039. /**
  69040. * Integrates the reconstruction coefficients directly in to the SH preventing further
  69041. * required operations at run time.
  69042. *
  69043. * This is simply done by scaling back the SH with Ylm constants parameter.
  69044. * The trigonometric part being applied by the shader at run time.
  69045. */
  69046. preScaleForRendering(): void;
  69047. /**
  69048. * Constructs a spherical harmonics from an array.
  69049. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  69050. * @returns the spherical harmonics
  69051. */
  69052. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  69053. /**
  69054. * Gets the spherical harmonics from polynomial
  69055. * @param polynomial the spherical polynomial
  69056. * @returns the spherical harmonics
  69057. */
  69058. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  69059. }
  69060. /**
  69061. * Class representing spherical polynomial coefficients to the 3rd degree
  69062. */
  69063. export class SphericalPolynomial {
  69064. private _harmonics;
  69065. /**
  69066. * The spherical harmonics used to create the polynomials.
  69067. */
  69068. readonly preScaledHarmonics: SphericalHarmonics;
  69069. /**
  69070. * The x coefficients of the spherical polynomial
  69071. */
  69072. x: Vector3;
  69073. /**
  69074. * The y coefficients of the spherical polynomial
  69075. */
  69076. y: Vector3;
  69077. /**
  69078. * The z coefficients of the spherical polynomial
  69079. */
  69080. z: Vector3;
  69081. /**
  69082. * The xx coefficients of the spherical polynomial
  69083. */
  69084. xx: Vector3;
  69085. /**
  69086. * The yy coefficients of the spherical polynomial
  69087. */
  69088. yy: Vector3;
  69089. /**
  69090. * The zz coefficients of the spherical polynomial
  69091. */
  69092. zz: Vector3;
  69093. /**
  69094. * The xy coefficients of the spherical polynomial
  69095. */
  69096. xy: Vector3;
  69097. /**
  69098. * The yz coefficients of the spherical polynomial
  69099. */
  69100. yz: Vector3;
  69101. /**
  69102. * The zx coefficients of the spherical polynomial
  69103. */
  69104. zx: Vector3;
  69105. /**
  69106. * Adds an ambient color to the spherical polynomial
  69107. * @param color the color to add
  69108. */
  69109. addAmbient(color: Color3): void;
  69110. /**
  69111. * Scales the spherical polynomial by the given amount
  69112. * @param scale the amount to scale
  69113. */
  69114. scaleInPlace(scale: number): void;
  69115. /**
  69116. * Gets the spherical polynomial from harmonics
  69117. * @param harmonics the spherical harmonics
  69118. * @returns the spherical polynomial
  69119. */
  69120. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  69121. /**
  69122. * Constructs a spherical polynomial from an array.
  69123. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  69124. * @returns the spherical polynomial
  69125. */
  69126. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  69127. }
  69128. }
  69129. declare module BABYLON {
  69130. /**
  69131. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  69132. */
  69133. export interface CubeMapInfo {
  69134. /**
  69135. * The pixel array for the front face.
  69136. * This is stored in format, left to right, up to down format.
  69137. */
  69138. front: Nullable<ArrayBufferView>;
  69139. /**
  69140. * The pixel array for the back face.
  69141. * This is stored in format, left to right, up to down format.
  69142. */
  69143. back: Nullable<ArrayBufferView>;
  69144. /**
  69145. * The pixel array for the left face.
  69146. * This is stored in format, left to right, up to down format.
  69147. */
  69148. left: Nullable<ArrayBufferView>;
  69149. /**
  69150. * The pixel array for the right face.
  69151. * This is stored in format, left to right, up to down format.
  69152. */
  69153. right: Nullable<ArrayBufferView>;
  69154. /**
  69155. * The pixel array for the up face.
  69156. * This is stored in format, left to right, up to down format.
  69157. */
  69158. up: Nullable<ArrayBufferView>;
  69159. /**
  69160. * The pixel array for the down face.
  69161. * This is stored in format, left to right, up to down format.
  69162. */
  69163. down: Nullable<ArrayBufferView>;
  69164. /**
  69165. * The size of the cubemap stored.
  69166. *
  69167. * Each faces will be size * size pixels.
  69168. */
  69169. size: number;
  69170. /**
  69171. * The format of the texture.
  69172. *
  69173. * RGBA, RGB.
  69174. */
  69175. format: number;
  69176. /**
  69177. * The type of the texture data.
  69178. *
  69179. * UNSIGNED_INT, FLOAT.
  69180. */
  69181. type: number;
  69182. /**
  69183. * Specifies whether the texture is in gamma space.
  69184. */
  69185. gammaSpace: boolean;
  69186. }
  69187. /**
  69188. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  69189. */
  69190. export class PanoramaToCubeMapTools {
  69191. private static FACE_FRONT;
  69192. private static FACE_BACK;
  69193. private static FACE_RIGHT;
  69194. private static FACE_LEFT;
  69195. private static FACE_DOWN;
  69196. private static FACE_UP;
  69197. /**
  69198. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  69199. *
  69200. * @param float32Array The source data.
  69201. * @param inputWidth The width of the input panorama.
  69202. * @param inputHeight The height of the input panorama.
  69203. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  69204. * @return The cubemap data
  69205. */
  69206. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  69207. private static CreateCubemapTexture;
  69208. private static CalcProjectionSpherical;
  69209. }
  69210. }
  69211. declare module BABYLON {
  69212. /**
  69213. * Helper class dealing with the extraction of spherical polynomial dataArray
  69214. * from a cube map.
  69215. */
  69216. export class CubeMapToSphericalPolynomialTools {
  69217. private static FileFaces;
  69218. /**
  69219. * Converts a texture to the according Spherical Polynomial data.
  69220. * This extracts the first 3 orders only as they are the only one used in the lighting.
  69221. *
  69222. * @param texture The texture to extract the information from.
  69223. * @return The Spherical Polynomial data.
  69224. */
  69225. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  69226. /**
  69227. * Converts a cubemap to the according Spherical Polynomial data.
  69228. * This extracts the first 3 orders only as they are the only one used in the lighting.
  69229. *
  69230. * @param cubeInfo The Cube map to extract the information from.
  69231. * @return The Spherical Polynomial data.
  69232. */
  69233. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  69234. }
  69235. }
  69236. declare module BABYLON {
  69237. /**
  69238. * The engine store class is responsible to hold all the instances of Engine and Scene created
  69239. * during the life time of the application.
  69240. */
  69241. export class EngineStore {
  69242. /** Gets the list of created engines */
  69243. static Instances: Engine[];
  69244. /** @hidden */
  69245. static _LastCreatedScene: Nullable<Scene>;
  69246. /**
  69247. * Gets the latest created engine
  69248. */
  69249. static readonly LastCreatedEngine: Nullable<Engine>;
  69250. /**
  69251. * Gets the latest created scene
  69252. */
  69253. static readonly LastCreatedScene: Nullable<Scene>;
  69254. }
  69255. }
  69256. declare module BABYLON {
  69257. /**
  69258. * Define options used to create a render target texture
  69259. */
  69260. export class RenderTargetCreationOptions {
  69261. /**
  69262. * Specifies is mipmaps must be generated
  69263. */
  69264. generateMipMaps?: boolean;
  69265. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69266. generateDepthBuffer?: boolean;
  69267. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69268. generateStencilBuffer?: boolean;
  69269. /** Defines texture type (int by default) */
  69270. type?: number;
  69271. /** Defines sampling mode (trilinear by default) */
  69272. samplingMode?: number;
  69273. /** Defines format (RGBA by default) */
  69274. format?: number;
  69275. }
  69276. }
  69277. declare module BABYLON {
  69278. /**
  69279. * @hidden
  69280. **/
  69281. export class _AlphaState {
  69282. private _isAlphaBlendDirty;
  69283. private _isBlendFunctionParametersDirty;
  69284. private _isBlendEquationParametersDirty;
  69285. private _isBlendConstantsDirty;
  69286. private _alphaBlend;
  69287. private _blendFunctionParameters;
  69288. private _blendEquationParameters;
  69289. private _blendConstants;
  69290. /**
  69291. * Initializes the state.
  69292. */
  69293. constructor();
  69294. readonly isDirty: boolean;
  69295. alphaBlend: boolean;
  69296. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  69297. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  69298. setAlphaEquationParameters(rgb: number, alpha: number): void;
  69299. reset(): void;
  69300. apply(gl: WebGLRenderingContext): void;
  69301. }
  69302. }
  69303. declare module BABYLON {
  69304. /**
  69305. * @hidden
  69306. **/
  69307. export class _DepthCullingState {
  69308. private _isDepthTestDirty;
  69309. private _isDepthMaskDirty;
  69310. private _isDepthFuncDirty;
  69311. private _isCullFaceDirty;
  69312. private _isCullDirty;
  69313. private _isZOffsetDirty;
  69314. private _isFrontFaceDirty;
  69315. private _depthTest;
  69316. private _depthMask;
  69317. private _depthFunc;
  69318. private _cull;
  69319. private _cullFace;
  69320. private _zOffset;
  69321. private _frontFace;
  69322. /**
  69323. * Initializes the state.
  69324. */
  69325. constructor();
  69326. readonly isDirty: boolean;
  69327. zOffset: number;
  69328. cullFace: Nullable<number>;
  69329. cull: Nullable<boolean>;
  69330. depthFunc: Nullable<number>;
  69331. depthMask: boolean;
  69332. depthTest: boolean;
  69333. frontFace: Nullable<number>;
  69334. reset(): void;
  69335. apply(gl: WebGLRenderingContext): void;
  69336. }
  69337. }
  69338. declare module BABYLON {
  69339. /**
  69340. * @hidden
  69341. **/
  69342. export class _StencilState {
  69343. /** 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 */
  69344. static readonly ALWAYS: number;
  69345. /** Passed to stencilOperation to specify that stencil value must be kept */
  69346. static readonly KEEP: number;
  69347. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69348. static readonly REPLACE: number;
  69349. private _isStencilTestDirty;
  69350. private _isStencilMaskDirty;
  69351. private _isStencilFuncDirty;
  69352. private _isStencilOpDirty;
  69353. private _stencilTest;
  69354. private _stencilMask;
  69355. private _stencilFunc;
  69356. private _stencilFuncRef;
  69357. private _stencilFuncMask;
  69358. private _stencilOpStencilFail;
  69359. private _stencilOpDepthFail;
  69360. private _stencilOpStencilDepthPass;
  69361. readonly isDirty: boolean;
  69362. stencilFunc: number;
  69363. stencilFuncRef: number;
  69364. stencilFuncMask: number;
  69365. stencilOpStencilFail: number;
  69366. stencilOpDepthFail: number;
  69367. stencilOpStencilDepthPass: number;
  69368. stencilMask: number;
  69369. stencilTest: boolean;
  69370. constructor();
  69371. reset(): void;
  69372. apply(gl: WebGLRenderingContext): void;
  69373. }
  69374. }
  69375. declare module BABYLON {
  69376. /**
  69377. * @hidden
  69378. **/
  69379. export class _TimeToken {
  69380. _startTimeQuery: Nullable<WebGLQuery>;
  69381. _endTimeQuery: Nullable<WebGLQuery>;
  69382. _timeElapsedQuery: Nullable<WebGLQuery>;
  69383. _timeElapsedQueryEnded: boolean;
  69384. }
  69385. }
  69386. declare module BABYLON {
  69387. /**
  69388. * Class used to store data associated with WebGL texture data for the engine
  69389. * This class should not be used directly
  69390. */
  69391. export class InternalTexture {
  69392. /** @hidden */
  69393. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  69394. /**
  69395. * The source of the texture data is unknown
  69396. */
  69397. static DATASOURCE_UNKNOWN: number;
  69398. /**
  69399. * Texture data comes from an URL
  69400. */
  69401. static DATASOURCE_URL: number;
  69402. /**
  69403. * Texture data is only used for temporary storage
  69404. */
  69405. static DATASOURCE_TEMP: number;
  69406. /**
  69407. * Texture data comes from raw data (ArrayBuffer)
  69408. */
  69409. static DATASOURCE_RAW: number;
  69410. /**
  69411. * Texture content is dynamic (video or dynamic texture)
  69412. */
  69413. static DATASOURCE_DYNAMIC: number;
  69414. /**
  69415. * Texture content is generated by rendering to it
  69416. */
  69417. static DATASOURCE_RENDERTARGET: number;
  69418. /**
  69419. * Texture content is part of a multi render target process
  69420. */
  69421. static DATASOURCE_MULTIRENDERTARGET: number;
  69422. /**
  69423. * Texture data comes from a cube data file
  69424. */
  69425. static DATASOURCE_CUBE: number;
  69426. /**
  69427. * Texture data comes from a raw cube data
  69428. */
  69429. static DATASOURCE_CUBERAW: number;
  69430. /**
  69431. * Texture data come from a prefiltered cube data file
  69432. */
  69433. static DATASOURCE_CUBEPREFILTERED: number;
  69434. /**
  69435. * Texture content is raw 3D data
  69436. */
  69437. static DATASOURCE_RAW3D: number;
  69438. /**
  69439. * Texture content is a depth texture
  69440. */
  69441. static DATASOURCE_DEPTHTEXTURE: number;
  69442. /**
  69443. * Texture data comes from a raw cube data encoded with RGBD
  69444. */
  69445. static DATASOURCE_CUBERAW_RGBD: number;
  69446. /**
  69447. * Defines if the texture is ready
  69448. */
  69449. isReady: boolean;
  69450. /**
  69451. * Defines if the texture is a cube texture
  69452. */
  69453. isCube: boolean;
  69454. /**
  69455. * Defines if the texture contains 3D data
  69456. */
  69457. is3D: boolean;
  69458. /**
  69459. * Defines if the texture contains multiview data
  69460. */
  69461. isMultiview: boolean;
  69462. /**
  69463. * Gets the URL used to load this texture
  69464. */
  69465. url: string;
  69466. /**
  69467. * Gets the sampling mode of the texture
  69468. */
  69469. samplingMode: number;
  69470. /**
  69471. * Gets a boolean indicating if the texture needs mipmaps generation
  69472. */
  69473. generateMipMaps: boolean;
  69474. /**
  69475. * Gets the number of samples used by the texture (WebGL2+ only)
  69476. */
  69477. samples: number;
  69478. /**
  69479. * Gets the type of the texture (int, float...)
  69480. */
  69481. type: number;
  69482. /**
  69483. * Gets the format of the texture (RGB, RGBA...)
  69484. */
  69485. format: number;
  69486. /**
  69487. * Observable called when the texture is loaded
  69488. */
  69489. onLoadedObservable: Observable<InternalTexture>;
  69490. /**
  69491. * Gets the width of the texture
  69492. */
  69493. width: number;
  69494. /**
  69495. * Gets the height of the texture
  69496. */
  69497. height: number;
  69498. /**
  69499. * Gets the depth of the texture
  69500. */
  69501. depth: number;
  69502. /**
  69503. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  69504. */
  69505. baseWidth: number;
  69506. /**
  69507. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  69508. */
  69509. baseHeight: number;
  69510. /**
  69511. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  69512. */
  69513. baseDepth: number;
  69514. /**
  69515. * Gets a boolean indicating if the texture is inverted on Y axis
  69516. */
  69517. invertY: boolean;
  69518. /** @hidden */
  69519. _invertVScale: boolean;
  69520. /** @hidden */
  69521. _associatedChannel: number;
  69522. /** @hidden */
  69523. _dataSource: number;
  69524. /** @hidden */
  69525. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  69526. /** @hidden */
  69527. _bufferView: Nullable<ArrayBufferView>;
  69528. /** @hidden */
  69529. _bufferViewArray: Nullable<ArrayBufferView[]>;
  69530. /** @hidden */
  69531. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  69532. /** @hidden */
  69533. _size: number;
  69534. /** @hidden */
  69535. _extension: string;
  69536. /** @hidden */
  69537. _files: Nullable<string[]>;
  69538. /** @hidden */
  69539. _workingCanvas: Nullable<HTMLCanvasElement>;
  69540. /** @hidden */
  69541. _workingContext: Nullable<CanvasRenderingContext2D>;
  69542. /** @hidden */
  69543. _framebuffer: Nullable<WebGLFramebuffer>;
  69544. /** @hidden */
  69545. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  69546. /** @hidden */
  69547. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  69548. /** @hidden */
  69549. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  69550. /** @hidden */
  69551. _attachments: Nullable<number[]>;
  69552. /** @hidden */
  69553. _cachedCoordinatesMode: Nullable<number>;
  69554. /** @hidden */
  69555. _cachedWrapU: Nullable<number>;
  69556. /** @hidden */
  69557. _cachedWrapV: Nullable<number>;
  69558. /** @hidden */
  69559. _cachedWrapR: Nullable<number>;
  69560. /** @hidden */
  69561. _cachedAnisotropicFilteringLevel: Nullable<number>;
  69562. /** @hidden */
  69563. _isDisabled: boolean;
  69564. /** @hidden */
  69565. _compression: Nullable<string>;
  69566. /** @hidden */
  69567. _generateStencilBuffer: boolean;
  69568. /** @hidden */
  69569. _generateDepthBuffer: boolean;
  69570. /** @hidden */
  69571. _comparisonFunction: number;
  69572. /** @hidden */
  69573. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  69574. /** @hidden */
  69575. _lodGenerationScale: number;
  69576. /** @hidden */
  69577. _lodGenerationOffset: number;
  69578. /** @hidden */
  69579. _colorTextureArray: Nullable<WebGLTexture>;
  69580. /** @hidden */
  69581. _depthStencilTextureArray: Nullable<WebGLTexture>;
  69582. /** @hidden */
  69583. _lodTextureHigh: Nullable<BaseTexture>;
  69584. /** @hidden */
  69585. _lodTextureMid: Nullable<BaseTexture>;
  69586. /** @hidden */
  69587. _lodTextureLow: Nullable<BaseTexture>;
  69588. /** @hidden */
  69589. _isRGBD: boolean;
  69590. /** @hidden */
  69591. _linearSpecularLOD: boolean;
  69592. /** @hidden */
  69593. _irradianceTexture: Nullable<BaseTexture>;
  69594. /** @hidden */
  69595. _webGLTexture: Nullable<WebGLTexture>;
  69596. /** @hidden */
  69597. _references: number;
  69598. private _engine;
  69599. /**
  69600. * Gets the Engine the texture belongs to.
  69601. * @returns The babylon engine
  69602. */
  69603. getEngine(): Engine;
  69604. /**
  69605. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  69606. */
  69607. readonly dataSource: number;
  69608. /**
  69609. * Creates a new InternalTexture
  69610. * @param engine defines the engine to use
  69611. * @param dataSource defines the type of data that will be used
  69612. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69613. */
  69614. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  69615. /**
  69616. * Increments the number of references (ie. the number of Texture that point to it)
  69617. */
  69618. incrementReferences(): void;
  69619. /**
  69620. * Change the size of the texture (not the size of the content)
  69621. * @param width defines the new width
  69622. * @param height defines the new height
  69623. * @param depth defines the new depth (1 by default)
  69624. */
  69625. updateSize(width: int, height: int, depth?: int): void;
  69626. /** @hidden */
  69627. _rebuild(): void;
  69628. /** @hidden */
  69629. _swapAndDie(target: InternalTexture): void;
  69630. /**
  69631. * Dispose the current allocated resources
  69632. */
  69633. dispose(): void;
  69634. }
  69635. }
  69636. declare module BABYLON {
  69637. /**
  69638. * This represents the main contract an easing function should follow.
  69639. * Easing functions are used throughout the animation system.
  69640. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69641. */
  69642. export interface IEasingFunction {
  69643. /**
  69644. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69645. * of the easing function.
  69646. * The link below provides some of the most common examples of easing functions.
  69647. * @see https://easings.net/
  69648. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69649. * @returns the corresponding value on the curve defined by the easing function
  69650. */
  69651. ease(gradient: number): number;
  69652. }
  69653. /**
  69654. * Base class used for every default easing function.
  69655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69656. */
  69657. export class EasingFunction implements IEasingFunction {
  69658. /**
  69659. * Interpolation follows the mathematical formula associated with the easing function.
  69660. */
  69661. static readonly EASINGMODE_EASEIN: number;
  69662. /**
  69663. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69664. */
  69665. static readonly EASINGMODE_EASEOUT: number;
  69666. /**
  69667. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69668. */
  69669. static readonly EASINGMODE_EASEINOUT: number;
  69670. private _easingMode;
  69671. /**
  69672. * Sets the easing mode of the current function.
  69673. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69674. */
  69675. setEasingMode(easingMode: number): void;
  69676. /**
  69677. * Gets the current easing mode.
  69678. * @returns the easing mode
  69679. */
  69680. getEasingMode(): number;
  69681. /**
  69682. * @hidden
  69683. */
  69684. easeInCore(gradient: number): number;
  69685. /**
  69686. * Given an input gradient between 0 and 1, this returns the corresponding value
  69687. * of the easing function.
  69688. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69689. * @returns the corresponding value on the curve defined by the easing function
  69690. */
  69691. ease(gradient: number): number;
  69692. }
  69693. /**
  69694. * Easing function with a circle shape (see link below).
  69695. * @see https://easings.net/#easeInCirc
  69696. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69697. */
  69698. export class CircleEase extends EasingFunction implements IEasingFunction {
  69699. /** @hidden */
  69700. easeInCore(gradient: number): number;
  69701. }
  69702. /**
  69703. * Easing function with a ease back shape (see link below).
  69704. * @see https://easings.net/#easeInBack
  69705. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69706. */
  69707. export class BackEase extends EasingFunction implements IEasingFunction {
  69708. /** Defines the amplitude of the function */
  69709. amplitude: number;
  69710. /**
  69711. * Instantiates a back ease easing
  69712. * @see https://easings.net/#easeInBack
  69713. * @param amplitude Defines the amplitude of the function
  69714. */
  69715. constructor(
  69716. /** Defines the amplitude of the function */
  69717. amplitude?: number);
  69718. /** @hidden */
  69719. easeInCore(gradient: number): number;
  69720. }
  69721. /**
  69722. * Easing function with a bouncing shape (see link below).
  69723. * @see https://easings.net/#easeInBounce
  69724. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69725. */
  69726. export class BounceEase extends EasingFunction implements IEasingFunction {
  69727. /** Defines the number of bounces */
  69728. bounces: number;
  69729. /** Defines the amplitude of the bounce */
  69730. bounciness: number;
  69731. /**
  69732. * Instantiates a bounce easing
  69733. * @see https://easings.net/#easeInBounce
  69734. * @param bounces Defines the number of bounces
  69735. * @param bounciness Defines the amplitude of the bounce
  69736. */
  69737. constructor(
  69738. /** Defines the number of bounces */
  69739. bounces?: number,
  69740. /** Defines the amplitude of the bounce */
  69741. bounciness?: number);
  69742. /** @hidden */
  69743. easeInCore(gradient: number): number;
  69744. }
  69745. /**
  69746. * Easing function with a power of 3 shape (see link below).
  69747. * @see https://easings.net/#easeInCubic
  69748. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69749. */
  69750. export class CubicEase extends EasingFunction implements IEasingFunction {
  69751. /** @hidden */
  69752. easeInCore(gradient: number): number;
  69753. }
  69754. /**
  69755. * Easing function with an elastic shape (see link below).
  69756. * @see https://easings.net/#easeInElastic
  69757. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69758. */
  69759. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69760. /** Defines the number of oscillations*/
  69761. oscillations: number;
  69762. /** Defines the amplitude of the oscillations*/
  69763. springiness: number;
  69764. /**
  69765. * Instantiates an elastic easing function
  69766. * @see https://easings.net/#easeInElastic
  69767. * @param oscillations Defines the number of oscillations
  69768. * @param springiness Defines the amplitude of the oscillations
  69769. */
  69770. constructor(
  69771. /** Defines the number of oscillations*/
  69772. oscillations?: number,
  69773. /** Defines the amplitude of the oscillations*/
  69774. springiness?: number);
  69775. /** @hidden */
  69776. easeInCore(gradient: number): number;
  69777. }
  69778. /**
  69779. * Easing function with an exponential shape (see link below).
  69780. * @see https://easings.net/#easeInExpo
  69781. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69782. */
  69783. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69784. /** Defines the exponent of the function */
  69785. exponent: number;
  69786. /**
  69787. * Instantiates an exponential easing function
  69788. * @see https://easings.net/#easeInExpo
  69789. * @param exponent Defines the exponent of the function
  69790. */
  69791. constructor(
  69792. /** Defines the exponent of the function */
  69793. exponent?: number);
  69794. /** @hidden */
  69795. easeInCore(gradient: number): number;
  69796. }
  69797. /**
  69798. * Easing function with a power shape (see link below).
  69799. * @see https://easings.net/#easeInQuad
  69800. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69801. */
  69802. export class PowerEase extends EasingFunction implements IEasingFunction {
  69803. /** Defines the power of the function */
  69804. power: number;
  69805. /**
  69806. * Instantiates an power base easing function
  69807. * @see https://easings.net/#easeInQuad
  69808. * @param power Defines the power of the function
  69809. */
  69810. constructor(
  69811. /** Defines the power of the function */
  69812. power?: number);
  69813. /** @hidden */
  69814. easeInCore(gradient: number): number;
  69815. }
  69816. /**
  69817. * Easing function with a power of 2 shape (see link below).
  69818. * @see https://easings.net/#easeInQuad
  69819. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69820. */
  69821. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69822. /** @hidden */
  69823. easeInCore(gradient: number): number;
  69824. }
  69825. /**
  69826. * Easing function with a power of 4 shape (see link below).
  69827. * @see https://easings.net/#easeInQuart
  69828. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69829. */
  69830. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69831. /** @hidden */
  69832. easeInCore(gradient: number): number;
  69833. }
  69834. /**
  69835. * Easing function with a power of 5 shape (see link below).
  69836. * @see https://easings.net/#easeInQuint
  69837. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69838. */
  69839. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69840. /** @hidden */
  69841. easeInCore(gradient: number): number;
  69842. }
  69843. /**
  69844. * Easing function with a sin shape (see link below).
  69845. * @see https://easings.net/#easeInSine
  69846. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69847. */
  69848. export class SineEase extends EasingFunction implements IEasingFunction {
  69849. /** @hidden */
  69850. easeInCore(gradient: number): number;
  69851. }
  69852. /**
  69853. * Easing function with a bezier shape (see link below).
  69854. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69855. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69856. */
  69857. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69858. /** Defines the x component of the start tangent in the bezier curve */
  69859. x1: number;
  69860. /** Defines the y component of the start tangent in the bezier curve */
  69861. y1: number;
  69862. /** Defines the x component of the end tangent in the bezier curve */
  69863. x2: number;
  69864. /** Defines the y component of the end tangent in the bezier curve */
  69865. y2: number;
  69866. /**
  69867. * Instantiates a bezier function
  69868. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69869. * @param x1 Defines the x component of the start tangent in the bezier curve
  69870. * @param y1 Defines the y component of the start tangent in the bezier curve
  69871. * @param x2 Defines the x component of the end tangent in the bezier curve
  69872. * @param y2 Defines the y component of the end tangent in the bezier curve
  69873. */
  69874. constructor(
  69875. /** Defines the x component of the start tangent in the bezier curve */
  69876. x1?: number,
  69877. /** Defines the y component of the start tangent in the bezier curve */
  69878. y1?: number,
  69879. /** Defines the x component of the end tangent in the bezier curve */
  69880. x2?: number,
  69881. /** Defines the y component of the end tangent in the bezier curve */
  69882. y2?: number);
  69883. /** @hidden */
  69884. easeInCore(gradient: number): number;
  69885. }
  69886. }
  69887. declare module BABYLON {
  69888. /**
  69889. * Defines an interface which represents an animation key frame
  69890. */
  69891. export interface IAnimationKey {
  69892. /**
  69893. * Frame of the key frame
  69894. */
  69895. frame: number;
  69896. /**
  69897. * Value at the specifies key frame
  69898. */
  69899. value: any;
  69900. /**
  69901. * The input tangent for the cubic hermite spline
  69902. */
  69903. inTangent?: any;
  69904. /**
  69905. * The output tangent for the cubic hermite spline
  69906. */
  69907. outTangent?: any;
  69908. /**
  69909. * The animation interpolation type
  69910. */
  69911. interpolation?: AnimationKeyInterpolation;
  69912. }
  69913. /**
  69914. * Enum for the animation key frame interpolation type
  69915. */
  69916. export enum AnimationKeyInterpolation {
  69917. /**
  69918. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69919. */
  69920. STEP = 1
  69921. }
  69922. }
  69923. declare module BABYLON {
  69924. /**
  69925. * Represents the range of an animation
  69926. */
  69927. export class AnimationRange {
  69928. /**The name of the animation range**/
  69929. name: string;
  69930. /**The starting frame of the animation */
  69931. from: number;
  69932. /**The ending frame of the animation*/
  69933. to: number;
  69934. /**
  69935. * Initializes the range of an animation
  69936. * @param name The name of the animation range
  69937. * @param from The starting frame of the animation
  69938. * @param to The ending frame of the animation
  69939. */
  69940. constructor(
  69941. /**The name of the animation range**/
  69942. name: string,
  69943. /**The starting frame of the animation */
  69944. from: number,
  69945. /**The ending frame of the animation*/
  69946. to: number);
  69947. /**
  69948. * Makes a copy of the animation range
  69949. * @returns A copy of the animation range
  69950. */
  69951. clone(): AnimationRange;
  69952. }
  69953. }
  69954. declare module BABYLON {
  69955. /**
  69956. * Composed of a frame, and an action function
  69957. */
  69958. export class AnimationEvent {
  69959. /** The frame for which the event is triggered **/
  69960. frame: number;
  69961. /** The event to perform when triggered **/
  69962. action: (currentFrame: number) => void;
  69963. /** Specifies if the event should be triggered only once**/
  69964. onlyOnce?: boolean | undefined;
  69965. /**
  69966. * Specifies if the animation event is done
  69967. */
  69968. isDone: boolean;
  69969. /**
  69970. * Initializes the animation event
  69971. * @param frame The frame for which the event is triggered
  69972. * @param action The event to perform when triggered
  69973. * @param onlyOnce Specifies if the event should be triggered only once
  69974. */
  69975. constructor(
  69976. /** The frame for which the event is triggered **/
  69977. frame: number,
  69978. /** The event to perform when triggered **/
  69979. action: (currentFrame: number) => void,
  69980. /** Specifies if the event should be triggered only once**/
  69981. onlyOnce?: boolean | undefined);
  69982. /** @hidden */
  69983. _clone(): AnimationEvent;
  69984. }
  69985. }
  69986. declare module BABYLON {
  69987. /**
  69988. * Interface used to define a behavior
  69989. */
  69990. export interface Behavior<T> {
  69991. /** gets or sets behavior's name */
  69992. name: string;
  69993. /**
  69994. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69995. */
  69996. init(): void;
  69997. /**
  69998. * Called when the behavior is attached to a target
  69999. * @param target defines the target where the behavior is attached to
  70000. */
  70001. attach(target: T): void;
  70002. /**
  70003. * Called when the behavior is detached from its target
  70004. */
  70005. detach(): void;
  70006. }
  70007. /**
  70008. * Interface implemented by classes supporting behaviors
  70009. */
  70010. export interface IBehaviorAware<T> {
  70011. /**
  70012. * Attach a behavior
  70013. * @param behavior defines the behavior to attach
  70014. * @returns the current host
  70015. */
  70016. addBehavior(behavior: Behavior<T>): T;
  70017. /**
  70018. * Remove a behavior from the current object
  70019. * @param behavior defines the behavior to detach
  70020. * @returns the current host
  70021. */
  70022. removeBehavior(behavior: Behavior<T>): T;
  70023. /**
  70024. * Gets a behavior using its name to search
  70025. * @param name defines the name to search
  70026. * @returns the behavior or null if not found
  70027. */
  70028. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  70029. }
  70030. }
  70031. declare module BABYLON {
  70032. /**
  70033. * @hidden
  70034. */
  70035. export class IntersectionInfo {
  70036. bu: Nullable<number>;
  70037. bv: Nullable<number>;
  70038. distance: number;
  70039. faceId: number;
  70040. subMeshId: number;
  70041. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  70042. }
  70043. }
  70044. declare module BABYLON {
  70045. /**
  70046. * Class used to store bounding sphere information
  70047. */
  70048. export class BoundingSphere {
  70049. /**
  70050. * Gets the center of the bounding sphere in local space
  70051. */
  70052. readonly center: Vector3;
  70053. /**
  70054. * Radius of the bounding sphere in local space
  70055. */
  70056. radius: number;
  70057. /**
  70058. * Gets the center of the bounding sphere in world space
  70059. */
  70060. readonly centerWorld: Vector3;
  70061. /**
  70062. * Radius of the bounding sphere in world space
  70063. */
  70064. radiusWorld: number;
  70065. /**
  70066. * Gets the minimum vector in local space
  70067. */
  70068. readonly minimum: Vector3;
  70069. /**
  70070. * Gets the maximum vector in local space
  70071. */
  70072. readonly maximum: Vector3;
  70073. private _worldMatrix;
  70074. private static readonly TmpVector3;
  70075. /**
  70076. * Creates a new bounding sphere
  70077. * @param min defines the minimum vector (in local space)
  70078. * @param max defines the maximum vector (in local space)
  70079. * @param worldMatrix defines the new world matrix
  70080. */
  70081. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70082. /**
  70083. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  70084. * @param min defines the new minimum vector (in local space)
  70085. * @param max defines the new maximum vector (in local space)
  70086. * @param worldMatrix defines the new world matrix
  70087. */
  70088. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70089. /**
  70090. * Scale the current bounding sphere by applying a scale factor
  70091. * @param factor defines the scale factor to apply
  70092. * @returns the current bounding box
  70093. */
  70094. scale(factor: number): BoundingSphere;
  70095. /**
  70096. * Gets the world matrix of the bounding box
  70097. * @returns a matrix
  70098. */
  70099. getWorldMatrix(): DeepImmutable<Matrix>;
  70100. /** @hidden */
  70101. _update(worldMatrix: DeepImmutable<Matrix>): void;
  70102. /**
  70103. * Tests if the bounding sphere is intersecting the frustum planes
  70104. * @param frustumPlanes defines the frustum planes to test
  70105. * @returns true if there is an intersection
  70106. */
  70107. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70108. /**
  70109. * Tests if the bounding sphere center is in between the frustum planes.
  70110. * Used for optimistic fast inclusion.
  70111. * @param frustumPlanes defines the frustum planes to test
  70112. * @returns true if the sphere center is in between the frustum planes
  70113. */
  70114. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70115. /**
  70116. * Tests if a point is inside the bounding sphere
  70117. * @param point defines the point to test
  70118. * @returns true if the point is inside the bounding sphere
  70119. */
  70120. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70121. /**
  70122. * Checks if two sphere intersct
  70123. * @param sphere0 sphere 0
  70124. * @param sphere1 sphere 1
  70125. * @returns true if the speres intersect
  70126. */
  70127. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  70128. }
  70129. }
  70130. declare module BABYLON {
  70131. /**
  70132. * Class used to store bounding box information
  70133. */
  70134. export class BoundingBox implements ICullable {
  70135. /**
  70136. * Gets the 8 vectors representing the bounding box in local space
  70137. */
  70138. readonly vectors: Vector3[];
  70139. /**
  70140. * Gets the center of the bounding box in local space
  70141. */
  70142. readonly center: Vector3;
  70143. /**
  70144. * Gets the center of the bounding box in world space
  70145. */
  70146. readonly centerWorld: Vector3;
  70147. /**
  70148. * Gets the extend size in local space
  70149. */
  70150. readonly extendSize: Vector3;
  70151. /**
  70152. * Gets the extend size in world space
  70153. */
  70154. readonly extendSizeWorld: Vector3;
  70155. /**
  70156. * Gets the OBB (object bounding box) directions
  70157. */
  70158. readonly directions: Vector3[];
  70159. /**
  70160. * Gets the 8 vectors representing the bounding box in world space
  70161. */
  70162. readonly vectorsWorld: Vector3[];
  70163. /**
  70164. * Gets the minimum vector in world space
  70165. */
  70166. readonly minimumWorld: Vector3;
  70167. /**
  70168. * Gets the maximum vector in world space
  70169. */
  70170. readonly maximumWorld: Vector3;
  70171. /**
  70172. * Gets the minimum vector in local space
  70173. */
  70174. readonly minimum: Vector3;
  70175. /**
  70176. * Gets the maximum vector in local space
  70177. */
  70178. readonly maximum: Vector3;
  70179. private _worldMatrix;
  70180. private static readonly TmpVector3;
  70181. /**
  70182. * @hidden
  70183. */
  70184. _tag: number;
  70185. /**
  70186. * Creates a new bounding box
  70187. * @param min defines the minimum vector (in local space)
  70188. * @param max defines the maximum vector (in local space)
  70189. * @param worldMatrix defines the new world matrix
  70190. */
  70191. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70192. /**
  70193. * Recreates the entire bounding box from scratch as if we call the constructor in place
  70194. * @param min defines the new minimum vector (in local space)
  70195. * @param max defines the new maximum vector (in local space)
  70196. * @param worldMatrix defines the new world matrix
  70197. */
  70198. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70199. /**
  70200. * Scale the current bounding box by applying a scale factor
  70201. * @param factor defines the scale factor to apply
  70202. * @returns the current bounding box
  70203. */
  70204. scale(factor: number): BoundingBox;
  70205. /**
  70206. * Gets the world matrix of the bounding box
  70207. * @returns a matrix
  70208. */
  70209. getWorldMatrix(): DeepImmutable<Matrix>;
  70210. /** @hidden */
  70211. _update(world: DeepImmutable<Matrix>): void;
  70212. /**
  70213. * Tests if the bounding box is intersecting the frustum planes
  70214. * @param frustumPlanes defines the frustum planes to test
  70215. * @returns true if there is an intersection
  70216. */
  70217. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70218. /**
  70219. * Tests if the bounding box is entirely inside the frustum planes
  70220. * @param frustumPlanes defines the frustum planes to test
  70221. * @returns true if there is an inclusion
  70222. */
  70223. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70224. /**
  70225. * Tests if a point is inside the bounding box
  70226. * @param point defines the point to test
  70227. * @returns true if the point is inside the bounding box
  70228. */
  70229. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70230. /**
  70231. * Tests if the bounding box intersects with a bounding sphere
  70232. * @param sphere defines the sphere to test
  70233. * @returns true if there is an intersection
  70234. */
  70235. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  70236. /**
  70237. * Tests if the bounding box intersects with a box defined by a min and max vectors
  70238. * @param min defines the min vector to use
  70239. * @param max defines the max vector to use
  70240. * @returns true if there is an intersection
  70241. */
  70242. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  70243. /**
  70244. * Tests if two bounding boxes are intersections
  70245. * @param box0 defines the first box to test
  70246. * @param box1 defines the second box to test
  70247. * @returns true if there is an intersection
  70248. */
  70249. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  70250. /**
  70251. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  70252. * @param minPoint defines the minimum vector of the bounding box
  70253. * @param maxPoint defines the maximum vector of the bounding box
  70254. * @param sphereCenter defines the sphere center
  70255. * @param sphereRadius defines the sphere radius
  70256. * @returns true if there is an intersection
  70257. */
  70258. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  70259. /**
  70260. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  70261. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70262. * @param frustumPlanes defines the frustum planes to test
  70263. * @return true if there is an inclusion
  70264. */
  70265. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70266. /**
  70267. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  70268. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70269. * @param frustumPlanes defines the frustum planes to test
  70270. * @return true if there is an intersection
  70271. */
  70272. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70273. }
  70274. }
  70275. declare module BABYLON {
  70276. /** @hidden */
  70277. export class Collider {
  70278. /** Define if a collision was found */
  70279. collisionFound: boolean;
  70280. /**
  70281. * Define last intersection point in local space
  70282. */
  70283. intersectionPoint: Vector3;
  70284. /**
  70285. * Define last collided mesh
  70286. */
  70287. collidedMesh: Nullable<AbstractMesh>;
  70288. private _collisionPoint;
  70289. private _planeIntersectionPoint;
  70290. private _tempVector;
  70291. private _tempVector2;
  70292. private _tempVector3;
  70293. private _tempVector4;
  70294. private _edge;
  70295. private _baseToVertex;
  70296. private _destinationPoint;
  70297. private _slidePlaneNormal;
  70298. private _displacementVector;
  70299. /** @hidden */
  70300. _radius: Vector3;
  70301. /** @hidden */
  70302. _retry: number;
  70303. private _velocity;
  70304. private _basePoint;
  70305. private _epsilon;
  70306. /** @hidden */
  70307. _velocityWorldLength: number;
  70308. /** @hidden */
  70309. _basePointWorld: Vector3;
  70310. private _velocityWorld;
  70311. private _normalizedVelocity;
  70312. /** @hidden */
  70313. _initialVelocity: Vector3;
  70314. /** @hidden */
  70315. _initialPosition: Vector3;
  70316. private _nearestDistance;
  70317. private _collisionMask;
  70318. collisionMask: number;
  70319. /**
  70320. * Gets the plane normal used to compute the sliding response (in local space)
  70321. */
  70322. readonly slidePlaneNormal: Vector3;
  70323. /** @hidden */
  70324. _initialize(source: Vector3, dir: Vector3, e: number): void;
  70325. /** @hidden */
  70326. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  70327. /** @hidden */
  70328. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  70329. /** @hidden */
  70330. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  70331. /** @hidden */
  70332. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  70333. /** @hidden */
  70334. _getResponse(pos: Vector3, vel: Vector3): void;
  70335. }
  70336. }
  70337. declare module BABYLON {
  70338. /**
  70339. * Interface for cullable objects
  70340. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  70341. */
  70342. export interface ICullable {
  70343. /**
  70344. * Checks if the object or part of the object is in the frustum
  70345. * @param frustumPlanes Camera near/planes
  70346. * @returns true if the object is in frustum otherwise false
  70347. */
  70348. isInFrustum(frustumPlanes: Plane[]): boolean;
  70349. /**
  70350. * Checks if a cullable object (mesh...) is in the camera frustum
  70351. * Unlike isInFrustum this cheks the full bounding box
  70352. * @param frustumPlanes Camera near/planes
  70353. * @returns true if the object is in frustum otherwise false
  70354. */
  70355. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  70356. }
  70357. /**
  70358. * Info for a bounding data of a mesh
  70359. */
  70360. export class BoundingInfo implements ICullable {
  70361. /**
  70362. * Bounding box for the mesh
  70363. */
  70364. readonly boundingBox: BoundingBox;
  70365. /**
  70366. * Bounding sphere for the mesh
  70367. */
  70368. readonly boundingSphere: BoundingSphere;
  70369. private _isLocked;
  70370. private static readonly TmpVector3;
  70371. /**
  70372. * Constructs bounding info
  70373. * @param minimum min vector of the bounding box/sphere
  70374. * @param maximum max vector of the bounding box/sphere
  70375. * @param worldMatrix defines the new world matrix
  70376. */
  70377. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70378. /**
  70379. * Recreates the entire bounding info from scratch as if we call the constructor in place
  70380. * @param min defines the new minimum vector (in local space)
  70381. * @param max defines the new maximum vector (in local space)
  70382. * @param worldMatrix defines the new world matrix
  70383. */
  70384. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70385. /**
  70386. * min vector of the bounding box/sphere
  70387. */
  70388. readonly minimum: Vector3;
  70389. /**
  70390. * max vector of the bounding box/sphere
  70391. */
  70392. readonly maximum: Vector3;
  70393. /**
  70394. * If the info is locked and won't be updated to avoid perf overhead
  70395. */
  70396. isLocked: boolean;
  70397. /**
  70398. * Updates the bounding sphere and box
  70399. * @param world world matrix to be used to update
  70400. */
  70401. update(world: DeepImmutable<Matrix>): void;
  70402. /**
  70403. * Recreate the bounding info to be centered around a specific point given a specific extend.
  70404. * @param center New center of the bounding info
  70405. * @param extend New extend of the bounding info
  70406. * @returns the current bounding info
  70407. */
  70408. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  70409. /**
  70410. * Scale the current bounding info by applying a scale factor
  70411. * @param factor defines the scale factor to apply
  70412. * @returns the current bounding info
  70413. */
  70414. scale(factor: number): BoundingInfo;
  70415. /**
  70416. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70417. * @param frustumPlanes defines the frustum to test
  70418. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70419. * @returns true if the bounding info is in the frustum planes
  70420. */
  70421. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70422. /**
  70423. * Gets the world distance between the min and max points of the bounding box
  70424. */
  70425. readonly diagonalLength: number;
  70426. /**
  70427. * Checks if a cullable object (mesh...) is in the camera frustum
  70428. * Unlike isInFrustum this cheks the full bounding box
  70429. * @param frustumPlanes Camera near/planes
  70430. * @returns true if the object is in frustum otherwise false
  70431. */
  70432. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70433. /** @hidden */
  70434. _checkCollision(collider: Collider): boolean;
  70435. /**
  70436. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70437. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70438. * @param point the point to check intersection with
  70439. * @returns if the point intersects
  70440. */
  70441. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70442. /**
  70443. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70444. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70445. * @param boundingInfo the bounding info to check intersection with
  70446. * @param precise if the intersection should be done using OBB
  70447. * @returns if the bounding info intersects
  70448. */
  70449. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70450. }
  70451. }
  70452. declare module BABYLON {
  70453. /**
  70454. * Defines an array and its length.
  70455. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70456. */
  70457. export interface ISmartArrayLike<T> {
  70458. /**
  70459. * The data of the array.
  70460. */
  70461. data: Array<T>;
  70462. /**
  70463. * The active length of the array.
  70464. */
  70465. length: number;
  70466. }
  70467. /**
  70468. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70469. */
  70470. export class SmartArray<T> implements ISmartArrayLike<T> {
  70471. /**
  70472. * The full set of data from the array.
  70473. */
  70474. data: Array<T>;
  70475. /**
  70476. * The active length of the array.
  70477. */
  70478. length: number;
  70479. protected _id: number;
  70480. /**
  70481. * Instantiates a Smart Array.
  70482. * @param capacity defines the default capacity of the array.
  70483. */
  70484. constructor(capacity: number);
  70485. /**
  70486. * Pushes a value at the end of the active data.
  70487. * @param value defines the object to push in the array.
  70488. */
  70489. push(value: T): void;
  70490. /**
  70491. * Iterates over the active data and apply the lambda to them.
  70492. * @param func defines the action to apply on each value.
  70493. */
  70494. forEach(func: (content: T) => void): void;
  70495. /**
  70496. * Sorts the full sets of data.
  70497. * @param compareFn defines the comparison function to apply.
  70498. */
  70499. sort(compareFn: (a: T, b: T) => number): void;
  70500. /**
  70501. * Resets the active data to an empty array.
  70502. */
  70503. reset(): void;
  70504. /**
  70505. * Releases all the data from the array as well as the array.
  70506. */
  70507. dispose(): void;
  70508. /**
  70509. * Concats the active data with a given array.
  70510. * @param array defines the data to concatenate with.
  70511. */
  70512. concat(array: any): void;
  70513. /**
  70514. * Returns the position of a value in the active data.
  70515. * @param value defines the value to find the index for
  70516. * @returns the index if found in the active data otherwise -1
  70517. */
  70518. indexOf(value: T): number;
  70519. /**
  70520. * Returns whether an element is part of the active data.
  70521. * @param value defines the value to look for
  70522. * @returns true if found in the active data otherwise false
  70523. */
  70524. contains(value: T): boolean;
  70525. private static _GlobalId;
  70526. }
  70527. /**
  70528. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70529. * The data in this array can only be present once
  70530. */
  70531. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70532. private _duplicateId;
  70533. /**
  70534. * Pushes a value at the end of the active data.
  70535. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70536. * @param value defines the object to push in the array.
  70537. */
  70538. push(value: T): void;
  70539. /**
  70540. * Pushes a value at the end of the active data.
  70541. * If the data is already present, it won t be added again
  70542. * @param value defines the object to push in the array.
  70543. * @returns true if added false if it was already present
  70544. */
  70545. pushNoDuplicate(value: T): boolean;
  70546. /**
  70547. * Resets the active data to an empty array.
  70548. */
  70549. reset(): void;
  70550. /**
  70551. * Concats the active data with a given array.
  70552. * This ensures no dupplicate will be present in the result.
  70553. * @param array defines the data to concatenate with.
  70554. */
  70555. concatWithNoDuplicate(array: any): void;
  70556. }
  70557. }
  70558. declare module BABYLON {
  70559. /**
  70560. * Enum that determines the text-wrapping mode to use.
  70561. */
  70562. export enum InspectableType {
  70563. /**
  70564. * Checkbox for booleans
  70565. */
  70566. Checkbox = 0,
  70567. /**
  70568. * Sliders for numbers
  70569. */
  70570. Slider = 1,
  70571. /**
  70572. * Vector3
  70573. */
  70574. Vector3 = 2,
  70575. /**
  70576. * Quaternions
  70577. */
  70578. Quaternion = 3,
  70579. /**
  70580. * Color3
  70581. */
  70582. Color3 = 4
  70583. }
  70584. /**
  70585. * Interface used to define custom inspectable properties.
  70586. * This interface is used by the inspector to display custom property grids
  70587. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70588. */
  70589. export interface IInspectable {
  70590. /**
  70591. * Gets the label to display
  70592. */
  70593. label: string;
  70594. /**
  70595. * Gets the name of the property to edit
  70596. */
  70597. propertyName: string;
  70598. /**
  70599. * Gets the type of the editor to use
  70600. */
  70601. type: InspectableType;
  70602. /**
  70603. * Gets the minimum value of the property when using in "slider" mode
  70604. */
  70605. min?: number;
  70606. /**
  70607. * Gets the maximum value of the property when using in "slider" mode
  70608. */
  70609. max?: number;
  70610. /**
  70611. * Gets the setp to use when using in "slider" mode
  70612. */
  70613. step?: number;
  70614. }
  70615. }
  70616. declare module BABYLON {
  70617. /**
  70618. * This represents the required contract to create a new type of texture loader.
  70619. */
  70620. export interface IInternalTextureLoader {
  70621. /**
  70622. * Defines wether the loader supports cascade loading the different faces.
  70623. */
  70624. supportCascades: boolean;
  70625. /**
  70626. * This returns if the loader support the current file information.
  70627. * @param extension defines the file extension of the file being loaded
  70628. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70629. * @param fallback defines the fallback internal texture if any
  70630. * @param isBase64 defines whether the texture is encoded as a base64
  70631. * @param isBuffer defines whether the texture data are stored as a buffer
  70632. * @returns true if the loader can load the specified file
  70633. */
  70634. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70635. /**
  70636. * Transform the url before loading if required.
  70637. * @param rootUrl the url of the texture
  70638. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70639. * @returns the transformed texture
  70640. */
  70641. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70642. /**
  70643. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70644. * @param rootUrl the url of the texture
  70645. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70646. * @returns the fallback texture
  70647. */
  70648. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70649. /**
  70650. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70651. * @param data contains the texture data
  70652. * @param texture defines the BabylonJS internal texture
  70653. * @param createPolynomials will be true if polynomials have been requested
  70654. * @param onLoad defines the callback to trigger once the texture is ready
  70655. * @param onError defines the callback to trigger in case of error
  70656. */
  70657. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70658. /**
  70659. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70660. * @param data contains the texture data
  70661. * @param texture defines the BabylonJS internal texture
  70662. * @param callback defines the method to call once ready to upload
  70663. */
  70664. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70665. }
  70666. }
  70667. declare module BABYLON {
  70668. interface Engine {
  70669. /**
  70670. * Creates a depth stencil cube texture.
  70671. * This is only available in WebGL 2.
  70672. * @param size The size of face edge in the cube texture.
  70673. * @param options The options defining the cube texture.
  70674. * @returns The cube texture
  70675. */
  70676. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70677. /**
  70678. * Creates a cube texture
  70679. * @param rootUrl defines the url where the files to load is located
  70680. * @param scene defines the current scene
  70681. * @param files defines the list of files to load (1 per face)
  70682. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70683. * @param onLoad defines an optional callback raised when the texture is loaded
  70684. * @param onError defines an optional callback raised if there is an issue to load the texture
  70685. * @param format defines the format of the data
  70686. * @param forcedExtension defines the extension to use to pick the right loader
  70687. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70688. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70689. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70690. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70691. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70692. * @returns the cube texture as an InternalTexture
  70693. */
  70694. 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;
  70695. /**
  70696. * Creates a cube texture
  70697. * @param rootUrl defines the url where the files to load is located
  70698. * @param scene defines the current scene
  70699. * @param files defines the list of files to load (1 per face)
  70700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70701. * @param onLoad defines an optional callback raised when the texture is loaded
  70702. * @param onError defines an optional callback raised if there is an issue to load the texture
  70703. * @param format defines the format of the data
  70704. * @param forcedExtension defines the extension to use to pick the right loader
  70705. * @returns the cube texture as an InternalTexture
  70706. */
  70707. 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;
  70708. /**
  70709. * Creates a cube texture
  70710. * @param rootUrl defines the url where the files to load is located
  70711. * @param scene defines the current scene
  70712. * @param files defines the list of files to load (1 per face)
  70713. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70714. * @param onLoad defines an optional callback raised when the texture is loaded
  70715. * @param onError defines an optional callback raised if there is an issue to load the texture
  70716. * @param format defines the format of the data
  70717. * @param forcedExtension defines the extension to use to pick the right loader
  70718. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70719. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70720. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70721. * @returns the cube texture as an InternalTexture
  70722. */
  70723. 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;
  70724. /** @hidden */
  70725. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70726. /** @hidden */
  70727. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70728. /** @hidden */
  70729. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70730. /** @hidden */
  70731. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70732. }
  70733. }
  70734. declare module BABYLON {
  70735. /**
  70736. * Class for creating a cube texture
  70737. */
  70738. export class CubeTexture extends BaseTexture {
  70739. private _delayedOnLoad;
  70740. /**
  70741. * The url of the texture
  70742. */
  70743. url: string;
  70744. /**
  70745. * Gets or sets the center of the bounding box associated with the cube texture.
  70746. * It must define where the camera used to render the texture was set
  70747. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70748. */
  70749. boundingBoxPosition: Vector3;
  70750. private _boundingBoxSize;
  70751. /**
  70752. * Gets or sets the size of the bounding box associated with the cube texture
  70753. * When defined, the cubemap will switch to local mode
  70754. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70755. * @example https://www.babylonjs-playground.com/#RNASML
  70756. */
  70757. /**
  70758. * Returns the bounding box size
  70759. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70760. */
  70761. boundingBoxSize: Vector3;
  70762. protected _rotationY: number;
  70763. /**
  70764. * Sets texture matrix rotation angle around Y axis in radians.
  70765. */
  70766. /**
  70767. * Gets texture matrix rotation angle around Y axis radians.
  70768. */
  70769. rotationY: number;
  70770. /**
  70771. * Are mip maps generated for this texture or not.
  70772. */
  70773. readonly noMipmap: boolean;
  70774. private _noMipmap;
  70775. private _files;
  70776. private _extensions;
  70777. private _textureMatrix;
  70778. private _format;
  70779. private _createPolynomials;
  70780. /** @hidden */
  70781. _prefiltered: boolean;
  70782. /**
  70783. * Creates a cube texture from an array of image urls
  70784. * @param files defines an array of image urls
  70785. * @param scene defines the hosting scene
  70786. * @param noMipmap specifies if mip maps are not used
  70787. * @returns a cube texture
  70788. */
  70789. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70790. /**
  70791. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70792. * @param url defines the url of the prefiltered texture
  70793. * @param scene defines the scene the texture is attached to
  70794. * @param forcedExtension defines the extension of the file if different from the url
  70795. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70796. * @return the prefiltered texture
  70797. */
  70798. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70799. /**
  70800. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70801. * as prefiltered data.
  70802. * @param rootUrl defines the url of the texture or the root name of the six images
  70803. * @param scene defines the scene the texture is attached to
  70804. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70805. * @param noMipmap defines if mipmaps should be created or not
  70806. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70807. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70808. * @param onError defines a callback triggered in case of error during load
  70809. * @param format defines the internal format to use for the texture once loaded
  70810. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70811. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70812. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70813. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70814. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70815. * @return the cube texture
  70816. */
  70817. 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);
  70818. /**
  70819. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70820. */
  70821. readonly isPrefiltered: boolean;
  70822. /**
  70823. * Get the current class name of the texture useful for serialization or dynamic coding.
  70824. * @returns "CubeTexture"
  70825. */
  70826. getClassName(): string;
  70827. /**
  70828. * Update the url (and optional buffer) of this texture if url was null during construction.
  70829. * @param url the url of the texture
  70830. * @param forcedExtension defines the extension to use
  70831. * @param onLoad callback called when the texture is loaded (defaults to null)
  70832. */
  70833. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70834. /**
  70835. * Delays loading of the cube texture
  70836. * @param forcedExtension defines the extension to use
  70837. */
  70838. delayLoad(forcedExtension?: string): void;
  70839. /**
  70840. * Returns the reflection texture matrix
  70841. * @returns the reflection texture matrix
  70842. */
  70843. getReflectionTextureMatrix(): Matrix;
  70844. /**
  70845. * Sets the reflection texture matrix
  70846. * @param value Reflection texture matrix
  70847. */
  70848. setReflectionTextureMatrix(value: Matrix): void;
  70849. /**
  70850. * Parses text to create a cube texture
  70851. * @param parsedTexture define the serialized text to read from
  70852. * @param scene defines the hosting scene
  70853. * @param rootUrl defines the root url of the cube texture
  70854. * @returns a cube texture
  70855. */
  70856. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70857. /**
  70858. * Makes a clone, or deep copy, of the cube texture
  70859. * @returns a new cube texture
  70860. */
  70861. clone(): CubeTexture;
  70862. }
  70863. }
  70864. declare module BABYLON {
  70865. /** @hidden */
  70866. export var postprocessVertexShader: {
  70867. name: string;
  70868. shader: string;
  70869. };
  70870. }
  70871. declare module BABYLON {
  70872. /**
  70873. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70874. * This is the base of the follow, arc rotate cameras and Free camera
  70875. * @see http://doc.babylonjs.com/features/cameras
  70876. */
  70877. export class TargetCamera extends Camera {
  70878. private static _RigCamTransformMatrix;
  70879. private static _TargetTransformMatrix;
  70880. private static _TargetFocalPoint;
  70881. /**
  70882. * Define the current direction the camera is moving to
  70883. */
  70884. cameraDirection: Vector3;
  70885. /**
  70886. * Define the current rotation the camera is rotating to
  70887. */
  70888. cameraRotation: Vector2;
  70889. /**
  70890. * When set, the up vector of the camera will be updated by the rotation of the camera
  70891. */
  70892. updateUpVectorFromRotation: boolean;
  70893. private _tmpQuaternion;
  70894. /**
  70895. * Define the current rotation of the camera
  70896. */
  70897. rotation: Vector3;
  70898. /**
  70899. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70900. */
  70901. rotationQuaternion: Quaternion;
  70902. /**
  70903. * Define the current speed of the camera
  70904. */
  70905. speed: number;
  70906. /**
  70907. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70908. * around all axis.
  70909. */
  70910. noRotationConstraint: boolean;
  70911. /**
  70912. * Define the current target of the camera as an object or a position.
  70913. */
  70914. lockedTarget: any;
  70915. /** @hidden */
  70916. _currentTarget: Vector3;
  70917. /** @hidden */
  70918. _initialFocalDistance: number;
  70919. /** @hidden */
  70920. _viewMatrix: Matrix;
  70921. /** @hidden */
  70922. _camMatrix: Matrix;
  70923. /** @hidden */
  70924. _cameraTransformMatrix: Matrix;
  70925. /** @hidden */
  70926. _cameraRotationMatrix: Matrix;
  70927. /** @hidden */
  70928. _referencePoint: Vector3;
  70929. /** @hidden */
  70930. _transformedReferencePoint: Vector3;
  70931. protected _globalCurrentTarget: Vector3;
  70932. protected _globalCurrentUpVector: Vector3;
  70933. /** @hidden */
  70934. _reset: () => void;
  70935. private _defaultUp;
  70936. /**
  70937. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70938. * This is the base of the follow, arc rotate cameras and Free camera
  70939. * @see http://doc.babylonjs.com/features/cameras
  70940. * @param name Defines the name of the camera in the scene
  70941. * @param position Defines the start position of the camera in the scene
  70942. * @param scene Defines the scene the camera belongs to
  70943. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70944. */
  70945. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70946. /**
  70947. * Gets the position in front of the camera at a given distance.
  70948. * @param distance The distance from the camera we want the position to be
  70949. * @returns the position
  70950. */
  70951. getFrontPosition(distance: number): Vector3;
  70952. /** @hidden */
  70953. _getLockedTargetPosition(): Nullable<Vector3>;
  70954. private _storedPosition;
  70955. private _storedRotation;
  70956. private _storedRotationQuaternion;
  70957. /**
  70958. * Store current camera state of the camera (fov, position, rotation, etc..)
  70959. * @returns the camera
  70960. */
  70961. storeState(): Camera;
  70962. /**
  70963. * Restored camera state. You must call storeState() first
  70964. * @returns whether it was successful or not
  70965. * @hidden
  70966. */
  70967. _restoreStateValues(): boolean;
  70968. /** @hidden */
  70969. _initCache(): void;
  70970. /** @hidden */
  70971. _updateCache(ignoreParentClass?: boolean): void;
  70972. /** @hidden */
  70973. _isSynchronizedViewMatrix(): boolean;
  70974. /** @hidden */
  70975. _computeLocalCameraSpeed(): number;
  70976. /**
  70977. * Defines the target the camera should look at.
  70978. * @param target Defines the new target as a Vector or a mesh
  70979. */
  70980. setTarget(target: Vector3): void;
  70981. /**
  70982. * Return the current target position of the camera. This value is expressed in local space.
  70983. * @returns the target position
  70984. */
  70985. getTarget(): Vector3;
  70986. /** @hidden */
  70987. _decideIfNeedsToMove(): boolean;
  70988. /** @hidden */
  70989. _updatePosition(): void;
  70990. /** @hidden */
  70991. _checkInputs(): void;
  70992. protected _updateCameraRotationMatrix(): void;
  70993. /**
  70994. * 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)
  70995. * @returns the current camera
  70996. */
  70997. private _rotateUpVectorWithCameraRotationMatrix;
  70998. private _cachedRotationZ;
  70999. private _cachedQuaternionRotationZ;
  71000. /** @hidden */
  71001. _getViewMatrix(): Matrix;
  71002. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  71003. /**
  71004. * @hidden
  71005. */
  71006. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  71007. /**
  71008. * @hidden
  71009. */
  71010. _updateRigCameras(): void;
  71011. private _getRigCamPositionAndTarget;
  71012. /**
  71013. * Gets the current object class name.
  71014. * @return the class name
  71015. */
  71016. getClassName(): string;
  71017. }
  71018. }
  71019. declare module BABYLON {
  71020. /**
  71021. * @ignore
  71022. * This is a list of all the different input types that are available in the application.
  71023. * Fo instance: ArcRotateCameraGamepadInput...
  71024. */
  71025. export var CameraInputTypes: {};
  71026. /**
  71027. * This is the contract to implement in order to create a new input class.
  71028. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  71029. */
  71030. export interface ICameraInput<TCamera extends Camera> {
  71031. /**
  71032. * Defines the camera the input is attached to.
  71033. */
  71034. camera: Nullable<TCamera>;
  71035. /**
  71036. * Gets the class name of the current intput.
  71037. * @returns the class name
  71038. */
  71039. getClassName(): string;
  71040. /**
  71041. * Get the friendly name associated with the input class.
  71042. * @returns the input friendly name
  71043. */
  71044. getSimpleName(): string;
  71045. /**
  71046. * Attach the input controls to a specific dom element to get the input from.
  71047. * @param element Defines the element the controls should be listened from
  71048. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71049. */
  71050. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71051. /**
  71052. * Detach the current controls from the specified dom element.
  71053. * @param element Defines the element to stop listening the inputs from
  71054. */
  71055. detachControl(element: Nullable<HTMLElement>): void;
  71056. /**
  71057. * Update the current camera state depending on the inputs that have been used this frame.
  71058. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71059. */
  71060. checkInputs?: () => void;
  71061. }
  71062. /**
  71063. * Represents a map of input types to input instance or input index to input instance.
  71064. */
  71065. export interface CameraInputsMap<TCamera extends Camera> {
  71066. /**
  71067. * Accessor to the input by input type.
  71068. */
  71069. [name: string]: ICameraInput<TCamera>;
  71070. /**
  71071. * Accessor to the input by input index.
  71072. */
  71073. [idx: number]: ICameraInput<TCamera>;
  71074. }
  71075. /**
  71076. * This represents the input manager used within a camera.
  71077. * It helps dealing with all the different kind of input attached to a camera.
  71078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71079. */
  71080. export class CameraInputsManager<TCamera extends Camera> {
  71081. /**
  71082. * Defines the list of inputs attahed to the camera.
  71083. */
  71084. attached: CameraInputsMap<TCamera>;
  71085. /**
  71086. * Defines the dom element the camera is collecting inputs from.
  71087. * This is null if the controls have not been attached.
  71088. */
  71089. attachedElement: Nullable<HTMLElement>;
  71090. /**
  71091. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71092. */
  71093. noPreventDefault: boolean;
  71094. /**
  71095. * Defined the camera the input manager belongs to.
  71096. */
  71097. camera: TCamera;
  71098. /**
  71099. * Update the current camera state depending on the inputs that have been used this frame.
  71100. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71101. */
  71102. checkInputs: () => void;
  71103. /**
  71104. * Instantiate a new Camera Input Manager.
  71105. * @param camera Defines the camera the input manager blongs to
  71106. */
  71107. constructor(camera: TCamera);
  71108. /**
  71109. * Add an input method to a camera
  71110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71111. * @param input camera input method
  71112. */
  71113. add(input: ICameraInput<TCamera>): void;
  71114. /**
  71115. * Remove a specific input method from a camera
  71116. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71117. * @param inputToRemove camera input method
  71118. */
  71119. remove(inputToRemove: ICameraInput<TCamera>): void;
  71120. /**
  71121. * Remove a specific input type from a camera
  71122. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71123. * @param inputType the type of the input to remove
  71124. */
  71125. removeByType(inputType: string): void;
  71126. private _addCheckInputs;
  71127. /**
  71128. * Attach the input controls to the currently attached dom element to listen the events from.
  71129. * @param input Defines the input to attach
  71130. */
  71131. attachInput(input: ICameraInput<TCamera>): void;
  71132. /**
  71133. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71134. * @param element Defines the dom element to collect the events from
  71135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71136. */
  71137. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71138. /**
  71139. * Detach the current manager inputs controls from a specific dom element.
  71140. * @param element Defines the dom element to collect the events from
  71141. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71142. */
  71143. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71144. /**
  71145. * Rebuild the dynamic inputCheck function from the current list of
  71146. * defined inputs in the manager.
  71147. */
  71148. rebuildInputCheck(): void;
  71149. /**
  71150. * Remove all attached input methods from a camera
  71151. */
  71152. clear(): void;
  71153. /**
  71154. * Serialize the current input manager attached to a camera.
  71155. * This ensures than once parsed,
  71156. * the input associated to the camera will be identical to the current ones
  71157. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71158. */
  71159. serialize(serializedCamera: any): void;
  71160. /**
  71161. * Parses an input manager serialized JSON to restore the previous list of inputs
  71162. * and states associated to a camera.
  71163. * @param parsedCamera Defines the JSON to parse
  71164. */
  71165. parse(parsedCamera: any): void;
  71166. }
  71167. }
  71168. declare module BABYLON {
  71169. /**
  71170. * Gather the list of keyboard event types as constants.
  71171. */
  71172. export class KeyboardEventTypes {
  71173. /**
  71174. * The keydown event is fired when a key becomes active (pressed).
  71175. */
  71176. static readonly KEYDOWN: number;
  71177. /**
  71178. * The keyup event is fired when a key has been released.
  71179. */
  71180. static readonly KEYUP: number;
  71181. }
  71182. /**
  71183. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71184. */
  71185. export class KeyboardInfo {
  71186. /**
  71187. * Defines the type of event (KeyboardEventTypes)
  71188. */
  71189. type: number;
  71190. /**
  71191. * Defines the related dom event
  71192. */
  71193. event: KeyboardEvent;
  71194. /**
  71195. * Instantiates a new keyboard info.
  71196. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71197. * @param type Defines the type of event (KeyboardEventTypes)
  71198. * @param event Defines the related dom event
  71199. */
  71200. constructor(
  71201. /**
  71202. * Defines the type of event (KeyboardEventTypes)
  71203. */
  71204. type: number,
  71205. /**
  71206. * Defines the related dom event
  71207. */
  71208. event: KeyboardEvent);
  71209. }
  71210. /**
  71211. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71212. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  71213. */
  71214. export class KeyboardInfoPre extends KeyboardInfo {
  71215. /**
  71216. * Defines the type of event (KeyboardEventTypes)
  71217. */
  71218. type: number;
  71219. /**
  71220. * Defines the related dom event
  71221. */
  71222. event: KeyboardEvent;
  71223. /**
  71224. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  71225. */
  71226. skipOnPointerObservable: boolean;
  71227. /**
  71228. * Instantiates a new keyboard pre info.
  71229. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71230. * @param type Defines the type of event (KeyboardEventTypes)
  71231. * @param event Defines the related dom event
  71232. */
  71233. constructor(
  71234. /**
  71235. * Defines the type of event (KeyboardEventTypes)
  71236. */
  71237. type: number,
  71238. /**
  71239. * Defines the related dom event
  71240. */
  71241. event: KeyboardEvent);
  71242. }
  71243. }
  71244. declare module BABYLON {
  71245. /**
  71246. * Manage the keyboard inputs to control the movement of a free camera.
  71247. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71248. */
  71249. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  71250. /**
  71251. * Defines the camera the input is attached to.
  71252. */
  71253. camera: FreeCamera;
  71254. /**
  71255. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71256. */
  71257. keysUp: number[];
  71258. /**
  71259. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71260. */
  71261. keysDown: number[];
  71262. /**
  71263. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71264. */
  71265. keysLeft: number[];
  71266. /**
  71267. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71268. */
  71269. keysRight: number[];
  71270. private _keys;
  71271. private _onCanvasBlurObserver;
  71272. private _onKeyboardObserver;
  71273. private _engine;
  71274. private _scene;
  71275. /**
  71276. * Attach the input controls to a specific dom element to get the input from.
  71277. * @param element Defines the element the controls should be listened from
  71278. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71279. */
  71280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71281. /**
  71282. * Detach the current controls from the specified dom element.
  71283. * @param element Defines the element to stop listening the inputs from
  71284. */
  71285. detachControl(element: Nullable<HTMLElement>): void;
  71286. /**
  71287. * Update the current camera state depending on the inputs that have been used this frame.
  71288. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71289. */
  71290. checkInputs(): void;
  71291. /**
  71292. * Gets the class name of the current intput.
  71293. * @returns the class name
  71294. */
  71295. getClassName(): string;
  71296. /** @hidden */
  71297. _onLostFocus(): void;
  71298. /**
  71299. * Get the friendly name associated with the input class.
  71300. * @returns the input friendly name
  71301. */
  71302. getSimpleName(): string;
  71303. }
  71304. }
  71305. declare module BABYLON {
  71306. /**
  71307. * A multi-material is used to apply different materials to different parts of the same object without the need of
  71308. * separate meshes. This can be use to improve performances.
  71309. * @see http://doc.babylonjs.com/how_to/multi_materials
  71310. */
  71311. export class MultiMaterial extends Material {
  71312. private _subMaterials;
  71313. /**
  71314. * Gets or Sets the list of Materials used within the multi material.
  71315. * They need to be ordered according to the submeshes order in the associated mesh
  71316. */
  71317. subMaterials: Nullable<Material>[];
  71318. /**
  71319. * Function used to align with Node.getChildren()
  71320. * @returns the list of Materials used within the multi material
  71321. */
  71322. getChildren(): Nullable<Material>[];
  71323. /**
  71324. * Instantiates a new Multi Material
  71325. * A multi-material is used to apply different materials to different parts of the same object without the need of
  71326. * separate meshes. This can be use to improve performances.
  71327. * @see http://doc.babylonjs.com/how_to/multi_materials
  71328. * @param name Define the name in the scene
  71329. * @param scene Define the scene the material belongs to
  71330. */
  71331. constructor(name: string, scene: Scene);
  71332. private _hookArray;
  71333. /**
  71334. * Get one of the submaterial by its index in the submaterials array
  71335. * @param index The index to look the sub material at
  71336. * @returns The Material if the index has been defined
  71337. */
  71338. getSubMaterial(index: number): Nullable<Material>;
  71339. /**
  71340. * Get the list of active textures for the whole sub materials list.
  71341. * @returns All the textures that will be used during the rendering
  71342. */
  71343. getActiveTextures(): BaseTexture[];
  71344. /**
  71345. * Gets the current class name of the material e.g. "MultiMaterial"
  71346. * Mainly use in serialization.
  71347. * @returns the class name
  71348. */
  71349. getClassName(): string;
  71350. /**
  71351. * Checks if the material is ready to render the requested sub mesh
  71352. * @param mesh Define the mesh the submesh belongs to
  71353. * @param subMesh Define the sub mesh to look readyness for
  71354. * @param useInstances Define whether or not the material is used with instances
  71355. * @returns true if ready, otherwise false
  71356. */
  71357. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  71358. /**
  71359. * Clones the current material and its related sub materials
  71360. * @param name Define the name of the newly cloned material
  71361. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  71362. * @returns the cloned material
  71363. */
  71364. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  71365. /**
  71366. * Serializes the materials into a JSON representation.
  71367. * @returns the JSON representation
  71368. */
  71369. serialize(): any;
  71370. /**
  71371. * Dispose the material and release its associated resources
  71372. * @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)
  71373. * @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)
  71374. * @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)
  71375. */
  71376. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  71377. /**
  71378. * Creates a MultiMaterial from parsed MultiMaterial data.
  71379. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  71380. * @param scene defines the hosting scene
  71381. * @returns a new MultiMaterial
  71382. */
  71383. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  71384. }
  71385. }
  71386. declare module BABYLON {
  71387. /**
  71388. * Class used to represent data loading progression
  71389. */
  71390. export class SceneLoaderFlags {
  71391. private static _ForceFullSceneLoadingForIncremental;
  71392. private static _ShowLoadingScreen;
  71393. private static _CleanBoneMatrixWeights;
  71394. private static _loggingLevel;
  71395. /**
  71396. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  71397. */
  71398. static ForceFullSceneLoadingForIncremental: boolean;
  71399. /**
  71400. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  71401. */
  71402. static ShowLoadingScreen: boolean;
  71403. /**
  71404. * Defines the current logging level (while loading the scene)
  71405. * @ignorenaming
  71406. */
  71407. static loggingLevel: number;
  71408. /**
  71409. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  71410. */
  71411. static CleanBoneMatrixWeights: boolean;
  71412. }
  71413. }
  71414. declare module BABYLON {
  71415. /**
  71416. * 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.
  71417. * @see https://doc.babylonjs.com/how_to/transformnode
  71418. */
  71419. export class TransformNode extends Node {
  71420. /**
  71421. * Object will not rotate to face the camera
  71422. */
  71423. static BILLBOARDMODE_NONE: number;
  71424. /**
  71425. * Object will rotate to face the camera but only on the x axis
  71426. */
  71427. static BILLBOARDMODE_X: number;
  71428. /**
  71429. * Object will rotate to face the camera but only on the y axis
  71430. */
  71431. static BILLBOARDMODE_Y: number;
  71432. /**
  71433. * Object will rotate to face the camera but only on the z axis
  71434. */
  71435. static BILLBOARDMODE_Z: number;
  71436. /**
  71437. * Object will rotate to face the camera
  71438. */
  71439. static BILLBOARDMODE_ALL: number;
  71440. private _forward;
  71441. private _forwardInverted;
  71442. private _up;
  71443. private _right;
  71444. private _rightInverted;
  71445. private _position;
  71446. private _rotation;
  71447. private _rotationQuaternion;
  71448. protected _scaling: Vector3;
  71449. protected _isDirty: boolean;
  71450. private _transformToBoneReferal;
  71451. private _billboardMode;
  71452. /**
  71453. * Gets or sets the billboard mode. Default is 0.
  71454. *
  71455. * | Value | Type | Description |
  71456. * | --- | --- | --- |
  71457. * | 0 | BILLBOARDMODE_NONE | |
  71458. * | 1 | BILLBOARDMODE_X | |
  71459. * | 2 | BILLBOARDMODE_Y | |
  71460. * | 4 | BILLBOARDMODE_Z | |
  71461. * | 7 | BILLBOARDMODE_ALL | |
  71462. *
  71463. */
  71464. billboardMode: number;
  71465. private _preserveParentRotationForBillboard;
  71466. /**
  71467. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  71468. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  71469. */
  71470. preserveParentRotationForBillboard: boolean;
  71471. /**
  71472. * 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
  71473. */
  71474. scalingDeterminant: number;
  71475. private _infiniteDistance;
  71476. /**
  71477. * Gets or sets the distance of the object to max, often used by skybox
  71478. */
  71479. infiniteDistance: boolean;
  71480. /**
  71481. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  71482. * By default the system will update normals to compensate
  71483. */
  71484. ignoreNonUniformScaling: boolean;
  71485. /**
  71486. * 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
  71487. */
  71488. reIntegrateRotationIntoRotationQuaternion: boolean;
  71489. /** @hidden */
  71490. _poseMatrix: Nullable<Matrix>;
  71491. /** @hidden */
  71492. _localMatrix: Matrix;
  71493. private _usePivotMatrix;
  71494. private _absolutePosition;
  71495. private _pivotMatrix;
  71496. private _pivotMatrixInverse;
  71497. protected _postMultiplyPivotMatrix: boolean;
  71498. protected _isWorldMatrixFrozen: boolean;
  71499. /** @hidden */
  71500. _indexInSceneTransformNodesArray: number;
  71501. /**
  71502. * An event triggered after the world matrix is updated
  71503. */
  71504. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  71505. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  71506. /**
  71507. * Gets a string identifying the name of the class
  71508. * @returns "TransformNode" string
  71509. */
  71510. getClassName(): string;
  71511. /**
  71512. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  71513. */
  71514. position: Vector3;
  71515. /**
  71516. * 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)).
  71517. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  71518. */
  71519. rotation: Vector3;
  71520. /**
  71521. * 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)).
  71522. */
  71523. scaling: Vector3;
  71524. /**
  71525. * 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).
  71526. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  71527. */
  71528. rotationQuaternion: Nullable<Quaternion>;
  71529. /**
  71530. * The forward direction of that transform in world space.
  71531. */
  71532. readonly forward: Vector3;
  71533. /**
  71534. * The up direction of that transform in world space.
  71535. */
  71536. readonly up: Vector3;
  71537. /**
  71538. * The right direction of that transform in world space.
  71539. */
  71540. readonly right: Vector3;
  71541. /**
  71542. * Copies the parameter passed Matrix into the mesh Pose matrix.
  71543. * @param matrix the matrix to copy the pose from
  71544. * @returns this TransformNode.
  71545. */
  71546. updatePoseMatrix(matrix: Matrix): TransformNode;
  71547. /**
  71548. * Returns the mesh Pose matrix.
  71549. * @returns the pose matrix
  71550. */
  71551. getPoseMatrix(): Matrix;
  71552. /** @hidden */
  71553. _isSynchronized(): boolean;
  71554. /** @hidden */
  71555. _initCache(): void;
  71556. /**
  71557. * Flag the transform node as dirty (Forcing it to update everything)
  71558. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  71559. * @returns this transform node
  71560. */
  71561. markAsDirty(property: string): TransformNode;
  71562. /**
  71563. * Returns the current mesh absolute position.
  71564. * Returns a Vector3.
  71565. */
  71566. readonly absolutePosition: Vector3;
  71567. /**
  71568. * Sets a new matrix to apply before all other transformation
  71569. * @param matrix defines the transform matrix
  71570. * @returns the current TransformNode
  71571. */
  71572. setPreTransformMatrix(matrix: Matrix): TransformNode;
  71573. /**
  71574. * Sets a new pivot matrix to the current node
  71575. * @param matrix defines the new pivot matrix to use
  71576. * @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
  71577. * @returns the current TransformNode
  71578. */
  71579. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  71580. /**
  71581. * Returns the mesh pivot matrix.
  71582. * Default : Identity.
  71583. * @returns the matrix
  71584. */
  71585. getPivotMatrix(): Matrix;
  71586. /**
  71587. * Prevents the World matrix to be computed any longer.
  71588. * @returns the TransformNode.
  71589. */
  71590. freezeWorldMatrix(): TransformNode;
  71591. /**
  71592. * Allows back the World matrix computation.
  71593. * @returns the TransformNode.
  71594. */
  71595. unfreezeWorldMatrix(): this;
  71596. /**
  71597. * True if the World matrix has been frozen.
  71598. */
  71599. readonly isWorldMatrixFrozen: boolean;
  71600. /**
  71601. * Retuns the mesh absolute position in the World.
  71602. * @returns a Vector3.
  71603. */
  71604. getAbsolutePosition(): Vector3;
  71605. /**
  71606. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  71607. * @param absolutePosition the absolute position to set
  71608. * @returns the TransformNode.
  71609. */
  71610. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  71611. /**
  71612. * Sets the mesh position in its local space.
  71613. * @param vector3 the position to set in localspace
  71614. * @returns the TransformNode.
  71615. */
  71616. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  71617. /**
  71618. * Returns the mesh position in the local space from the current World matrix values.
  71619. * @returns a new Vector3.
  71620. */
  71621. getPositionExpressedInLocalSpace(): Vector3;
  71622. /**
  71623. * Translates the mesh along the passed Vector3 in its local space.
  71624. * @param vector3 the distance to translate in localspace
  71625. * @returns the TransformNode.
  71626. */
  71627. locallyTranslate(vector3: Vector3): TransformNode;
  71628. private static _lookAtVectorCache;
  71629. /**
  71630. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  71631. * @param targetPoint the position (must be in same space as current mesh) to look at
  71632. * @param yawCor optional yaw (y-axis) correction in radians
  71633. * @param pitchCor optional pitch (x-axis) correction in radians
  71634. * @param rollCor optional roll (z-axis) correction in radians
  71635. * @param space the choosen space of the target
  71636. * @returns the TransformNode.
  71637. */
  71638. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  71639. /**
  71640. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71641. * This Vector3 is expressed in the World space.
  71642. * @param localAxis axis to rotate
  71643. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71644. */
  71645. getDirection(localAxis: Vector3): Vector3;
  71646. /**
  71647. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  71648. * localAxis is expressed in the mesh local space.
  71649. * result is computed in the Wordl space from the mesh World matrix.
  71650. * @param localAxis axis to rotate
  71651. * @param result the resulting transformnode
  71652. * @returns this TransformNode.
  71653. */
  71654. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  71655. /**
  71656. * Sets this transform node rotation to the given local axis.
  71657. * @param localAxis the axis in local space
  71658. * @param yawCor optional yaw (y-axis) correction in radians
  71659. * @param pitchCor optional pitch (x-axis) correction in radians
  71660. * @param rollCor optional roll (z-axis) correction in radians
  71661. * @returns this TransformNode
  71662. */
  71663. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  71664. /**
  71665. * Sets a new pivot point to the current node
  71666. * @param point defines the new pivot point to use
  71667. * @param space defines if the point is in world or local space (local by default)
  71668. * @returns the current TransformNode
  71669. */
  71670. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  71671. /**
  71672. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  71673. * @returns the pivot point
  71674. */
  71675. getPivotPoint(): Vector3;
  71676. /**
  71677. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  71678. * @param result the vector3 to store the result
  71679. * @returns this TransformNode.
  71680. */
  71681. getPivotPointToRef(result: Vector3): TransformNode;
  71682. /**
  71683. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  71684. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  71685. */
  71686. getAbsolutePivotPoint(): Vector3;
  71687. /**
  71688. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  71689. * @param result vector3 to store the result
  71690. * @returns this TransformNode.
  71691. */
  71692. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  71693. /**
  71694. * Defines the passed node as the parent of the current node.
  71695. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  71696. * @see https://doc.babylonjs.com/how_to/parenting
  71697. * @param node the node ot set as the parent
  71698. * @returns this TransformNode.
  71699. */
  71700. setParent(node: Nullable<Node>): TransformNode;
  71701. private _nonUniformScaling;
  71702. /**
  71703. * True if the scaling property of this object is non uniform eg. (1,2,1)
  71704. */
  71705. readonly nonUniformScaling: boolean;
  71706. /** @hidden */
  71707. _updateNonUniformScalingState(value: boolean): boolean;
  71708. /**
  71709. * Attach the current TransformNode to another TransformNode associated with a bone
  71710. * @param bone Bone affecting the TransformNode
  71711. * @param affectedTransformNode TransformNode associated with the bone
  71712. * @returns this object
  71713. */
  71714. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  71715. /**
  71716. * Detach the transform node if its associated with a bone
  71717. * @returns this object
  71718. */
  71719. detachFromBone(): TransformNode;
  71720. private static _rotationAxisCache;
  71721. /**
  71722. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  71723. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71724. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71725. * The passed axis is also normalized.
  71726. * @param axis the axis to rotate around
  71727. * @param amount the amount to rotate in radians
  71728. * @param space Space to rotate in (Default: local)
  71729. * @returns the TransformNode.
  71730. */
  71731. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  71732. /**
  71733. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  71734. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71735. * The passed axis is also normalized. .
  71736. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  71737. * @param point the point to rotate around
  71738. * @param axis the axis to rotate around
  71739. * @param amount the amount to rotate in radians
  71740. * @returns the TransformNode
  71741. */
  71742. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  71743. /**
  71744. * Translates the mesh along the axis vector for the passed distance in the given space.
  71745. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71746. * @param axis the axis to translate in
  71747. * @param distance the distance to translate
  71748. * @param space Space to rotate in (Default: local)
  71749. * @returns the TransformNode.
  71750. */
  71751. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  71752. /**
  71753. * Adds a rotation step to the mesh current rotation.
  71754. * x, y, z are Euler angles expressed in radians.
  71755. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  71756. * This means this rotation is made in the mesh local space only.
  71757. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  71758. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  71759. * ```javascript
  71760. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  71761. * ```
  71762. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  71763. * 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.
  71764. * @param x Rotation to add
  71765. * @param y Rotation to add
  71766. * @param z Rotation to add
  71767. * @returns the TransformNode.
  71768. */
  71769. addRotation(x: number, y: number, z: number): TransformNode;
  71770. /**
  71771. * @hidden
  71772. */
  71773. protected _getEffectiveParent(): Nullable<Node>;
  71774. /**
  71775. * Computes the world matrix of the node
  71776. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71777. * @returns the world matrix
  71778. */
  71779. computeWorldMatrix(force?: boolean): Matrix;
  71780. protected _afterComputeWorldMatrix(): void;
  71781. /**
  71782. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  71783. * @param func callback function to add
  71784. *
  71785. * @returns the TransformNode.
  71786. */
  71787. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71788. /**
  71789. * Removes a registered callback function.
  71790. * @param func callback function to remove
  71791. * @returns the TransformNode.
  71792. */
  71793. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71794. /**
  71795. * Gets the position of the current mesh in camera space
  71796. * @param camera defines the camera to use
  71797. * @returns a position
  71798. */
  71799. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  71800. /**
  71801. * Returns the distance from the mesh to the active camera
  71802. * @param camera defines the camera to use
  71803. * @returns the distance
  71804. */
  71805. getDistanceToCamera(camera?: Nullable<Camera>): number;
  71806. /**
  71807. * Clone the current transform node
  71808. * @param name Name of the new clone
  71809. * @param newParent New parent for the clone
  71810. * @param doNotCloneChildren Do not clone children hierarchy
  71811. * @returns the new transform node
  71812. */
  71813. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  71814. /**
  71815. * Serializes the objects information.
  71816. * @param currentSerializationObject defines the object to serialize in
  71817. * @returns the serialized object
  71818. */
  71819. serialize(currentSerializationObject?: any): any;
  71820. /**
  71821. * Returns a new TransformNode object parsed from the source provided.
  71822. * @param parsedTransformNode is the source.
  71823. * @param scene the scne the object belongs to
  71824. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  71825. * @returns a new TransformNode object parsed from the source provided.
  71826. */
  71827. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  71828. /**
  71829. * Get all child-transformNodes of this node
  71830. * @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
  71831. * @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
  71832. * @returns an array of TransformNode
  71833. */
  71834. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  71835. /**
  71836. * Releases resources associated with this transform node.
  71837. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  71838. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  71839. */
  71840. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71841. /**
  71842. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  71843. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  71844. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  71845. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  71846. * @returns the current mesh
  71847. */
  71848. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  71849. }
  71850. }
  71851. declare module BABYLON {
  71852. /**
  71853. * Class used to override all child animations of a given target
  71854. */
  71855. export class AnimationPropertiesOverride {
  71856. /**
  71857. * Gets or sets a value indicating if animation blending must be used
  71858. */
  71859. enableBlending: boolean;
  71860. /**
  71861. * Gets or sets the blending speed to use when enableBlending is true
  71862. */
  71863. blendingSpeed: number;
  71864. /**
  71865. * Gets or sets the default loop mode to use
  71866. */
  71867. loopMode: number;
  71868. }
  71869. }
  71870. declare module BABYLON {
  71871. /**
  71872. * Class used to store bone information
  71873. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  71874. */
  71875. export class Bone extends Node {
  71876. /**
  71877. * defines the bone name
  71878. */
  71879. name: string;
  71880. private static _tmpVecs;
  71881. private static _tmpQuat;
  71882. private static _tmpMats;
  71883. /**
  71884. * Gets the list of child bones
  71885. */
  71886. children: Bone[];
  71887. /** Gets the animations associated with this bone */
  71888. animations: Animation[];
  71889. /**
  71890. * Gets or sets bone length
  71891. */
  71892. length: number;
  71893. /**
  71894. * @hidden Internal only
  71895. * Set this value to map this bone to a different index in the transform matrices
  71896. * Set this value to -1 to exclude the bone from the transform matrices
  71897. */
  71898. _index: Nullable<number>;
  71899. private _skeleton;
  71900. private _localMatrix;
  71901. private _restPose;
  71902. private _baseMatrix;
  71903. private _absoluteTransform;
  71904. private _invertedAbsoluteTransform;
  71905. private _parent;
  71906. private _scalingDeterminant;
  71907. private _worldTransform;
  71908. private _localScaling;
  71909. private _localRotation;
  71910. private _localPosition;
  71911. private _needToDecompose;
  71912. private _needToCompose;
  71913. /** @hidden */
  71914. _linkedTransformNode: Nullable<TransformNode>;
  71915. /** @hidden */
  71916. _waitingTransformNodeId: Nullable<string>;
  71917. /** @hidden */
  71918. /** @hidden */
  71919. _matrix: Matrix;
  71920. /**
  71921. * Create a new bone
  71922. * @param name defines the bone name
  71923. * @param skeleton defines the parent skeleton
  71924. * @param parentBone defines the parent (can be null if the bone is the root)
  71925. * @param localMatrix defines the local matrix
  71926. * @param restPose defines the rest pose matrix
  71927. * @param baseMatrix defines the base matrix
  71928. * @param index defines index of the bone in the hiearchy
  71929. */
  71930. constructor(
  71931. /**
  71932. * defines the bone name
  71933. */
  71934. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  71935. /**
  71936. * Gets the current object class name.
  71937. * @return the class name
  71938. */
  71939. getClassName(): string;
  71940. /**
  71941. * Gets the parent skeleton
  71942. * @returns a skeleton
  71943. */
  71944. getSkeleton(): Skeleton;
  71945. /**
  71946. * Gets parent bone
  71947. * @returns a bone or null if the bone is the root of the bone hierarchy
  71948. */
  71949. getParent(): Nullable<Bone>;
  71950. /**
  71951. * Returns an array containing the root bones
  71952. * @returns an array containing the root bones
  71953. */
  71954. getChildren(): Array<Bone>;
  71955. /**
  71956. * Sets the parent bone
  71957. * @param parent defines the parent (can be null if the bone is the root)
  71958. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71959. */
  71960. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  71961. /**
  71962. * Gets the local matrix
  71963. * @returns a matrix
  71964. */
  71965. getLocalMatrix(): Matrix;
  71966. /**
  71967. * Gets the base matrix (initial matrix which remains unchanged)
  71968. * @returns a matrix
  71969. */
  71970. getBaseMatrix(): Matrix;
  71971. /**
  71972. * Gets the rest pose matrix
  71973. * @returns a matrix
  71974. */
  71975. getRestPose(): Matrix;
  71976. /**
  71977. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  71978. */
  71979. getWorldMatrix(): Matrix;
  71980. /**
  71981. * Sets the local matrix to rest pose matrix
  71982. */
  71983. returnToRest(): void;
  71984. /**
  71985. * Gets the inverse of the absolute transform matrix.
  71986. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  71987. * @returns a matrix
  71988. */
  71989. getInvertedAbsoluteTransform(): Matrix;
  71990. /**
  71991. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  71992. * @returns a matrix
  71993. */
  71994. getAbsoluteTransform(): Matrix;
  71995. /**
  71996. * Links with the given transform node.
  71997. * The local matrix of this bone is copied from the transform node every frame.
  71998. * @param transformNode defines the transform node to link to
  71999. */
  72000. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  72001. /** Gets or sets current position (in local space) */
  72002. position: Vector3;
  72003. /** Gets or sets current rotation (in local space) */
  72004. rotation: Vector3;
  72005. /** Gets or sets current rotation quaternion (in local space) */
  72006. rotationQuaternion: Quaternion;
  72007. /** Gets or sets current scaling (in local space) */
  72008. scaling: Vector3;
  72009. /**
  72010. * Gets the animation properties override
  72011. */
  72012. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72013. private _decompose;
  72014. private _compose;
  72015. /**
  72016. * Update the base and local matrices
  72017. * @param matrix defines the new base or local matrix
  72018. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  72019. * @param updateLocalMatrix defines if the local matrix should be updated
  72020. */
  72021. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  72022. /** @hidden */
  72023. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  72024. /**
  72025. * Flag the bone as dirty (Forcing it to update everything)
  72026. */
  72027. markAsDirty(): void;
  72028. /** @hidden */
  72029. _markAsDirtyAndCompose(): void;
  72030. private _markAsDirtyAndDecompose;
  72031. /**
  72032. * Translate the bone in local or world space
  72033. * @param vec The amount to translate the bone
  72034. * @param space The space that the translation is in
  72035. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72036. */
  72037. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  72038. /**
  72039. * Set the postion of the bone in local or world space
  72040. * @param position The position to set the bone
  72041. * @param space The space that the position is in
  72042. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72043. */
  72044. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  72045. /**
  72046. * Set the absolute position of the bone (world space)
  72047. * @param position The position to set the bone
  72048. * @param mesh The mesh that this bone is attached to
  72049. */
  72050. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  72051. /**
  72052. * Scale the bone on the x, y and z axes (in local space)
  72053. * @param x The amount to scale the bone on the x axis
  72054. * @param y The amount to scale the bone on the y axis
  72055. * @param z The amount to scale the bone on the z axis
  72056. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  72057. */
  72058. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  72059. /**
  72060. * Set the bone scaling in local space
  72061. * @param scale defines the scaling vector
  72062. */
  72063. setScale(scale: Vector3): void;
  72064. /**
  72065. * Gets the current scaling in local space
  72066. * @returns the current scaling vector
  72067. */
  72068. getScale(): Vector3;
  72069. /**
  72070. * Gets the current scaling in local space and stores it in a target vector
  72071. * @param result defines the target vector
  72072. */
  72073. getScaleToRef(result: Vector3): void;
  72074. /**
  72075. * Set the yaw, pitch, and roll of the bone in local or world space
  72076. * @param yaw The rotation of the bone on the y axis
  72077. * @param pitch The rotation of the bone on the x axis
  72078. * @param roll The rotation of the bone on the z axis
  72079. * @param space The space that the axes of rotation are in
  72080. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72081. */
  72082. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  72083. /**
  72084. * Add a rotation to the bone on an axis in local or world space
  72085. * @param axis The axis to rotate the bone on
  72086. * @param amount The amount to rotate the bone
  72087. * @param space The space that the axis is in
  72088. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72089. */
  72090. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  72091. /**
  72092. * Set the rotation of the bone to a particular axis angle in local or world space
  72093. * @param axis The axis to rotate the bone on
  72094. * @param angle The angle that the bone should be rotated to
  72095. * @param space The space that the axis is in
  72096. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72097. */
  72098. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  72099. /**
  72100. * Set the euler rotation of the bone in local of world space
  72101. * @param rotation The euler rotation that the bone should be set to
  72102. * @param space The space that the rotation is in
  72103. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72104. */
  72105. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  72106. /**
  72107. * Set the quaternion rotation of the bone in local of world space
  72108. * @param quat The quaternion rotation that the bone should be set to
  72109. * @param space The space that the rotation is in
  72110. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72111. */
  72112. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  72113. /**
  72114. * Set the rotation matrix of the bone in local of world space
  72115. * @param rotMat The rotation matrix that the bone should be set to
  72116. * @param space The space that the rotation is in
  72117. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72118. */
  72119. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  72120. private _rotateWithMatrix;
  72121. private _getNegativeRotationToRef;
  72122. /**
  72123. * Get the position of the bone in local or world space
  72124. * @param space The space that the returned position is in
  72125. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72126. * @returns The position of the bone
  72127. */
  72128. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  72129. /**
  72130. * Copy the position of the bone to a vector3 in local or world space
  72131. * @param space The space that the returned position is in
  72132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72133. * @param result The vector3 to copy the position to
  72134. */
  72135. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  72136. /**
  72137. * Get the absolute position of the bone (world space)
  72138. * @param mesh The mesh that this bone is attached to
  72139. * @returns The absolute position of the bone
  72140. */
  72141. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  72142. /**
  72143. * Copy the absolute position of the bone (world space) to the result param
  72144. * @param mesh The mesh that this bone is attached to
  72145. * @param result The vector3 to copy the absolute position to
  72146. */
  72147. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  72148. /**
  72149. * Compute the absolute transforms of this bone and its children
  72150. */
  72151. computeAbsoluteTransforms(): void;
  72152. /**
  72153. * Get the world direction from an axis that is in the local space of the bone
  72154. * @param localAxis The local direction that is used to compute the world direction
  72155. * @param mesh The mesh that this bone is attached to
  72156. * @returns The world direction
  72157. */
  72158. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72159. /**
  72160. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  72161. * @param localAxis The local direction that is used to compute the world direction
  72162. * @param mesh The mesh that this bone is attached to
  72163. * @param result The vector3 that the world direction will be copied to
  72164. */
  72165. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72166. /**
  72167. * Get the euler rotation of the bone in local or world space
  72168. * @param space The space that the rotation should be in
  72169. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72170. * @returns The euler rotation
  72171. */
  72172. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  72173. /**
  72174. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  72175. * @param space The space that the rotation should be in
  72176. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72177. * @param result The vector3 that the rotation should be copied to
  72178. */
  72179. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72180. /**
  72181. * Get the quaternion rotation of the bone in either local or world space
  72182. * @param space The space that the rotation should be in
  72183. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72184. * @returns The quaternion rotation
  72185. */
  72186. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  72187. /**
  72188. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  72189. * @param space The space that the rotation should be in
  72190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72191. * @param result The quaternion that the rotation should be copied to
  72192. */
  72193. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  72194. /**
  72195. * Get the rotation matrix of the bone in local or world space
  72196. * @param space The space that the rotation should be in
  72197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72198. * @returns The rotation matrix
  72199. */
  72200. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  72201. /**
  72202. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  72203. * @param space The space that the rotation should be in
  72204. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72205. * @param result The quaternion that the rotation should be copied to
  72206. */
  72207. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  72208. /**
  72209. * Get the world position of a point that is in the local space of the bone
  72210. * @param position The local position
  72211. * @param mesh The mesh that this bone is attached to
  72212. * @returns The world position
  72213. */
  72214. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72215. /**
  72216. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  72217. * @param position The local position
  72218. * @param mesh The mesh that this bone is attached to
  72219. * @param result The vector3 that the world position should be copied to
  72220. */
  72221. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72222. /**
  72223. * Get the local position of a point that is in world space
  72224. * @param position The world position
  72225. * @param mesh The mesh that this bone is attached to
  72226. * @returns The local position
  72227. */
  72228. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72229. /**
  72230. * Get the local position of a point that is in world space and copy it to the result param
  72231. * @param position The world position
  72232. * @param mesh The mesh that this bone is attached to
  72233. * @param result The vector3 that the local position should be copied to
  72234. */
  72235. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72236. }
  72237. }
  72238. declare module BABYLON {
  72239. interface Engine {
  72240. /**
  72241. * Creates a raw texture
  72242. * @param data defines the data to store in the texture
  72243. * @param width defines the width of the texture
  72244. * @param height defines the height of the texture
  72245. * @param format defines the format of the data
  72246. * @param generateMipMaps defines if the engine should generate the mip levels
  72247. * @param invertY defines if data must be stored with Y axis inverted
  72248. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  72249. * @param compression defines the compression used (null by default)
  72250. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72251. * @returns the raw texture inside an InternalTexture
  72252. */
  72253. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  72254. /**
  72255. * Update a raw texture
  72256. * @param texture defines the texture to update
  72257. * @param data defines the data to store in the texture
  72258. * @param format defines the format of the data
  72259. * @param invertY defines if data must be stored with Y axis inverted
  72260. */
  72261. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  72262. /**
  72263. * Update a raw texture
  72264. * @param texture defines the texture to update
  72265. * @param data defines the data to store in the texture
  72266. * @param format defines the format of the data
  72267. * @param invertY defines if data must be stored with Y axis inverted
  72268. * @param compression defines the compression used (null by default)
  72269. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72270. */
  72271. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  72272. /**
  72273. * Creates a new raw cube texture
  72274. * @param data defines the array of data to use to create each face
  72275. * @param size defines the size of the textures
  72276. * @param format defines the format of the data
  72277. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72278. * @param generateMipMaps defines if the engine should generate the mip levels
  72279. * @param invertY defines if data must be stored with Y axis inverted
  72280. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72281. * @param compression defines the compression used (null by default)
  72282. * @returns the cube texture as an InternalTexture
  72283. */
  72284. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  72285. /**
  72286. * Update a raw cube texture
  72287. * @param texture defines the texture to udpdate
  72288. * @param data defines the data to store
  72289. * @param format defines the data format
  72290. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72291. * @param invertY defines if data must be stored with Y axis inverted
  72292. */
  72293. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  72294. /**
  72295. * Update a raw cube texture
  72296. * @param texture defines the texture to udpdate
  72297. * @param data defines the data to store
  72298. * @param format defines the data format
  72299. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72300. * @param invertY defines if data must be stored with Y axis inverted
  72301. * @param compression defines the compression used (null by default)
  72302. */
  72303. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  72304. /**
  72305. * Update a raw cube texture
  72306. * @param texture defines the texture to udpdate
  72307. * @param data defines the data to store
  72308. * @param format defines the data format
  72309. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72310. * @param invertY defines if data must be stored with Y axis inverted
  72311. * @param compression defines the compression used (null by default)
  72312. * @param level defines which level of the texture to update
  72313. */
  72314. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  72315. /**
  72316. * Creates a new raw cube texture from a specified url
  72317. * @param url defines the url where the data is located
  72318. * @param scene defines the current scene
  72319. * @param size defines the size of the textures
  72320. * @param format defines the format of the data
  72321. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72322. * @param noMipmap defines if the engine should avoid generating the mip levels
  72323. * @param callback defines a callback used to extract texture data from loaded data
  72324. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  72325. * @param onLoad defines a callback called when texture is loaded
  72326. * @param onError defines a callback called if there is an error
  72327. * @returns the cube texture as an InternalTexture
  72328. */
  72329. 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;
  72330. /**
  72331. * Creates a new raw cube texture from a specified url
  72332. * @param url defines the url where the data is located
  72333. * @param scene defines the current scene
  72334. * @param size defines the size of the textures
  72335. * @param format defines the format of the data
  72336. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72337. * @param noMipmap defines if the engine should avoid generating the mip levels
  72338. * @param callback defines a callback used to extract texture data from loaded data
  72339. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  72340. * @param onLoad defines a callback called when texture is loaded
  72341. * @param onError defines a callback called if there is an error
  72342. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72343. * @param invertY defines if data must be stored with Y axis inverted
  72344. * @returns the cube texture as an InternalTexture
  72345. */
  72346. 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;
  72347. /**
  72348. * Creates a new raw 3D texture
  72349. * @param data defines the data used to create the texture
  72350. * @param width defines the width of the texture
  72351. * @param height defines the height of the texture
  72352. * @param depth defines the depth of the texture
  72353. * @param format defines the format of the texture
  72354. * @param generateMipMaps defines if the engine must generate mip levels
  72355. * @param invertY defines if data must be stored with Y axis inverted
  72356. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72357. * @param compression defines the compressed used (can be null)
  72358. * @param textureType defines the compressed used (can be null)
  72359. * @returns a new raw 3D texture (stored in an InternalTexture)
  72360. */
  72361. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  72362. /**
  72363. * Update a raw 3D texture
  72364. * @param texture defines the texture to update
  72365. * @param data defines the data to store
  72366. * @param format defines the data format
  72367. * @param invertY defines if data must be stored with Y axis inverted
  72368. */
  72369. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  72370. /**
  72371. * Update a raw 3D texture
  72372. * @param texture defines the texture to update
  72373. * @param data defines the data to store
  72374. * @param format defines the data format
  72375. * @param invertY defines if data must be stored with Y axis inverted
  72376. * @param compression defines the used compression (can be null)
  72377. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  72378. */
  72379. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  72380. }
  72381. }
  72382. declare module BABYLON {
  72383. /**
  72384. * Raw texture can help creating a texture directly from an array of data.
  72385. * This can be super useful if you either get the data from an uncompressed source or
  72386. * if you wish to create your texture pixel by pixel.
  72387. */
  72388. export class RawTexture extends Texture {
  72389. /**
  72390. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72391. */
  72392. format: number;
  72393. private _engine;
  72394. /**
  72395. * Instantiates a new RawTexture.
  72396. * Raw texture can help creating a texture directly from an array of data.
  72397. * This can be super useful if you either get the data from an uncompressed source or
  72398. * if you wish to create your texture pixel by pixel.
  72399. * @param data define the array of data to use to create the texture
  72400. * @param width define the width of the texture
  72401. * @param height define the height of the texture
  72402. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72403. * @param scene define the scene the texture belongs to
  72404. * @param generateMipMaps define whether mip maps should be generated or not
  72405. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72406. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72407. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72408. */
  72409. constructor(data: ArrayBufferView, width: number, height: number,
  72410. /**
  72411. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72412. */
  72413. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  72414. /**
  72415. * Updates the texture underlying data.
  72416. * @param data Define the new data of the texture
  72417. */
  72418. update(data: ArrayBufferView): void;
  72419. /**
  72420. * Creates a luminance texture from some data.
  72421. * @param data Define the texture data
  72422. * @param width Define the width of the texture
  72423. * @param height Define the height of the texture
  72424. * @param scene Define the scene the texture belongs to
  72425. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72426. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72427. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72428. * @returns the luminance texture
  72429. */
  72430. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72431. /**
  72432. * Creates a luminance alpha texture from some data.
  72433. * @param data Define the texture data
  72434. * @param width Define the width of the texture
  72435. * @param height Define the height of the texture
  72436. * @param scene Define the scene the texture belongs to
  72437. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72438. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72439. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72440. * @returns the luminance alpha texture
  72441. */
  72442. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72443. /**
  72444. * Creates an alpha texture from some data.
  72445. * @param data Define the texture data
  72446. * @param width Define the width of the texture
  72447. * @param height Define the height of the texture
  72448. * @param scene Define the scene the texture belongs to
  72449. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72450. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72451. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72452. * @returns the alpha texture
  72453. */
  72454. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72455. /**
  72456. * Creates a RGB texture from some data.
  72457. * @param data Define the texture data
  72458. * @param width Define the width of the texture
  72459. * @param height Define the height of the texture
  72460. * @param scene Define the scene the texture belongs to
  72461. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72462. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72463. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72464. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72465. * @returns the RGB alpha texture
  72466. */
  72467. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72468. /**
  72469. * Creates a RGBA texture from some data.
  72470. * @param data Define the texture data
  72471. * @param width Define the width of the texture
  72472. * @param height Define the height of the texture
  72473. * @param scene Define the scene the texture belongs to
  72474. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72475. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72476. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72477. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72478. * @returns the RGBA texture
  72479. */
  72480. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72481. /**
  72482. * Creates a R texture from some data.
  72483. * @param data Define the texture data
  72484. * @param width Define the width of the texture
  72485. * @param height Define the height of the texture
  72486. * @param scene Define the scene the texture belongs to
  72487. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72488. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72489. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72490. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72491. * @returns the R texture
  72492. */
  72493. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72494. }
  72495. }
  72496. declare module BABYLON {
  72497. /**
  72498. * Defines a runtime animation
  72499. */
  72500. export class RuntimeAnimation {
  72501. private _events;
  72502. /**
  72503. * The current frame of the runtime animation
  72504. */
  72505. private _currentFrame;
  72506. /**
  72507. * The animation used by the runtime animation
  72508. */
  72509. private _animation;
  72510. /**
  72511. * The target of the runtime animation
  72512. */
  72513. private _target;
  72514. /**
  72515. * The initiating animatable
  72516. */
  72517. private _host;
  72518. /**
  72519. * The original value of the runtime animation
  72520. */
  72521. private _originalValue;
  72522. /**
  72523. * The original blend value of the runtime animation
  72524. */
  72525. private _originalBlendValue;
  72526. /**
  72527. * The offsets cache of the runtime animation
  72528. */
  72529. private _offsetsCache;
  72530. /**
  72531. * The high limits cache of the runtime animation
  72532. */
  72533. private _highLimitsCache;
  72534. /**
  72535. * Specifies if the runtime animation has been stopped
  72536. */
  72537. private _stopped;
  72538. /**
  72539. * The blending factor of the runtime animation
  72540. */
  72541. private _blendingFactor;
  72542. /**
  72543. * The BabylonJS scene
  72544. */
  72545. private _scene;
  72546. /**
  72547. * The current value of the runtime animation
  72548. */
  72549. private _currentValue;
  72550. /** @hidden */
  72551. _animationState: _IAnimationState;
  72552. /**
  72553. * The active target of the runtime animation
  72554. */
  72555. private _activeTargets;
  72556. private _currentActiveTarget;
  72557. private _directTarget;
  72558. /**
  72559. * The target path of the runtime animation
  72560. */
  72561. private _targetPath;
  72562. /**
  72563. * The weight of the runtime animation
  72564. */
  72565. private _weight;
  72566. /**
  72567. * The ratio offset of the runtime animation
  72568. */
  72569. private _ratioOffset;
  72570. /**
  72571. * The previous delay of the runtime animation
  72572. */
  72573. private _previousDelay;
  72574. /**
  72575. * The previous ratio of the runtime animation
  72576. */
  72577. private _previousRatio;
  72578. private _enableBlending;
  72579. private _keys;
  72580. private _minFrame;
  72581. private _maxFrame;
  72582. private _minValue;
  72583. private _maxValue;
  72584. private _targetIsArray;
  72585. /**
  72586. * Gets the current frame of the runtime animation
  72587. */
  72588. readonly currentFrame: number;
  72589. /**
  72590. * Gets the weight of the runtime animation
  72591. */
  72592. readonly weight: number;
  72593. /**
  72594. * Gets the current value of the runtime animation
  72595. */
  72596. readonly currentValue: any;
  72597. /**
  72598. * Gets the target path of the runtime animation
  72599. */
  72600. readonly targetPath: string;
  72601. /**
  72602. * Gets the actual target of the runtime animation
  72603. */
  72604. readonly target: any;
  72605. /** @hidden */
  72606. _onLoop: () => void;
  72607. /**
  72608. * Create a new RuntimeAnimation object
  72609. * @param target defines the target of the animation
  72610. * @param animation defines the source animation object
  72611. * @param scene defines the hosting scene
  72612. * @param host defines the initiating Animatable
  72613. */
  72614. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  72615. private _preparePath;
  72616. /**
  72617. * Gets the animation from the runtime animation
  72618. */
  72619. readonly animation: Animation;
  72620. /**
  72621. * Resets the runtime animation to the beginning
  72622. * @param restoreOriginal defines whether to restore the target property to the original value
  72623. */
  72624. reset(restoreOriginal?: boolean): void;
  72625. /**
  72626. * Specifies if the runtime animation is stopped
  72627. * @returns Boolean specifying if the runtime animation is stopped
  72628. */
  72629. isStopped(): boolean;
  72630. /**
  72631. * Disposes of the runtime animation
  72632. */
  72633. dispose(): void;
  72634. /**
  72635. * Apply the interpolated value to the target
  72636. * @param currentValue defines the value computed by the animation
  72637. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  72638. */
  72639. setValue(currentValue: any, weight: number): void;
  72640. private _getOriginalValues;
  72641. private _setValue;
  72642. /**
  72643. * Gets the loop pmode of the runtime animation
  72644. * @returns Loop Mode
  72645. */
  72646. private _getCorrectLoopMode;
  72647. /**
  72648. * Move the current animation to a given frame
  72649. * @param frame defines the frame to move to
  72650. */
  72651. goToFrame(frame: number): void;
  72652. /**
  72653. * @hidden Internal use only
  72654. */
  72655. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  72656. /**
  72657. * Execute the current animation
  72658. * @param delay defines the delay to add to the current frame
  72659. * @param from defines the lower bound of the animation range
  72660. * @param to defines the upper bound of the animation range
  72661. * @param loop defines if the current animation must loop
  72662. * @param speedRatio defines the current speed ratio
  72663. * @param weight defines the weight of the animation (default is -1 so no weight)
  72664. * @param onLoop optional callback called when animation loops
  72665. * @returns a boolean indicating if the animation is running
  72666. */
  72667. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  72668. }
  72669. }
  72670. declare module BABYLON {
  72671. /**
  72672. * Class used to store an actual running animation
  72673. */
  72674. export class Animatable {
  72675. /** defines the target object */
  72676. target: any;
  72677. /** defines the starting frame number (default is 0) */
  72678. fromFrame: number;
  72679. /** defines the ending frame number (default is 100) */
  72680. toFrame: number;
  72681. /** defines if the animation must loop (default is false) */
  72682. loopAnimation: boolean;
  72683. /** defines a callback to call when animation ends if it is not looping */
  72684. onAnimationEnd?: (() => void) | null | undefined;
  72685. /** defines a callback to call when animation loops */
  72686. onAnimationLoop?: (() => void) | null | undefined;
  72687. private _localDelayOffset;
  72688. private _pausedDelay;
  72689. private _runtimeAnimations;
  72690. private _paused;
  72691. private _scene;
  72692. private _speedRatio;
  72693. private _weight;
  72694. private _syncRoot;
  72695. /**
  72696. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  72697. * This will only apply for non looping animation (default is true)
  72698. */
  72699. disposeOnEnd: boolean;
  72700. /**
  72701. * Gets a boolean indicating if the animation has started
  72702. */
  72703. animationStarted: boolean;
  72704. /**
  72705. * Observer raised when the animation ends
  72706. */
  72707. onAnimationEndObservable: Observable<Animatable>;
  72708. /**
  72709. * Observer raised when the animation loops
  72710. */
  72711. onAnimationLoopObservable: Observable<Animatable>;
  72712. /**
  72713. * Gets the root Animatable used to synchronize and normalize animations
  72714. */
  72715. readonly syncRoot: Nullable<Animatable>;
  72716. /**
  72717. * Gets the current frame of the first RuntimeAnimation
  72718. * Used to synchronize Animatables
  72719. */
  72720. readonly masterFrame: number;
  72721. /**
  72722. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  72723. */
  72724. weight: number;
  72725. /**
  72726. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  72727. */
  72728. speedRatio: number;
  72729. /**
  72730. * Creates a new Animatable
  72731. * @param scene defines the hosting scene
  72732. * @param target defines the target object
  72733. * @param fromFrame defines the starting frame number (default is 0)
  72734. * @param toFrame defines the ending frame number (default is 100)
  72735. * @param loopAnimation defines if the animation must loop (default is false)
  72736. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  72737. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  72738. * @param animations defines a group of animation to add to the new Animatable
  72739. * @param onAnimationLoop defines a callback to call when animation loops
  72740. */
  72741. constructor(scene: Scene,
  72742. /** defines the target object */
  72743. target: any,
  72744. /** defines the starting frame number (default is 0) */
  72745. fromFrame?: number,
  72746. /** defines the ending frame number (default is 100) */
  72747. toFrame?: number,
  72748. /** defines if the animation must loop (default is false) */
  72749. loopAnimation?: boolean, speedRatio?: number,
  72750. /** defines a callback to call when animation ends if it is not looping */
  72751. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  72752. /** defines a callback to call when animation loops */
  72753. onAnimationLoop?: (() => void) | null | undefined);
  72754. /**
  72755. * Synchronize and normalize current Animatable with a source Animatable
  72756. * This is useful when using animation weights and when animations are not of the same length
  72757. * @param root defines the root Animatable to synchronize with
  72758. * @returns the current Animatable
  72759. */
  72760. syncWith(root: Animatable): Animatable;
  72761. /**
  72762. * Gets the list of runtime animations
  72763. * @returns an array of RuntimeAnimation
  72764. */
  72765. getAnimations(): RuntimeAnimation[];
  72766. /**
  72767. * Adds more animations to the current animatable
  72768. * @param target defines the target of the animations
  72769. * @param animations defines the new animations to add
  72770. */
  72771. appendAnimations(target: any, animations: Animation[]): void;
  72772. /**
  72773. * Gets the source animation for a specific property
  72774. * @param property defines the propertyu to look for
  72775. * @returns null or the source animation for the given property
  72776. */
  72777. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  72778. /**
  72779. * Gets the runtime animation for a specific property
  72780. * @param property defines the propertyu to look for
  72781. * @returns null or the runtime animation for the given property
  72782. */
  72783. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  72784. /**
  72785. * Resets the animatable to its original state
  72786. */
  72787. reset(): void;
  72788. /**
  72789. * Allows the animatable to blend with current running animations
  72790. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72791. * @param blendingSpeed defines the blending speed to use
  72792. */
  72793. enableBlending(blendingSpeed: number): void;
  72794. /**
  72795. * Disable animation blending
  72796. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72797. */
  72798. disableBlending(): void;
  72799. /**
  72800. * Jump directly to a given frame
  72801. * @param frame defines the frame to jump to
  72802. */
  72803. goToFrame(frame: number): void;
  72804. /**
  72805. * Pause the animation
  72806. */
  72807. pause(): void;
  72808. /**
  72809. * Restart the animation
  72810. */
  72811. restart(): void;
  72812. private _raiseOnAnimationEnd;
  72813. /**
  72814. * Stop and delete the current animation
  72815. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  72816. * @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)
  72817. */
  72818. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  72819. /**
  72820. * Wait asynchronously for the animation to end
  72821. * @returns a promise which will be fullfilled when the animation ends
  72822. */
  72823. waitAsync(): Promise<Animatable>;
  72824. /** @hidden */
  72825. _animate(delay: number): boolean;
  72826. }
  72827. interface Scene {
  72828. /** @hidden */
  72829. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  72830. /** @hidden */
  72831. _processLateAnimationBindingsForMatrices(holder: {
  72832. totalWeight: number;
  72833. animations: RuntimeAnimation[];
  72834. originalValue: Matrix;
  72835. }): any;
  72836. /** @hidden */
  72837. _processLateAnimationBindingsForQuaternions(holder: {
  72838. totalWeight: number;
  72839. animations: RuntimeAnimation[];
  72840. originalValue: Quaternion;
  72841. }, refQuaternion: Quaternion): Quaternion;
  72842. /** @hidden */
  72843. _processLateAnimationBindings(): void;
  72844. /**
  72845. * Will start the animation sequence of a given target
  72846. * @param target defines the target
  72847. * @param from defines from which frame should animation start
  72848. * @param to defines until which frame should animation run.
  72849. * @param weight defines the weight to apply to the animation (1.0 by default)
  72850. * @param loop defines if the animation loops
  72851. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72852. * @param onAnimationEnd defines the function to be executed when the animation ends
  72853. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72854. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72855. * @param onAnimationLoop defines the callback to call when an animation loops
  72856. * @returns the animatable object created for this animation
  72857. */
  72858. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72859. /**
  72860. * Will start the animation sequence of a given target
  72861. * @param target defines the target
  72862. * @param from defines from which frame should animation start
  72863. * @param to defines until which frame should animation run.
  72864. * @param loop defines if the animation loops
  72865. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72866. * @param onAnimationEnd defines the function to be executed when the animation ends
  72867. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72868. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72869. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  72870. * @param onAnimationLoop defines the callback to call when an animation loops
  72871. * @returns the animatable object created for this animation
  72872. */
  72873. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72874. /**
  72875. * Will start the animation sequence of a given target and its hierarchy
  72876. * @param target defines the target
  72877. * @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.
  72878. * @param from defines from which frame should animation start
  72879. * @param to defines until which frame should animation run.
  72880. * @param loop defines if the animation loops
  72881. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72882. * @param onAnimationEnd defines the function to be executed when the animation ends
  72883. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72884. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72885. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72886. * @param onAnimationLoop defines the callback to call when an animation loops
  72887. * @returns the list of created animatables
  72888. */
  72889. 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[];
  72890. /**
  72891. * Begin a new animation on a given node
  72892. * @param target defines the target where the animation will take place
  72893. * @param animations defines the list of animations to start
  72894. * @param from defines the initial value
  72895. * @param to defines the final value
  72896. * @param loop defines if you want animation to loop (off by default)
  72897. * @param speedRatio defines the speed ratio to apply to all animations
  72898. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72899. * @param onAnimationLoop defines the callback to call when an animation loops
  72900. * @returns the list of created animatables
  72901. */
  72902. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  72903. /**
  72904. * Begin a new animation on a given node and its hierarchy
  72905. * @param target defines the root node where the animation will take place
  72906. * @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.
  72907. * @param animations defines the list of animations to start
  72908. * @param from defines the initial value
  72909. * @param to defines the final value
  72910. * @param loop defines if you want animation to loop (off by default)
  72911. * @param speedRatio defines the speed ratio to apply to all animations
  72912. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72913. * @param onAnimationLoop defines the callback to call when an animation loops
  72914. * @returns the list of animatables created for all nodes
  72915. */
  72916. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  72917. /**
  72918. * Gets the animatable associated with a specific target
  72919. * @param target defines the target of the animatable
  72920. * @returns the required animatable if found
  72921. */
  72922. getAnimatableByTarget(target: any): Nullable<Animatable>;
  72923. /**
  72924. * Gets all animatables associated with a given target
  72925. * @param target defines the target to look animatables for
  72926. * @returns an array of Animatables
  72927. */
  72928. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  72929. /**
  72930. * Stops and removes all animations that have been applied to the scene
  72931. */
  72932. stopAllAnimations(): void;
  72933. }
  72934. interface Bone {
  72935. /**
  72936. * Copy an animation range from another bone
  72937. * @param source defines the source bone
  72938. * @param rangeName defines the range name to copy
  72939. * @param frameOffset defines the frame offset
  72940. * @param rescaleAsRequired defines if rescaling must be applied if required
  72941. * @param skelDimensionsRatio defines the scaling ratio
  72942. * @returns true if operation was successful
  72943. */
  72944. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  72945. }
  72946. }
  72947. declare module BABYLON {
  72948. /**
  72949. * Class used to handle skinning animations
  72950. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  72951. */
  72952. export class Skeleton implements IAnimatable {
  72953. /** defines the skeleton name */
  72954. name: string;
  72955. /** defines the skeleton Id */
  72956. id: string;
  72957. /**
  72958. * Defines the list of child bones
  72959. */
  72960. bones: Bone[];
  72961. /**
  72962. * Defines an estimate of the dimension of the skeleton at rest
  72963. */
  72964. dimensionsAtRest: Vector3;
  72965. /**
  72966. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  72967. */
  72968. needInitialSkinMatrix: boolean;
  72969. /**
  72970. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  72971. */
  72972. overrideMesh: Nullable<AbstractMesh>;
  72973. /**
  72974. * Gets the list of animations attached to this skeleton
  72975. */
  72976. animations: Array<Animation>;
  72977. private _scene;
  72978. private _isDirty;
  72979. private _transformMatrices;
  72980. private _transformMatrixTexture;
  72981. private _meshesWithPoseMatrix;
  72982. private _animatables;
  72983. private _identity;
  72984. private _synchronizedWithMesh;
  72985. private _ranges;
  72986. private _lastAbsoluteTransformsUpdateId;
  72987. private _canUseTextureForBones;
  72988. private _uniqueId;
  72989. /** @hidden */
  72990. _numBonesWithLinkedTransformNode: number;
  72991. /** @hidden */
  72992. _hasWaitingData: Nullable<boolean>;
  72993. /**
  72994. * Specifies if the skeleton should be serialized
  72995. */
  72996. doNotSerialize: boolean;
  72997. private _useTextureToStoreBoneMatrices;
  72998. /**
  72999. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  73000. * Please note that this option is not available if the hardware does not support it
  73001. */
  73002. useTextureToStoreBoneMatrices: boolean;
  73003. private _animationPropertiesOverride;
  73004. /**
  73005. * Gets or sets the animation properties override
  73006. */
  73007. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  73008. /**
  73009. * List of inspectable custom properties (used by the Inspector)
  73010. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73011. */
  73012. inspectableCustomProperties: IInspectable[];
  73013. /**
  73014. * An observable triggered before computing the skeleton's matrices
  73015. */
  73016. onBeforeComputeObservable: Observable<Skeleton>;
  73017. /**
  73018. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  73019. */
  73020. readonly isUsingTextureForMatrices: boolean;
  73021. /**
  73022. * Gets the unique ID of this skeleton
  73023. */
  73024. readonly uniqueId: number;
  73025. /**
  73026. * Creates a new skeleton
  73027. * @param name defines the skeleton name
  73028. * @param id defines the skeleton Id
  73029. * @param scene defines the hosting scene
  73030. */
  73031. constructor(
  73032. /** defines the skeleton name */
  73033. name: string,
  73034. /** defines the skeleton Id */
  73035. id: string, scene: Scene);
  73036. /**
  73037. * Gets the current object class name.
  73038. * @return the class name
  73039. */
  73040. getClassName(): string;
  73041. /**
  73042. * Returns an array containing the root bones
  73043. * @returns an array containing the root bones
  73044. */
  73045. getChildren(): Array<Bone>;
  73046. /**
  73047. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  73048. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  73049. * @returns a Float32Array containing matrices data
  73050. */
  73051. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  73052. /**
  73053. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  73054. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  73055. * @returns a raw texture containing the data
  73056. */
  73057. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  73058. /**
  73059. * Gets the current hosting scene
  73060. * @returns a scene object
  73061. */
  73062. getScene(): Scene;
  73063. /**
  73064. * Gets a string representing the current skeleton data
  73065. * @param fullDetails defines a boolean indicating if we want a verbose version
  73066. * @returns a string representing the current skeleton data
  73067. */
  73068. toString(fullDetails?: boolean): string;
  73069. /**
  73070. * Get bone's index searching by name
  73071. * @param name defines bone's name to search for
  73072. * @return the indice of the bone. Returns -1 if not found
  73073. */
  73074. getBoneIndexByName(name: string): number;
  73075. /**
  73076. * Creater a new animation range
  73077. * @param name defines the name of the range
  73078. * @param from defines the start key
  73079. * @param to defines the end key
  73080. */
  73081. createAnimationRange(name: string, from: number, to: number): void;
  73082. /**
  73083. * Delete a specific animation range
  73084. * @param name defines the name of the range
  73085. * @param deleteFrames defines if frames must be removed as well
  73086. */
  73087. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  73088. /**
  73089. * Gets a specific animation range
  73090. * @param name defines the name of the range to look for
  73091. * @returns the requested animation range or null if not found
  73092. */
  73093. getAnimationRange(name: string): Nullable<AnimationRange>;
  73094. /**
  73095. * Gets the list of all animation ranges defined on this skeleton
  73096. * @returns an array
  73097. */
  73098. getAnimationRanges(): Nullable<AnimationRange>[];
  73099. /**
  73100. * Copy animation range from a source skeleton.
  73101. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  73102. * @param source defines the source skeleton
  73103. * @param name defines the name of the range to copy
  73104. * @param rescaleAsRequired defines if rescaling must be applied if required
  73105. * @returns true if operation was successful
  73106. */
  73107. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  73108. /**
  73109. * Forces the skeleton to go to rest pose
  73110. */
  73111. returnToRest(): void;
  73112. private _getHighestAnimationFrame;
  73113. /**
  73114. * Begin a specific animation range
  73115. * @param name defines the name of the range to start
  73116. * @param loop defines if looping must be turned on (false by default)
  73117. * @param speedRatio defines the speed ratio to apply (1 by default)
  73118. * @param onAnimationEnd defines a callback which will be called when animation will end
  73119. * @returns a new animatable
  73120. */
  73121. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  73122. /** @hidden */
  73123. _markAsDirty(): void;
  73124. /** @hidden */
  73125. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  73126. /** @hidden */
  73127. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  73128. private _computeTransformMatrices;
  73129. /**
  73130. * Build all resources required to render a skeleton
  73131. */
  73132. prepare(): void;
  73133. /**
  73134. * Gets the list of animatables currently running for this skeleton
  73135. * @returns an array of animatables
  73136. */
  73137. getAnimatables(): IAnimatable[];
  73138. /**
  73139. * Clone the current skeleton
  73140. * @param name defines the name of the new skeleton
  73141. * @param id defines the id of the new skeleton
  73142. * @returns the new skeleton
  73143. */
  73144. clone(name: string, id: string): Skeleton;
  73145. /**
  73146. * Enable animation blending for this skeleton
  73147. * @param blendingSpeed defines the blending speed to apply
  73148. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  73149. */
  73150. enableBlending(blendingSpeed?: number): void;
  73151. /**
  73152. * Releases all resources associated with the current skeleton
  73153. */
  73154. dispose(): void;
  73155. /**
  73156. * Serialize the skeleton in a JSON object
  73157. * @returns a JSON object
  73158. */
  73159. serialize(): any;
  73160. /**
  73161. * Creates a new skeleton from serialized data
  73162. * @param parsedSkeleton defines the serialized data
  73163. * @param scene defines the hosting scene
  73164. * @returns a new skeleton
  73165. */
  73166. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  73167. /**
  73168. * Compute all node absolute transforms
  73169. * @param forceUpdate defines if computation must be done even if cache is up to date
  73170. */
  73171. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  73172. /**
  73173. * Gets the root pose matrix
  73174. * @returns a matrix
  73175. */
  73176. getPoseMatrix(): Nullable<Matrix>;
  73177. /**
  73178. * Sorts bones per internal index
  73179. */
  73180. sortBones(): void;
  73181. private _sortBones;
  73182. }
  73183. }
  73184. declare module BABYLON {
  73185. /**
  73186. * Defines a target to use with MorphTargetManager
  73187. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73188. */
  73189. export class MorphTarget implements IAnimatable {
  73190. /** defines the name of the target */
  73191. name: string;
  73192. /**
  73193. * Gets or sets the list of animations
  73194. */
  73195. animations: Animation[];
  73196. private _scene;
  73197. private _positions;
  73198. private _normals;
  73199. private _tangents;
  73200. private _uvs;
  73201. private _influence;
  73202. /**
  73203. * Observable raised when the influence changes
  73204. */
  73205. onInfluenceChanged: Observable<boolean>;
  73206. /** @hidden */
  73207. _onDataLayoutChanged: Observable<void>;
  73208. /**
  73209. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  73210. */
  73211. influence: number;
  73212. /**
  73213. * Gets or sets the id of the morph Target
  73214. */
  73215. id: string;
  73216. private _animationPropertiesOverride;
  73217. /**
  73218. * Gets or sets the animation properties override
  73219. */
  73220. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  73221. /**
  73222. * Creates a new MorphTarget
  73223. * @param name defines the name of the target
  73224. * @param influence defines the influence to use
  73225. * @param scene defines the scene the morphtarget belongs to
  73226. */
  73227. constructor(
  73228. /** defines the name of the target */
  73229. name: string, influence?: number, scene?: Nullable<Scene>);
  73230. /**
  73231. * Gets a boolean defining if the target contains position data
  73232. */
  73233. readonly hasPositions: boolean;
  73234. /**
  73235. * Gets a boolean defining if the target contains normal data
  73236. */
  73237. readonly hasNormals: boolean;
  73238. /**
  73239. * Gets a boolean defining if the target contains tangent data
  73240. */
  73241. readonly hasTangents: boolean;
  73242. /**
  73243. * Gets a boolean defining if the target contains texture coordinates data
  73244. */
  73245. readonly hasUVs: boolean;
  73246. /**
  73247. * Affects position data to this target
  73248. * @param data defines the position data to use
  73249. */
  73250. setPositions(data: Nullable<FloatArray>): void;
  73251. /**
  73252. * Gets the position data stored in this target
  73253. * @returns a FloatArray containing the position data (or null if not present)
  73254. */
  73255. getPositions(): Nullable<FloatArray>;
  73256. /**
  73257. * Affects normal data to this target
  73258. * @param data defines the normal data to use
  73259. */
  73260. setNormals(data: Nullable<FloatArray>): void;
  73261. /**
  73262. * Gets the normal data stored in this target
  73263. * @returns a FloatArray containing the normal data (or null if not present)
  73264. */
  73265. getNormals(): Nullable<FloatArray>;
  73266. /**
  73267. * Affects tangent data to this target
  73268. * @param data defines the tangent data to use
  73269. */
  73270. setTangents(data: Nullable<FloatArray>): void;
  73271. /**
  73272. * Gets the tangent data stored in this target
  73273. * @returns a FloatArray containing the tangent data (or null if not present)
  73274. */
  73275. getTangents(): Nullable<FloatArray>;
  73276. /**
  73277. * Affects texture coordinates data to this target
  73278. * @param data defines the texture coordinates data to use
  73279. */
  73280. setUVs(data: Nullable<FloatArray>): void;
  73281. /**
  73282. * Gets the texture coordinates data stored in this target
  73283. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  73284. */
  73285. getUVs(): Nullable<FloatArray>;
  73286. /**
  73287. * Serializes the current target into a Serialization object
  73288. * @returns the serialized object
  73289. */
  73290. serialize(): any;
  73291. /**
  73292. * Returns the string "MorphTarget"
  73293. * @returns "MorphTarget"
  73294. */
  73295. getClassName(): string;
  73296. /**
  73297. * Creates a new target from serialized data
  73298. * @param serializationObject defines the serialized data to use
  73299. * @returns a new MorphTarget
  73300. */
  73301. static Parse(serializationObject: any): MorphTarget;
  73302. /**
  73303. * Creates a MorphTarget from mesh data
  73304. * @param mesh defines the source mesh
  73305. * @param name defines the name to use for the new target
  73306. * @param influence defines the influence to attach to the target
  73307. * @returns a new MorphTarget
  73308. */
  73309. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  73310. }
  73311. }
  73312. declare module BABYLON {
  73313. /**
  73314. * This class is used to deform meshes using morphing between different targets
  73315. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73316. */
  73317. export class MorphTargetManager {
  73318. private _targets;
  73319. private _targetInfluenceChangedObservers;
  73320. private _targetDataLayoutChangedObservers;
  73321. private _activeTargets;
  73322. private _scene;
  73323. private _influences;
  73324. private _supportsNormals;
  73325. private _supportsTangents;
  73326. private _supportsUVs;
  73327. private _vertexCount;
  73328. private _uniqueId;
  73329. private _tempInfluences;
  73330. /**
  73331. * Gets or sets a boolean indicating if normals must be morphed
  73332. */
  73333. enableNormalMorphing: boolean;
  73334. /**
  73335. * Gets or sets a boolean indicating if tangents must be morphed
  73336. */
  73337. enableTangentMorphing: boolean;
  73338. /**
  73339. * Gets or sets a boolean indicating if UV must be morphed
  73340. */
  73341. enableUVMorphing: boolean;
  73342. /**
  73343. * Creates a new MorphTargetManager
  73344. * @param scene defines the current scene
  73345. */
  73346. constructor(scene?: Nullable<Scene>);
  73347. /**
  73348. * Gets the unique ID of this manager
  73349. */
  73350. readonly uniqueId: number;
  73351. /**
  73352. * Gets the number of vertices handled by this manager
  73353. */
  73354. readonly vertexCount: number;
  73355. /**
  73356. * Gets a boolean indicating if this manager supports morphing of normals
  73357. */
  73358. readonly supportsNormals: boolean;
  73359. /**
  73360. * Gets a boolean indicating if this manager supports morphing of tangents
  73361. */
  73362. readonly supportsTangents: boolean;
  73363. /**
  73364. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  73365. */
  73366. readonly supportsUVs: boolean;
  73367. /**
  73368. * Gets the number of targets stored in this manager
  73369. */
  73370. readonly numTargets: number;
  73371. /**
  73372. * Gets the number of influencers (ie. the number of targets with influences > 0)
  73373. */
  73374. readonly numInfluencers: number;
  73375. /**
  73376. * Gets the list of influences (one per target)
  73377. */
  73378. readonly influences: Float32Array;
  73379. /**
  73380. * Gets the active target at specified index. An active target is a target with an influence > 0
  73381. * @param index defines the index to check
  73382. * @returns the requested target
  73383. */
  73384. getActiveTarget(index: number): MorphTarget;
  73385. /**
  73386. * Gets the target at specified index
  73387. * @param index defines the index to check
  73388. * @returns the requested target
  73389. */
  73390. getTarget(index: number): MorphTarget;
  73391. /**
  73392. * Add a new target to this manager
  73393. * @param target defines the target to add
  73394. */
  73395. addTarget(target: MorphTarget): void;
  73396. /**
  73397. * Removes a target from the manager
  73398. * @param target defines the target to remove
  73399. */
  73400. removeTarget(target: MorphTarget): void;
  73401. /**
  73402. * Serializes the current manager into a Serialization object
  73403. * @returns the serialized object
  73404. */
  73405. serialize(): any;
  73406. private _syncActiveTargets;
  73407. /**
  73408. * Syncrhonize the targets with all the meshes using this morph target manager
  73409. */
  73410. synchronize(): void;
  73411. /**
  73412. * Creates a new MorphTargetManager from serialized data
  73413. * @param serializationObject defines the serialized data
  73414. * @param scene defines the hosting scene
  73415. * @returns the new MorphTargetManager
  73416. */
  73417. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  73418. }
  73419. }
  73420. declare module BABYLON {
  73421. /**
  73422. * Groups all the scene component constants in one place to ease maintenance.
  73423. * @hidden
  73424. */
  73425. export class SceneComponentConstants {
  73426. static readonly NAME_EFFECTLAYER: string;
  73427. static readonly NAME_LAYER: string;
  73428. static readonly NAME_LENSFLARESYSTEM: string;
  73429. static readonly NAME_BOUNDINGBOXRENDERER: string;
  73430. static readonly NAME_PARTICLESYSTEM: string;
  73431. static readonly NAME_GAMEPAD: string;
  73432. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  73433. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  73434. static readonly NAME_DEPTHRENDERER: string;
  73435. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  73436. static readonly NAME_SPRITE: string;
  73437. static readonly NAME_OUTLINERENDERER: string;
  73438. static readonly NAME_PROCEDURALTEXTURE: string;
  73439. static readonly NAME_SHADOWGENERATOR: string;
  73440. static readonly NAME_OCTREE: string;
  73441. static readonly NAME_PHYSICSENGINE: string;
  73442. static readonly NAME_AUDIO: string;
  73443. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  73444. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73445. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  73446. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73447. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  73448. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  73449. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  73450. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  73451. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  73452. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  73453. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  73454. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  73455. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  73456. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  73457. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  73458. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  73459. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  73460. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  73461. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  73462. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  73463. static readonly STEP_AFTERRENDER_AUDIO: number;
  73464. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  73465. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  73466. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  73467. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  73468. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  73469. static readonly STEP_POINTERMOVE_SPRITE: number;
  73470. static readonly STEP_POINTERDOWN_SPRITE: number;
  73471. static readonly STEP_POINTERUP_SPRITE: number;
  73472. }
  73473. /**
  73474. * This represents a scene component.
  73475. *
  73476. * This is used to decouple the dependency the scene is having on the different workloads like
  73477. * layers, post processes...
  73478. */
  73479. export interface ISceneComponent {
  73480. /**
  73481. * The name of the component. Each component must have a unique name.
  73482. */
  73483. name: string;
  73484. /**
  73485. * The scene the component belongs to.
  73486. */
  73487. scene: Scene;
  73488. /**
  73489. * Register the component to one instance of a scene.
  73490. */
  73491. register(): void;
  73492. /**
  73493. * Rebuilds the elements related to this component in case of
  73494. * context lost for instance.
  73495. */
  73496. rebuild(): void;
  73497. /**
  73498. * Disposes the component and the associated ressources.
  73499. */
  73500. dispose(): void;
  73501. }
  73502. /**
  73503. * This represents a SERIALIZABLE scene component.
  73504. *
  73505. * This extends Scene Component to add Serialization methods on top.
  73506. */
  73507. export interface ISceneSerializableComponent extends ISceneComponent {
  73508. /**
  73509. * Adds all the elements from the container to the scene
  73510. * @param container the container holding the elements
  73511. */
  73512. addFromContainer(container: AbstractScene): void;
  73513. /**
  73514. * Removes all the elements in the container from the scene
  73515. * @param container contains the elements to remove
  73516. * @param dispose if the removed element should be disposed (default: false)
  73517. */
  73518. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73519. /**
  73520. * Serializes the component data to the specified json object
  73521. * @param serializationObject The object to serialize to
  73522. */
  73523. serialize(serializationObject: any): void;
  73524. }
  73525. /**
  73526. * Strong typing of a Mesh related stage step action
  73527. */
  73528. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73529. /**
  73530. * Strong typing of a Evaluate Sub Mesh related stage step action
  73531. */
  73532. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73533. /**
  73534. * Strong typing of a Active Mesh related stage step action
  73535. */
  73536. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73537. /**
  73538. * Strong typing of a Camera related stage step action
  73539. */
  73540. export type CameraStageAction = (camera: Camera) => void;
  73541. /**
  73542. * Strong typing of a Camera Frame buffer related stage step action
  73543. */
  73544. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73545. /**
  73546. * Strong typing of a Render Target related stage step action
  73547. */
  73548. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73549. /**
  73550. * Strong typing of a RenderingGroup related stage step action
  73551. */
  73552. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73553. /**
  73554. * Strong typing of a Mesh Render related stage step action
  73555. */
  73556. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73557. /**
  73558. * Strong typing of a simple stage step action
  73559. */
  73560. export type SimpleStageAction = () => void;
  73561. /**
  73562. * Strong typing of a render target action.
  73563. */
  73564. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73565. /**
  73566. * Strong typing of a pointer move action.
  73567. */
  73568. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73569. /**
  73570. * Strong typing of a pointer up/down action.
  73571. */
  73572. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73573. /**
  73574. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73575. * @hidden
  73576. */
  73577. export class Stage<T extends Function> extends Array<{
  73578. index: number;
  73579. component: ISceneComponent;
  73580. action: T;
  73581. }> {
  73582. /**
  73583. * Hide ctor from the rest of the world.
  73584. * @param items The items to add.
  73585. */
  73586. private constructor();
  73587. /**
  73588. * Creates a new Stage.
  73589. * @returns A new instance of a Stage
  73590. */
  73591. static Create<T extends Function>(): Stage<T>;
  73592. /**
  73593. * Registers a step in an ordered way in the targeted stage.
  73594. * @param index Defines the position to register the step in
  73595. * @param component Defines the component attached to the step
  73596. * @param action Defines the action to launch during the step
  73597. */
  73598. registerStep(index: number, component: ISceneComponent, action: T): void;
  73599. /**
  73600. * Clears all the steps from the stage.
  73601. */
  73602. clear(): void;
  73603. }
  73604. }
  73605. declare module BABYLON {
  73606. /**
  73607. * Class used to represent a specific level of detail of a mesh
  73608. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  73609. */
  73610. export class MeshLODLevel {
  73611. /** Defines the distance where this level should star being displayed */
  73612. distance: number;
  73613. /** Defines the mesh to use to render this level */
  73614. mesh: Nullable<Mesh>;
  73615. /**
  73616. * Creates a new LOD level
  73617. * @param distance defines the distance where this level should star being displayed
  73618. * @param mesh defines the mesh to use to render this level
  73619. */
  73620. constructor(
  73621. /** Defines the distance where this level should star being displayed */
  73622. distance: number,
  73623. /** Defines the mesh to use to render this level */
  73624. mesh: Nullable<Mesh>);
  73625. }
  73626. }
  73627. declare module BABYLON {
  73628. /**
  73629. * Interface describing all the common properties and methods a shadow light needs to implement.
  73630. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73631. * as well as binding the different shadow properties to the effects.
  73632. */
  73633. export interface IShadowLight extends Light {
  73634. /**
  73635. * The light id in the scene (used in scene.findLighById for instance)
  73636. */
  73637. id: string;
  73638. /**
  73639. * The position the shdow will be casted from.
  73640. */
  73641. position: Vector3;
  73642. /**
  73643. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73644. */
  73645. direction: Vector3;
  73646. /**
  73647. * The transformed position. Position of the light in world space taking parenting in account.
  73648. */
  73649. transformedPosition: Vector3;
  73650. /**
  73651. * The transformed direction. Direction of the light in world space taking parenting in account.
  73652. */
  73653. transformedDirection: Vector3;
  73654. /**
  73655. * The friendly name of the light in the scene.
  73656. */
  73657. name: string;
  73658. /**
  73659. * Defines the shadow projection clipping minimum z value.
  73660. */
  73661. shadowMinZ: number;
  73662. /**
  73663. * Defines the shadow projection clipping maximum z value.
  73664. */
  73665. shadowMaxZ: number;
  73666. /**
  73667. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73668. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73669. */
  73670. computeTransformedInformation(): boolean;
  73671. /**
  73672. * Gets the scene the light belongs to.
  73673. * @returns The scene
  73674. */
  73675. getScene(): Scene;
  73676. /**
  73677. * Callback defining a custom Projection Matrix Builder.
  73678. * This can be used to override the default projection matrix computation.
  73679. */
  73680. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73681. /**
  73682. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73683. * @param matrix The materix to updated with the projection information
  73684. * @param viewMatrix The transform matrix of the light
  73685. * @param renderList The list of mesh to render in the map
  73686. * @returns The current light
  73687. */
  73688. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73689. /**
  73690. * Gets the current depth scale used in ESM.
  73691. * @returns The scale
  73692. */
  73693. getDepthScale(): number;
  73694. /**
  73695. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73696. * @returns true if a cube texture needs to be use
  73697. */
  73698. needCube(): boolean;
  73699. /**
  73700. * Detects if the projection matrix requires to be recomputed this frame.
  73701. * @returns true if it requires to be recomputed otherwise, false.
  73702. */
  73703. needProjectionMatrixCompute(): boolean;
  73704. /**
  73705. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73706. */
  73707. forceProjectionMatrixCompute(): void;
  73708. /**
  73709. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73710. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73711. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73712. */
  73713. getShadowDirection(faceIndex?: number): Vector3;
  73714. /**
  73715. * Gets the minZ used for shadow according to both the scene and the light.
  73716. * @param activeCamera The camera we are returning the min for
  73717. * @returns the depth min z
  73718. */
  73719. getDepthMinZ(activeCamera: Camera): number;
  73720. /**
  73721. * Gets the maxZ used for shadow according to both the scene and the light.
  73722. * @param activeCamera The camera we are returning the max for
  73723. * @returns the depth max z
  73724. */
  73725. getDepthMaxZ(activeCamera: Camera): number;
  73726. }
  73727. /**
  73728. * Base implementation IShadowLight
  73729. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73730. */
  73731. export abstract class ShadowLight extends Light implements IShadowLight {
  73732. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73733. protected _position: Vector3;
  73734. protected _setPosition(value: Vector3): void;
  73735. /**
  73736. * Sets the position the shadow will be casted from. Also use as the light position for both
  73737. * point and spot lights.
  73738. */
  73739. /**
  73740. * Sets the position the shadow will be casted from. Also use as the light position for both
  73741. * point and spot lights.
  73742. */
  73743. position: Vector3;
  73744. protected _direction: Vector3;
  73745. protected _setDirection(value: Vector3): void;
  73746. /**
  73747. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73748. * Also use as the light direction on spot and directional lights.
  73749. */
  73750. /**
  73751. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73752. * Also use as the light direction on spot and directional lights.
  73753. */
  73754. direction: Vector3;
  73755. private _shadowMinZ;
  73756. /**
  73757. * Gets the shadow projection clipping minimum z value.
  73758. */
  73759. /**
  73760. * Sets the shadow projection clipping minimum z value.
  73761. */
  73762. shadowMinZ: number;
  73763. private _shadowMaxZ;
  73764. /**
  73765. * Sets the shadow projection clipping maximum z value.
  73766. */
  73767. /**
  73768. * Gets the shadow projection clipping maximum z value.
  73769. */
  73770. shadowMaxZ: number;
  73771. /**
  73772. * Callback defining a custom Projection Matrix Builder.
  73773. * This can be used to override the default projection matrix computation.
  73774. */
  73775. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73776. /**
  73777. * The transformed position. Position of the light in world space taking parenting in account.
  73778. */
  73779. transformedPosition: Vector3;
  73780. /**
  73781. * The transformed direction. Direction of the light in world space taking parenting in account.
  73782. */
  73783. transformedDirection: Vector3;
  73784. private _needProjectionMatrixCompute;
  73785. /**
  73786. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73787. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73788. */
  73789. computeTransformedInformation(): boolean;
  73790. /**
  73791. * Return the depth scale used for the shadow map.
  73792. * @returns the depth scale.
  73793. */
  73794. getDepthScale(): number;
  73795. /**
  73796. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73797. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73798. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73799. */
  73800. getShadowDirection(faceIndex?: number): Vector3;
  73801. /**
  73802. * Returns the ShadowLight absolute position in the World.
  73803. * @returns the position vector in world space
  73804. */
  73805. getAbsolutePosition(): Vector3;
  73806. /**
  73807. * Sets the ShadowLight direction toward the passed target.
  73808. * @param target The point to target in local space
  73809. * @returns the updated ShadowLight direction
  73810. */
  73811. setDirectionToTarget(target: Vector3): Vector3;
  73812. /**
  73813. * Returns the light rotation in euler definition.
  73814. * @returns the x y z rotation in local space.
  73815. */
  73816. getRotation(): Vector3;
  73817. /**
  73818. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73819. * @returns true if a cube texture needs to be use
  73820. */
  73821. needCube(): boolean;
  73822. /**
  73823. * Detects if the projection matrix requires to be recomputed this frame.
  73824. * @returns true if it requires to be recomputed otherwise, false.
  73825. */
  73826. needProjectionMatrixCompute(): boolean;
  73827. /**
  73828. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73829. */
  73830. forceProjectionMatrixCompute(): void;
  73831. /** @hidden */
  73832. _initCache(): void;
  73833. /** @hidden */
  73834. _isSynchronized(): boolean;
  73835. /**
  73836. * Computes the world matrix of the node
  73837. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73838. * @returns the world matrix
  73839. */
  73840. computeWorldMatrix(force?: boolean): Matrix;
  73841. /**
  73842. * Gets the minZ used for shadow according to both the scene and the light.
  73843. * @param activeCamera The camera we are returning the min for
  73844. * @returns the depth min z
  73845. */
  73846. getDepthMinZ(activeCamera: Camera): number;
  73847. /**
  73848. * Gets the maxZ used for shadow according to both the scene and the light.
  73849. * @param activeCamera The camera we are returning the max for
  73850. * @returns the depth max z
  73851. */
  73852. getDepthMaxZ(activeCamera: Camera): number;
  73853. /**
  73854. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73855. * @param matrix The materix to updated with the projection information
  73856. * @param viewMatrix The transform matrix of the light
  73857. * @param renderList The list of mesh to render in the map
  73858. * @returns The current light
  73859. */
  73860. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73861. }
  73862. }
  73863. declare module BABYLON {
  73864. /**
  73865. * "Static Class" containing the most commonly used helper while dealing with material for
  73866. * rendering purpose.
  73867. *
  73868. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73869. *
  73870. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73871. */
  73872. export class MaterialHelper {
  73873. /**
  73874. * Bind the current view position to an effect.
  73875. * @param effect The effect to be bound
  73876. * @param scene The scene the eyes position is used from
  73877. */
  73878. static BindEyePosition(effect: Effect, scene: Scene): void;
  73879. /**
  73880. * Helps preparing the defines values about the UVs in used in the effect.
  73881. * UVs are shared as much as we can accross channels in the shaders.
  73882. * @param texture The texture we are preparing the UVs for
  73883. * @param defines The defines to update
  73884. * @param key The channel key "diffuse", "specular"... used in the shader
  73885. */
  73886. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73887. /**
  73888. * Binds a texture matrix value to its corrsponding uniform
  73889. * @param texture The texture to bind the matrix for
  73890. * @param uniformBuffer The uniform buffer receivin the data
  73891. * @param key The channel key "diffuse", "specular"... used in the shader
  73892. */
  73893. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73894. /**
  73895. * Gets the current status of the fog (should it be enabled?)
  73896. * @param mesh defines the mesh to evaluate for fog support
  73897. * @param scene defines the hosting scene
  73898. * @returns true if fog must be enabled
  73899. */
  73900. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73901. /**
  73902. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73903. * @param mesh defines the current mesh
  73904. * @param scene defines the current scene
  73905. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73906. * @param pointsCloud defines if point cloud rendering has to be turned on
  73907. * @param fogEnabled defines if fog has to be turned on
  73908. * @param alphaTest defines if alpha testing has to be turned on
  73909. * @param defines defines the current list of defines
  73910. */
  73911. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73912. /**
  73913. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73914. * @param scene defines the current scene
  73915. * @param engine defines the current engine
  73916. * @param defines specifies the list of active defines
  73917. * @param useInstances defines if instances have to be turned on
  73918. * @param useClipPlane defines if clip plane have to be turned on
  73919. */
  73920. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73921. /**
  73922. * Prepares the defines for bones
  73923. * @param mesh The mesh containing the geometry data we will draw
  73924. * @param defines The defines to update
  73925. */
  73926. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73927. /**
  73928. * Prepares the defines for morph targets
  73929. * @param mesh The mesh containing the geometry data we will draw
  73930. * @param defines The defines to update
  73931. */
  73932. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73933. /**
  73934. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73935. * @param mesh The mesh containing the geometry data we will draw
  73936. * @param defines The defines to update
  73937. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73938. * @param useBones Precise whether bones should be used or not (override mesh info)
  73939. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73940. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73941. * @returns false if defines are considered not dirty and have not been checked
  73942. */
  73943. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73944. /**
  73945. * Prepares the defines related to multiview
  73946. * @param scene The scene we are intending to draw
  73947. * @param defines The defines to update
  73948. */
  73949. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73950. /**
  73951. * Prepares the defines related to the light information passed in parameter
  73952. * @param scene The scene we are intending to draw
  73953. * @param mesh The mesh the effect is compiling for
  73954. * @param light The light the effect is compiling for
  73955. * @param lightIndex The index of the light
  73956. * @param defines The defines to update
  73957. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73958. * @param state Defines the current state regarding what is needed (normals, etc...)
  73959. */
  73960. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73961. needNormals: boolean;
  73962. needRebuild: boolean;
  73963. shadowEnabled: boolean;
  73964. specularEnabled: boolean;
  73965. lightmapMode: boolean;
  73966. }): void;
  73967. /**
  73968. * Prepares the defines related to the light information passed in parameter
  73969. * @param scene The scene we are intending to draw
  73970. * @param mesh The mesh the effect is compiling for
  73971. * @param defines The defines to update
  73972. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73973. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73974. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73975. * @returns true if normals will be required for the rest of the effect
  73976. */
  73977. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73978. /**
  73979. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73980. * @param lightIndex defines the light index
  73981. * @param uniformsList The uniform list
  73982. * @param samplersList The sampler list
  73983. * @param projectedLightTexture defines if projected texture must be used
  73984. * @param uniformBuffersList defines an optional list of uniform buffers
  73985. */
  73986. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73987. /**
  73988. * Prepares the uniforms and samplers list to be used in the effect
  73989. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73990. * @param samplersList The sampler list
  73991. * @param defines The defines helping in the list generation
  73992. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73993. */
  73994. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73995. /**
  73996. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73997. * @param defines The defines to update while falling back
  73998. * @param fallbacks The authorized effect fallbacks
  73999. * @param maxSimultaneousLights The maximum number of lights allowed
  74000. * @param rank the current rank of the Effect
  74001. * @returns The newly affected rank
  74002. */
  74003. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  74004. private static _TmpMorphInfluencers;
  74005. /**
  74006. * Prepares the list of attributes required for morph targets according to the effect defines.
  74007. * @param attribs The current list of supported attribs
  74008. * @param mesh The mesh to prepare the morph targets attributes for
  74009. * @param influencers The number of influencers
  74010. */
  74011. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  74012. /**
  74013. * Prepares the list of attributes required for morph targets according to the effect defines.
  74014. * @param attribs The current list of supported attribs
  74015. * @param mesh The mesh to prepare the morph targets attributes for
  74016. * @param defines The current Defines of the effect
  74017. */
  74018. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  74019. /**
  74020. * Prepares the list of attributes required for bones according to the effect defines.
  74021. * @param attribs The current list of supported attribs
  74022. * @param mesh The mesh to prepare the bones attributes for
  74023. * @param defines The current Defines of the effect
  74024. * @param fallbacks The current efffect fallback strategy
  74025. */
  74026. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  74027. /**
  74028. * Check and prepare the list of attributes required for instances according to the effect defines.
  74029. * @param attribs The current list of supported attribs
  74030. * @param defines The current MaterialDefines of the effect
  74031. */
  74032. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  74033. /**
  74034. * Add the list of attributes required for instances to the attribs array.
  74035. * @param attribs The current list of supported attribs
  74036. */
  74037. static PushAttributesForInstances(attribs: string[]): void;
  74038. /**
  74039. * Binds the light shadow information to the effect for the given mesh.
  74040. * @param light The light containing the generator
  74041. * @param scene The scene the lights belongs to
  74042. * @param mesh The mesh we are binding the information to render
  74043. * @param lightIndex The light index in the effect used to render the mesh
  74044. * @param effect The effect we are binding the data to
  74045. */
  74046. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74047. /**
  74048. * Binds the light information to the effect.
  74049. * @param light The light containing the generator
  74050. * @param effect The effect we are binding the data to
  74051. * @param lightIndex The light index in the effect used to render
  74052. */
  74053. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74054. /**
  74055. * Binds the lights information from the scene to the effect for the given mesh.
  74056. * @param light Light to bind
  74057. * @param lightIndex Light index
  74058. * @param scene The scene where the light belongs to
  74059. * @param mesh The mesh we are binding the information to render
  74060. * @param effect The effect we are binding the data to
  74061. * @param useSpecular Defines if specular is supported
  74062. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74063. */
  74064. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  74065. /**
  74066. * Binds the lights information from the scene to the effect for the given mesh.
  74067. * @param scene The scene the lights belongs to
  74068. * @param mesh The mesh we are binding the information to render
  74069. * @param effect The effect we are binding the data to
  74070. * @param defines The generated defines for the effect
  74071. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74072. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74073. */
  74074. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  74075. private static _tempFogColor;
  74076. /**
  74077. * Binds the fog information from the scene to the effect for the given mesh.
  74078. * @param scene The scene the lights belongs to
  74079. * @param mesh The mesh we are binding the information to render
  74080. * @param effect The effect we are binding the data to
  74081. * @param linearSpace Defines if the fog effect is applied in linear space
  74082. */
  74083. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74084. /**
  74085. * Binds the bones information from the mesh to the effect.
  74086. * @param mesh The mesh we are binding the information to render
  74087. * @param effect The effect we are binding the data to
  74088. */
  74089. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74090. /**
  74091. * Binds the morph targets information from the mesh to the effect.
  74092. * @param abstractMesh The mesh we are binding the information to render
  74093. * @param effect The effect we are binding the data to
  74094. */
  74095. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74096. /**
  74097. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74098. * @param defines The generated defines used in the effect
  74099. * @param effect The effect we are binding the data to
  74100. * @param scene The scene we are willing to render with logarithmic scale for
  74101. */
  74102. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74103. /**
  74104. * Binds the clip plane information from the scene to the effect.
  74105. * @param scene The scene the clip plane information are extracted from
  74106. * @param effect The effect we are binding the data to
  74107. */
  74108. static BindClipPlane(effect: Effect, scene: Scene): void;
  74109. }
  74110. }
  74111. declare module BABYLON {
  74112. /** @hidden */
  74113. export var shadowMapPixelShader: {
  74114. name: string;
  74115. shader: string;
  74116. };
  74117. }
  74118. declare module BABYLON {
  74119. /** @hidden */
  74120. export var bonesDeclaration: {
  74121. name: string;
  74122. shader: string;
  74123. };
  74124. }
  74125. declare module BABYLON {
  74126. /** @hidden */
  74127. export var morphTargetsVertexGlobalDeclaration: {
  74128. name: string;
  74129. shader: string;
  74130. };
  74131. }
  74132. declare module BABYLON {
  74133. /** @hidden */
  74134. export var morphTargetsVertexDeclaration: {
  74135. name: string;
  74136. shader: string;
  74137. };
  74138. }
  74139. declare module BABYLON {
  74140. /** @hidden */
  74141. export var instancesDeclaration: {
  74142. name: string;
  74143. shader: string;
  74144. };
  74145. }
  74146. declare module BABYLON {
  74147. /** @hidden */
  74148. export var helperFunctions: {
  74149. name: string;
  74150. shader: string;
  74151. };
  74152. }
  74153. declare module BABYLON {
  74154. /** @hidden */
  74155. export var morphTargetsVertex: {
  74156. name: string;
  74157. shader: string;
  74158. };
  74159. }
  74160. declare module BABYLON {
  74161. /** @hidden */
  74162. export var instancesVertex: {
  74163. name: string;
  74164. shader: string;
  74165. };
  74166. }
  74167. declare module BABYLON {
  74168. /** @hidden */
  74169. export var bonesVertex: {
  74170. name: string;
  74171. shader: string;
  74172. };
  74173. }
  74174. declare module BABYLON {
  74175. /** @hidden */
  74176. export var shadowMapVertexShader: {
  74177. name: string;
  74178. shader: string;
  74179. };
  74180. }
  74181. declare module BABYLON {
  74182. /** @hidden */
  74183. export var depthBoxBlurPixelShader: {
  74184. name: string;
  74185. shader: string;
  74186. };
  74187. }
  74188. declare module BABYLON {
  74189. /**
  74190. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74191. */
  74192. export interface ICustomShaderOptions {
  74193. /**
  74194. * Gets or sets the custom shader name to use
  74195. */
  74196. shaderName: string;
  74197. /**
  74198. * The list of attribute names used in the shader
  74199. */
  74200. attributes?: string[];
  74201. /**
  74202. * The list of unifrom names used in the shader
  74203. */
  74204. uniforms?: string[];
  74205. /**
  74206. * The list of sampler names used in the shader
  74207. */
  74208. samplers?: string[];
  74209. /**
  74210. * The list of defines used in the shader
  74211. */
  74212. defines?: string[];
  74213. }
  74214. /**
  74215. * Interface to implement to create a shadow generator compatible with BJS.
  74216. */
  74217. export interface IShadowGenerator {
  74218. /**
  74219. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74220. * @returns The render target texture if present otherwise, null
  74221. */
  74222. getShadowMap(): Nullable<RenderTargetTexture>;
  74223. /**
  74224. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74225. * @returns The render target texture if the shadow map is present otherwise, null
  74226. */
  74227. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74228. /**
  74229. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74230. * @param subMesh The submesh we want to render in the shadow map
  74231. * @param useInstances Defines wether will draw in the map using instances
  74232. * @returns true if ready otherwise, false
  74233. */
  74234. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74235. /**
  74236. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74237. * @param defines Defines of the material we want to update
  74238. * @param lightIndex Index of the light in the enabled light list of the material
  74239. */
  74240. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74241. /**
  74242. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74243. * defined in the generator but impacting the effect).
  74244. * It implies the unifroms available on the materials are the standard BJS ones.
  74245. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74246. * @param effect The effect we are binfing the information for
  74247. */
  74248. bindShadowLight(lightIndex: string, effect: Effect): void;
  74249. /**
  74250. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74251. * (eq to shadow prjection matrix * light transform matrix)
  74252. * @returns The transform matrix used to create the shadow map
  74253. */
  74254. getTransformMatrix(): Matrix;
  74255. /**
  74256. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74257. * Cube and 2D textures for instance.
  74258. */
  74259. recreateShadowMap(): void;
  74260. /**
  74261. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74262. * @param onCompiled Callback triggered at the and of the effects compilation
  74263. * @param options Sets of optional options forcing the compilation with different modes
  74264. */
  74265. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74266. useInstances: boolean;
  74267. }>): void;
  74268. /**
  74269. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74270. * @param options Sets of optional options forcing the compilation with different modes
  74271. * @returns A promise that resolves when the compilation completes
  74272. */
  74273. forceCompilationAsync(options?: Partial<{
  74274. useInstances: boolean;
  74275. }>): Promise<void>;
  74276. /**
  74277. * Serializes the shadow generator setup to a json object.
  74278. * @returns The serialized JSON object
  74279. */
  74280. serialize(): any;
  74281. /**
  74282. * Disposes the Shadow map and related Textures and effects.
  74283. */
  74284. dispose(): void;
  74285. }
  74286. /**
  74287. * Default implementation IShadowGenerator.
  74288. * This is the main object responsible of generating shadows in the framework.
  74289. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74290. */
  74291. export class ShadowGenerator implements IShadowGenerator {
  74292. /**
  74293. * Shadow generator mode None: no filtering applied.
  74294. */
  74295. static readonly FILTER_NONE: number;
  74296. /**
  74297. * Shadow generator mode ESM: Exponential Shadow Mapping.
  74298. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74299. */
  74300. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  74301. /**
  74302. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  74303. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  74304. */
  74305. static readonly FILTER_POISSONSAMPLING: number;
  74306. /**
  74307. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74308. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74309. */
  74310. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74311. /**
  74312. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74313. * edge artifacts on steep falloff.
  74314. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74315. */
  74316. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74317. /**
  74318. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  74319. * edge artifacts on steep falloff.
  74320. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74321. */
  74322. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  74323. /**
  74324. * Shadow generator mode PCF: Percentage Closer Filtering
  74325. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74326. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  74327. */
  74328. static readonly FILTER_PCF: number;
  74329. /**
  74330. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  74331. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74332. * Contact Hardening
  74333. */
  74334. static readonly FILTER_PCSS: number;
  74335. /**
  74336. * Reserved for PCF and PCSS
  74337. * Highest Quality.
  74338. *
  74339. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  74340. *
  74341. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  74342. */
  74343. static readonly QUALITY_HIGH: number;
  74344. /**
  74345. * Reserved for PCF and PCSS
  74346. * Good tradeoff for quality/perf cross devices
  74347. *
  74348. * Execute PCF on a 3*3 kernel.
  74349. *
  74350. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  74351. */
  74352. static readonly QUALITY_MEDIUM: number;
  74353. /**
  74354. * Reserved for PCF and PCSS
  74355. * The lowest quality but the fastest.
  74356. *
  74357. * Execute PCF on a 1*1 kernel.
  74358. *
  74359. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  74360. */
  74361. static readonly QUALITY_LOW: number;
  74362. /** Gets or sets the custom shader name to use */
  74363. customShaderOptions: ICustomShaderOptions;
  74364. /**
  74365. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  74366. */
  74367. onBeforeShadowMapRenderObservable: Observable<Effect>;
  74368. /**
  74369. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74370. */
  74371. onAfterShadowMapRenderObservable: Observable<Effect>;
  74372. /**
  74373. * Observable triggered before a mesh is rendered in the shadow map.
  74374. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74375. */
  74376. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74377. /**
  74378. * Observable triggered after a mesh is rendered in the shadow map.
  74379. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  74380. */
  74381. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  74382. private _bias;
  74383. /**
  74384. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  74385. */
  74386. /**
  74387. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  74388. */
  74389. bias: number;
  74390. private _normalBias;
  74391. /**
  74392. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74393. */
  74394. /**
  74395. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74396. */
  74397. normalBias: number;
  74398. private _blurBoxOffset;
  74399. /**
  74400. * Gets the blur box offset: offset applied during the blur pass.
  74401. * Only useful if useKernelBlur = false
  74402. */
  74403. /**
  74404. * Sets the blur box offset: offset applied during the blur pass.
  74405. * Only useful if useKernelBlur = false
  74406. */
  74407. blurBoxOffset: number;
  74408. private _blurScale;
  74409. /**
  74410. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74411. * 2 means half of the size.
  74412. */
  74413. /**
  74414. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74415. * 2 means half of the size.
  74416. */
  74417. blurScale: number;
  74418. private _blurKernel;
  74419. /**
  74420. * Gets the blur kernel: kernel size of the blur pass.
  74421. * Only useful if useKernelBlur = true
  74422. */
  74423. /**
  74424. * Sets the blur kernel: kernel size of the blur pass.
  74425. * Only useful if useKernelBlur = true
  74426. */
  74427. blurKernel: number;
  74428. private _useKernelBlur;
  74429. /**
  74430. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74431. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74432. */
  74433. /**
  74434. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74435. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74436. */
  74437. useKernelBlur: boolean;
  74438. private _depthScale;
  74439. /**
  74440. * Gets the depth scale used in ESM mode.
  74441. */
  74442. /**
  74443. * Sets the depth scale used in ESM mode.
  74444. * This can override the scale stored on the light.
  74445. */
  74446. depthScale: number;
  74447. private _filter;
  74448. /**
  74449. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74450. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74451. */
  74452. /**
  74453. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74454. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74455. */
  74456. filter: number;
  74457. /**
  74458. * Gets if the current filter is set to Poisson Sampling.
  74459. */
  74460. /**
  74461. * Sets the current filter to Poisson Sampling.
  74462. */
  74463. usePoissonSampling: boolean;
  74464. /**
  74465. * Gets if the current filter is set to ESM.
  74466. */
  74467. /**
  74468. * Sets the current filter is to ESM.
  74469. */
  74470. useExponentialShadowMap: boolean;
  74471. /**
  74472. * Gets if the current filter is set to filtered ESM.
  74473. */
  74474. /**
  74475. * Gets if the current filter is set to filtered ESM.
  74476. */
  74477. useBlurExponentialShadowMap: boolean;
  74478. /**
  74479. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74480. * exponential to prevent steep falloff artifacts).
  74481. */
  74482. /**
  74483. * Sets the current filter to "close ESM" (using the inverse of the
  74484. * exponential to prevent steep falloff artifacts).
  74485. */
  74486. useCloseExponentialShadowMap: boolean;
  74487. /**
  74488. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74489. * exponential to prevent steep falloff artifacts).
  74490. */
  74491. /**
  74492. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74493. * exponential to prevent steep falloff artifacts).
  74494. */
  74495. useBlurCloseExponentialShadowMap: boolean;
  74496. /**
  74497. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74498. */
  74499. /**
  74500. * Sets the current filter to "PCF" (percentage closer filtering).
  74501. */
  74502. usePercentageCloserFiltering: boolean;
  74503. private _filteringQuality;
  74504. /**
  74505. * Gets the PCF or PCSS Quality.
  74506. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74507. */
  74508. /**
  74509. * Sets the PCF or PCSS Quality.
  74510. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74511. */
  74512. filteringQuality: number;
  74513. /**
  74514. * Gets if the current filter is set to "PCSS" (contact hardening).
  74515. */
  74516. /**
  74517. * Sets the current filter to "PCSS" (contact hardening).
  74518. */
  74519. useContactHardeningShadow: boolean;
  74520. private _contactHardeningLightSizeUVRatio;
  74521. /**
  74522. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74523. * Using a ratio helps keeping shape stability independently of the map size.
  74524. *
  74525. * It does not account for the light projection as it was having too much
  74526. * instability during the light setup or during light position changes.
  74527. *
  74528. * Only valid if useContactHardeningShadow is true.
  74529. */
  74530. /**
  74531. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74532. * Using a ratio helps keeping shape stability independently of the map size.
  74533. *
  74534. * It does not account for the light projection as it was having too much
  74535. * instability during the light setup or during light position changes.
  74536. *
  74537. * Only valid if useContactHardeningShadow is true.
  74538. */
  74539. contactHardeningLightSizeUVRatio: number;
  74540. private _darkness;
  74541. /** Gets or sets the actual darkness of a shadow */
  74542. darkness: number;
  74543. /**
  74544. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74545. * 0 means strongest and 1 would means no shadow.
  74546. * @returns the darkness.
  74547. */
  74548. getDarkness(): number;
  74549. /**
  74550. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74551. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74552. * @returns the shadow generator allowing fluent coding.
  74553. */
  74554. setDarkness(darkness: number): ShadowGenerator;
  74555. private _transparencyShadow;
  74556. /** Gets or sets the ability to have transparent shadow */
  74557. transparencyShadow: boolean;
  74558. /**
  74559. * Sets the ability to have transparent shadow (boolean).
  74560. * @param transparent True if transparent else False
  74561. * @returns the shadow generator allowing fluent coding
  74562. */
  74563. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74564. private _shadowMap;
  74565. private _shadowMap2;
  74566. /**
  74567. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74568. * @returns The render target texture if present otherwise, null
  74569. */
  74570. getShadowMap(): Nullable<RenderTargetTexture>;
  74571. /**
  74572. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74573. * @returns The render target texture if the shadow map is present otherwise, null
  74574. */
  74575. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74576. /**
  74577. * Gets the class name of that object
  74578. * @returns "ShadowGenerator"
  74579. */
  74580. getClassName(): string;
  74581. /**
  74582. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74583. * @param mesh Mesh to add
  74584. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74585. * @returns the Shadow Generator itself
  74586. */
  74587. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74588. /**
  74589. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74590. * @param mesh Mesh to remove
  74591. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74592. * @returns the Shadow Generator itself
  74593. */
  74594. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74595. /**
  74596. * Controls the extent to which the shadows fade out at the edge of the frustum
  74597. * Used only by directionals and spots
  74598. */
  74599. frustumEdgeFalloff: number;
  74600. private _light;
  74601. /**
  74602. * Returns the associated light object.
  74603. * @returns the light generating the shadow
  74604. */
  74605. getLight(): IShadowLight;
  74606. /**
  74607. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74608. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74609. * It might on the other hand introduce peter panning.
  74610. */
  74611. forceBackFacesOnly: boolean;
  74612. private _scene;
  74613. private _lightDirection;
  74614. private _effect;
  74615. private _viewMatrix;
  74616. private _projectionMatrix;
  74617. private _transformMatrix;
  74618. private _cachedPosition;
  74619. private _cachedDirection;
  74620. private _cachedDefines;
  74621. private _currentRenderID;
  74622. private _boxBlurPostprocess;
  74623. private _kernelBlurXPostprocess;
  74624. private _kernelBlurYPostprocess;
  74625. private _blurPostProcesses;
  74626. private _mapSize;
  74627. private _currentFaceIndex;
  74628. private _currentFaceIndexCache;
  74629. private _textureType;
  74630. private _defaultTextureMatrix;
  74631. /** @hidden */
  74632. static _SceneComponentInitialization: (scene: Scene) => void;
  74633. /**
  74634. * Creates a ShadowGenerator object.
  74635. * A ShadowGenerator is the required tool to use the shadows.
  74636. * Each light casting shadows needs to use its own ShadowGenerator.
  74637. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74638. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74639. * @param light The light object generating the shadows.
  74640. * @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.
  74641. */
  74642. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74643. private _initializeGenerator;
  74644. private _initializeShadowMap;
  74645. private _initializeBlurRTTAndPostProcesses;
  74646. private _renderForShadowMap;
  74647. private _renderSubMeshForShadowMap;
  74648. private _applyFilterValues;
  74649. /**
  74650. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74651. * @param onCompiled Callback triggered at the and of the effects compilation
  74652. * @param options Sets of optional options forcing the compilation with different modes
  74653. */
  74654. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74655. useInstances: boolean;
  74656. }>): void;
  74657. /**
  74658. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74659. * @param options Sets of optional options forcing the compilation with different modes
  74660. * @returns A promise that resolves when the compilation completes
  74661. */
  74662. forceCompilationAsync(options?: Partial<{
  74663. useInstances: boolean;
  74664. }>): Promise<void>;
  74665. /**
  74666. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74667. * @param subMesh The submesh we want to render in the shadow map
  74668. * @param useInstances Defines wether will draw in the map using instances
  74669. * @returns true if ready otherwise, false
  74670. */
  74671. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74672. /**
  74673. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74674. * @param defines Defines of the material we want to update
  74675. * @param lightIndex Index of the light in the enabled light list of the material
  74676. */
  74677. prepareDefines(defines: any, lightIndex: number): void;
  74678. /**
  74679. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74680. * defined in the generator but impacting the effect).
  74681. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74682. * @param effect The effect we are binfing the information for
  74683. */
  74684. bindShadowLight(lightIndex: string, effect: Effect): void;
  74685. /**
  74686. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74687. * (eq to shadow prjection matrix * light transform matrix)
  74688. * @returns The transform matrix used to create the shadow map
  74689. */
  74690. getTransformMatrix(): Matrix;
  74691. /**
  74692. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74693. * Cube and 2D textures for instance.
  74694. */
  74695. recreateShadowMap(): void;
  74696. private _disposeBlurPostProcesses;
  74697. private _disposeRTTandPostProcesses;
  74698. /**
  74699. * Disposes the ShadowGenerator.
  74700. * Returns nothing.
  74701. */
  74702. dispose(): void;
  74703. /**
  74704. * Serializes the shadow generator setup to a json object.
  74705. * @returns The serialized JSON object
  74706. */
  74707. serialize(): any;
  74708. /**
  74709. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74710. * @param parsedShadowGenerator The JSON object to parse
  74711. * @param scene The scene to create the shadow map for
  74712. * @returns The parsed shadow generator
  74713. */
  74714. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74715. }
  74716. }
  74717. declare module BABYLON {
  74718. /**
  74719. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74720. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74721. * 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.
  74722. */
  74723. export abstract class Light extends Node {
  74724. /**
  74725. * Falloff Default: light is falling off following the material specification:
  74726. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74727. */
  74728. static readonly FALLOFF_DEFAULT: number;
  74729. /**
  74730. * Falloff Physical: light is falling off following the inverse squared distance law.
  74731. */
  74732. static readonly FALLOFF_PHYSICAL: number;
  74733. /**
  74734. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74735. * to enhance interoperability with other engines.
  74736. */
  74737. static readonly FALLOFF_GLTF: number;
  74738. /**
  74739. * Falloff Standard: light is falling off like in the standard material
  74740. * to enhance interoperability with other materials.
  74741. */
  74742. static readonly FALLOFF_STANDARD: number;
  74743. /**
  74744. * If every light affecting the material is in this lightmapMode,
  74745. * material.lightmapTexture adds or multiplies
  74746. * (depends on material.useLightmapAsShadowmap)
  74747. * after every other light calculations.
  74748. */
  74749. static readonly LIGHTMAP_DEFAULT: number;
  74750. /**
  74751. * material.lightmapTexture as only diffuse lighting from this light
  74752. * adds only specular lighting from this light
  74753. * adds dynamic shadows
  74754. */
  74755. static readonly LIGHTMAP_SPECULAR: number;
  74756. /**
  74757. * material.lightmapTexture as only lighting
  74758. * no light calculation from this light
  74759. * only adds dynamic shadows from this light
  74760. */
  74761. static readonly LIGHTMAP_SHADOWSONLY: number;
  74762. /**
  74763. * Each light type uses the default quantity according to its type:
  74764. * point/spot lights use luminous intensity
  74765. * directional lights use illuminance
  74766. */
  74767. static readonly INTENSITYMODE_AUTOMATIC: number;
  74768. /**
  74769. * lumen (lm)
  74770. */
  74771. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74772. /**
  74773. * candela (lm/sr)
  74774. */
  74775. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74776. /**
  74777. * lux (lm/m^2)
  74778. */
  74779. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74780. /**
  74781. * nit (cd/m^2)
  74782. */
  74783. static readonly INTENSITYMODE_LUMINANCE: number;
  74784. /**
  74785. * Light type const id of the point light.
  74786. */
  74787. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74788. /**
  74789. * Light type const id of the directional light.
  74790. */
  74791. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74792. /**
  74793. * Light type const id of the spot light.
  74794. */
  74795. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74796. /**
  74797. * Light type const id of the hemispheric light.
  74798. */
  74799. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74800. /**
  74801. * Diffuse gives the basic color to an object.
  74802. */
  74803. diffuse: Color3;
  74804. /**
  74805. * Specular produces a highlight color on an object.
  74806. * Note: This is note affecting PBR materials.
  74807. */
  74808. specular: Color3;
  74809. /**
  74810. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74811. * falling off base on range or angle.
  74812. * This can be set to any values in Light.FALLOFF_x.
  74813. *
  74814. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74815. * other types of materials.
  74816. */
  74817. falloffType: number;
  74818. /**
  74819. * Strength of the light.
  74820. * Note: By default it is define in the framework own unit.
  74821. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74822. */
  74823. intensity: number;
  74824. private _range;
  74825. protected _inverseSquaredRange: number;
  74826. /**
  74827. * Defines how far from the source the light is impacting in scene units.
  74828. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74829. */
  74830. /**
  74831. * Defines how far from the source the light is impacting in scene units.
  74832. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74833. */
  74834. range: number;
  74835. /**
  74836. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74837. * of light.
  74838. */
  74839. private _photometricScale;
  74840. private _intensityMode;
  74841. /**
  74842. * Gets the photometric scale used to interpret the intensity.
  74843. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74844. */
  74845. /**
  74846. * Sets the photometric scale used to interpret the intensity.
  74847. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74848. */
  74849. intensityMode: number;
  74850. private _radius;
  74851. /**
  74852. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74853. */
  74854. /**
  74855. * sets the light radius used by PBR Materials to simulate soft area lights.
  74856. */
  74857. radius: number;
  74858. private _renderPriority;
  74859. /**
  74860. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74861. * exceeding the number allowed of the materials.
  74862. */
  74863. renderPriority: number;
  74864. private _shadowEnabled;
  74865. /**
  74866. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74867. * the current shadow generator.
  74868. */
  74869. /**
  74870. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74871. * the current shadow generator.
  74872. */
  74873. shadowEnabled: boolean;
  74874. private _includedOnlyMeshes;
  74875. /**
  74876. * Gets the only meshes impacted by this light.
  74877. */
  74878. /**
  74879. * Sets the only meshes impacted by this light.
  74880. */
  74881. includedOnlyMeshes: AbstractMesh[];
  74882. private _excludedMeshes;
  74883. /**
  74884. * Gets the meshes not impacted by this light.
  74885. */
  74886. /**
  74887. * Sets the meshes not impacted by this light.
  74888. */
  74889. excludedMeshes: AbstractMesh[];
  74890. private _excludeWithLayerMask;
  74891. /**
  74892. * Gets the layer id use to find what meshes are not impacted by the light.
  74893. * Inactive if 0
  74894. */
  74895. /**
  74896. * Sets the layer id use to find what meshes are not impacted by the light.
  74897. * Inactive if 0
  74898. */
  74899. excludeWithLayerMask: number;
  74900. private _includeOnlyWithLayerMask;
  74901. /**
  74902. * Gets the layer id use to find what meshes are impacted by the light.
  74903. * Inactive if 0
  74904. */
  74905. /**
  74906. * Sets the layer id use to find what meshes are impacted by the light.
  74907. * Inactive if 0
  74908. */
  74909. includeOnlyWithLayerMask: number;
  74910. private _lightmapMode;
  74911. /**
  74912. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74913. */
  74914. /**
  74915. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74916. */
  74917. lightmapMode: number;
  74918. /**
  74919. * Shadow generator associted to the light.
  74920. * @hidden Internal use only.
  74921. */
  74922. _shadowGenerator: Nullable<IShadowGenerator>;
  74923. /**
  74924. * @hidden Internal use only.
  74925. */
  74926. _excludedMeshesIds: string[];
  74927. /**
  74928. * @hidden Internal use only.
  74929. */
  74930. _includedOnlyMeshesIds: string[];
  74931. /**
  74932. * The current light unifom buffer.
  74933. * @hidden Internal use only.
  74934. */
  74935. _uniformBuffer: UniformBuffer;
  74936. /**
  74937. * Creates a Light object in the scene.
  74938. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74939. * @param name The firendly name of the light
  74940. * @param scene The scene the light belongs too
  74941. */
  74942. constructor(name: string, scene: Scene);
  74943. protected abstract _buildUniformLayout(): void;
  74944. /**
  74945. * Sets the passed Effect "effect" with the Light information.
  74946. * @param effect The effect to update
  74947. * @param lightIndex The index of the light in the effect to update
  74948. * @returns The light
  74949. */
  74950. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74951. /**
  74952. * Returns the string "Light".
  74953. * @returns the class name
  74954. */
  74955. getClassName(): string;
  74956. /** @hidden */
  74957. readonly _isLight: boolean;
  74958. /**
  74959. * Converts the light information to a readable string for debug purpose.
  74960. * @param fullDetails Supports for multiple levels of logging within scene loading
  74961. * @returns the human readable light info
  74962. */
  74963. toString(fullDetails?: boolean): string;
  74964. /** @hidden */
  74965. protected _syncParentEnabledState(): void;
  74966. /**
  74967. * Set the enabled state of this node.
  74968. * @param value - the new enabled state
  74969. */
  74970. setEnabled(value: boolean): void;
  74971. /**
  74972. * Returns the Light associated shadow generator if any.
  74973. * @return the associated shadow generator.
  74974. */
  74975. getShadowGenerator(): Nullable<IShadowGenerator>;
  74976. /**
  74977. * Returns a Vector3, the absolute light position in the World.
  74978. * @returns the world space position of the light
  74979. */
  74980. getAbsolutePosition(): Vector3;
  74981. /**
  74982. * Specifies if the light will affect the passed mesh.
  74983. * @param mesh The mesh to test against the light
  74984. * @return true the mesh is affected otherwise, false.
  74985. */
  74986. canAffectMesh(mesh: AbstractMesh): boolean;
  74987. /**
  74988. * Sort function to order lights for rendering.
  74989. * @param a First Light object to compare to second.
  74990. * @param b Second Light object to compare first.
  74991. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74992. */
  74993. static CompareLightsPriority(a: Light, b: Light): number;
  74994. /**
  74995. * Releases resources associated with this node.
  74996. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74997. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74998. */
  74999. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75000. /**
  75001. * Returns the light type ID (integer).
  75002. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75003. */
  75004. getTypeID(): number;
  75005. /**
  75006. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  75007. * @returns the scaled intensity in intensity mode unit
  75008. */
  75009. getScaledIntensity(): number;
  75010. /**
  75011. * Returns a new Light object, named "name", from the current one.
  75012. * @param name The name of the cloned light
  75013. * @returns the new created light
  75014. */
  75015. clone(name: string): Nullable<Light>;
  75016. /**
  75017. * Serializes the current light into a Serialization object.
  75018. * @returns the serialized object.
  75019. */
  75020. serialize(): any;
  75021. /**
  75022. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  75023. * This new light is named "name" and added to the passed scene.
  75024. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75025. * @param name The friendly name of the light
  75026. * @param scene The scene the new light will belong to
  75027. * @returns the constructor function
  75028. */
  75029. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75030. /**
  75031. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75032. * @param parsedLight The JSON representation of the light
  75033. * @param scene The scene to create the parsed light in
  75034. * @returns the created light after parsing
  75035. */
  75036. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75037. private _hookArrayForExcluded;
  75038. private _hookArrayForIncludedOnly;
  75039. private _resyncMeshes;
  75040. /**
  75041. * Forces the meshes to update their light related information in their rendering used effects
  75042. * @hidden Internal Use Only
  75043. */
  75044. _markMeshesAsLightDirty(): void;
  75045. /**
  75046. * Recomputes the cached photometric scale if needed.
  75047. */
  75048. private _computePhotometricScale;
  75049. /**
  75050. * Returns the Photometric Scale according to the light type and intensity mode.
  75051. */
  75052. private _getPhotometricScale;
  75053. /**
  75054. * Reorder the light in the scene according to their defined priority.
  75055. * @hidden Internal Use Only
  75056. */
  75057. _reorderLightsInScene(): void;
  75058. /**
  75059. * Prepares the list of defines specific to the light type.
  75060. * @param defines the list of defines
  75061. * @param lightIndex defines the index of the light for the effect
  75062. */
  75063. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75064. }
  75065. }
  75066. declare module BABYLON {
  75067. /**
  75068. * Creates an instance based on a source mesh.
  75069. */
  75070. export class InstancedMesh extends AbstractMesh {
  75071. private _sourceMesh;
  75072. private _currentLOD;
  75073. /** @hidden */
  75074. _indexInSourceMeshInstanceArray: number;
  75075. constructor(name: string, source: Mesh);
  75076. /**
  75077. * Returns the string "InstancedMesh".
  75078. */
  75079. getClassName(): string;
  75080. /** Gets the list of lights affecting that mesh */
  75081. readonly lightSources: Light[];
  75082. _resyncLightSources(): void;
  75083. _resyncLighSource(light: Light): void;
  75084. _removeLightSource(light: Light): void;
  75085. /**
  75086. * If the source mesh receives shadows
  75087. */
  75088. readonly receiveShadows: boolean;
  75089. /**
  75090. * The material of the source mesh
  75091. */
  75092. readonly material: Nullable<Material>;
  75093. /**
  75094. * Visibility of the source mesh
  75095. */
  75096. readonly visibility: number;
  75097. /**
  75098. * Skeleton of the source mesh
  75099. */
  75100. readonly skeleton: Nullable<Skeleton>;
  75101. /**
  75102. * Rendering ground id of the source mesh
  75103. */
  75104. renderingGroupId: number;
  75105. /**
  75106. * Returns the total number of vertices (integer).
  75107. */
  75108. getTotalVertices(): number;
  75109. /**
  75110. * Returns a positive integer : the total number of indices in this mesh geometry.
  75111. * @returns the numner of indices or zero if the mesh has no geometry.
  75112. */
  75113. getTotalIndices(): number;
  75114. /**
  75115. * The source mesh of the instance
  75116. */
  75117. readonly sourceMesh: Mesh;
  75118. /**
  75119. * Is this node ready to be used/rendered
  75120. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75121. * @return {boolean} is it ready
  75122. */
  75123. isReady(completeCheck?: boolean): boolean;
  75124. /**
  75125. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75126. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75127. * @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.
  75128. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75129. */
  75130. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75131. /**
  75132. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75133. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75134. * The `data` are either a numeric array either a Float32Array.
  75135. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75136. * 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).
  75137. * Note that a new underlying VertexBuffer object is created each call.
  75138. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75139. *
  75140. * Possible `kind` values :
  75141. * - VertexBuffer.PositionKind
  75142. * - VertexBuffer.UVKind
  75143. * - VertexBuffer.UV2Kind
  75144. * - VertexBuffer.UV3Kind
  75145. * - VertexBuffer.UV4Kind
  75146. * - VertexBuffer.UV5Kind
  75147. * - VertexBuffer.UV6Kind
  75148. * - VertexBuffer.ColorKind
  75149. * - VertexBuffer.MatricesIndicesKind
  75150. * - VertexBuffer.MatricesIndicesExtraKind
  75151. * - VertexBuffer.MatricesWeightsKind
  75152. * - VertexBuffer.MatricesWeightsExtraKind
  75153. *
  75154. * Returns the Mesh.
  75155. */
  75156. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75157. /**
  75158. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75159. * If the mesh has no geometry, it is simply returned as it is.
  75160. * The `data` are either a numeric array either a Float32Array.
  75161. * No new underlying VertexBuffer object is created.
  75162. * 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.
  75163. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75164. *
  75165. * Possible `kind` values :
  75166. * - VertexBuffer.PositionKind
  75167. * - VertexBuffer.UVKind
  75168. * - VertexBuffer.UV2Kind
  75169. * - VertexBuffer.UV3Kind
  75170. * - VertexBuffer.UV4Kind
  75171. * - VertexBuffer.UV5Kind
  75172. * - VertexBuffer.UV6Kind
  75173. * - VertexBuffer.ColorKind
  75174. * - VertexBuffer.MatricesIndicesKind
  75175. * - VertexBuffer.MatricesIndicesExtraKind
  75176. * - VertexBuffer.MatricesWeightsKind
  75177. * - VertexBuffer.MatricesWeightsExtraKind
  75178. *
  75179. * Returns the Mesh.
  75180. */
  75181. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75182. /**
  75183. * Sets the mesh indices.
  75184. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  75185. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75186. * This method creates a new index buffer each call.
  75187. * Returns the Mesh.
  75188. */
  75189. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  75190. /**
  75191. * Boolean : True if the mesh owns the requested kind of data.
  75192. */
  75193. isVerticesDataPresent(kind: string): boolean;
  75194. /**
  75195. * Returns an array of indices (IndicesArray).
  75196. */
  75197. getIndices(): Nullable<IndicesArray>;
  75198. readonly _positions: Nullable<Vector3[]>;
  75199. /**
  75200. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75201. * This means the mesh underlying bounding box and sphere are recomputed.
  75202. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75203. * @returns the current mesh
  75204. */
  75205. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  75206. /** @hidden */
  75207. _preActivate(): InstancedMesh;
  75208. /** @hidden */
  75209. _activate(renderId: number, intermediateRendering: boolean): boolean;
  75210. /** @hidden */
  75211. _postActivate(): void;
  75212. getWorldMatrix(): Matrix;
  75213. readonly isAnInstance: boolean;
  75214. /**
  75215. * Returns the current associated LOD AbstractMesh.
  75216. */
  75217. getLOD(camera: Camera): AbstractMesh;
  75218. /** @hidden */
  75219. _syncSubMeshes(): InstancedMesh;
  75220. /** @hidden */
  75221. _generatePointsArray(): boolean;
  75222. /**
  75223. * Creates a new InstancedMesh from the current mesh.
  75224. * - name (string) : the cloned mesh name
  75225. * - newParent (optional Node) : the optional Node to parent the clone to.
  75226. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  75227. *
  75228. * Returns the clone.
  75229. */
  75230. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  75231. /**
  75232. * Disposes the InstancedMesh.
  75233. * Returns nothing.
  75234. */
  75235. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75236. }
  75237. }
  75238. declare module BABYLON {
  75239. /**
  75240. * Defines the options associated with the creation of a shader material.
  75241. */
  75242. export interface IShaderMaterialOptions {
  75243. /**
  75244. * Does the material work in alpha blend mode
  75245. */
  75246. needAlphaBlending: boolean;
  75247. /**
  75248. * Does the material work in alpha test mode
  75249. */
  75250. needAlphaTesting: boolean;
  75251. /**
  75252. * The list of attribute names used in the shader
  75253. */
  75254. attributes: string[];
  75255. /**
  75256. * The list of unifrom names used in the shader
  75257. */
  75258. uniforms: string[];
  75259. /**
  75260. * The list of UBO names used in the shader
  75261. */
  75262. uniformBuffers: string[];
  75263. /**
  75264. * The list of sampler names used in the shader
  75265. */
  75266. samplers: string[];
  75267. /**
  75268. * The list of defines used in the shader
  75269. */
  75270. defines: string[];
  75271. }
  75272. /**
  75273. * 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.
  75274. *
  75275. * This returned material effects how the mesh will look based on the code in the shaders.
  75276. *
  75277. * @see http://doc.babylonjs.com/how_to/shader_material
  75278. */
  75279. export class ShaderMaterial extends Material {
  75280. private _shaderPath;
  75281. private _options;
  75282. private _textures;
  75283. private _textureArrays;
  75284. private _floats;
  75285. private _ints;
  75286. private _floatsArrays;
  75287. private _colors3;
  75288. private _colors3Arrays;
  75289. private _colors4;
  75290. private _colors4Arrays;
  75291. private _vectors2;
  75292. private _vectors3;
  75293. private _vectors4;
  75294. private _matrices;
  75295. private _matrices3x3;
  75296. private _matrices2x2;
  75297. private _vectors2Arrays;
  75298. private _vectors3Arrays;
  75299. private _vectors4Arrays;
  75300. private _cachedWorldViewMatrix;
  75301. private _cachedWorldViewProjectionMatrix;
  75302. private _renderId;
  75303. /**
  75304. * Instantiate a new shader material.
  75305. * 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.
  75306. * This returned material effects how the mesh will look based on the code in the shaders.
  75307. * @see http://doc.babylonjs.com/how_to/shader_material
  75308. * @param name Define the name of the material in the scene
  75309. * @param scene Define the scene the material belongs to
  75310. * @param shaderPath Defines the route to the shader code in one of three ways:
  75311. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  75312. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  75313. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  75314. * @param options Define the options used to create the shader
  75315. */
  75316. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  75317. /**
  75318. * Gets the options used to compile the shader.
  75319. * They can be modified to trigger a new compilation
  75320. */
  75321. readonly options: IShaderMaterialOptions;
  75322. /**
  75323. * Gets the current class name of the material e.g. "ShaderMaterial"
  75324. * Mainly use in serialization.
  75325. * @returns the class name
  75326. */
  75327. getClassName(): string;
  75328. /**
  75329. * Specifies if the material will require alpha blending
  75330. * @returns a boolean specifying if alpha blending is needed
  75331. */
  75332. needAlphaBlending(): boolean;
  75333. /**
  75334. * Specifies if this material should be rendered in alpha test mode
  75335. * @returns a boolean specifying if an alpha test is needed.
  75336. */
  75337. needAlphaTesting(): boolean;
  75338. private _checkUniform;
  75339. /**
  75340. * Set a texture in the shader.
  75341. * @param name Define the name of the uniform samplers as defined in the shader
  75342. * @param texture Define the texture to bind to this sampler
  75343. * @return the material itself allowing "fluent" like uniform updates
  75344. */
  75345. setTexture(name: string, texture: Texture): ShaderMaterial;
  75346. /**
  75347. * Set a texture array in the shader.
  75348. * @param name Define the name of the uniform sampler array as defined in the shader
  75349. * @param textures Define the list of textures to bind to this sampler
  75350. * @return the material itself allowing "fluent" like uniform updates
  75351. */
  75352. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75353. /**
  75354. * Set a float in the shader.
  75355. * @param name Define the name of the uniform as defined in the shader
  75356. * @param value Define the value to give to the uniform
  75357. * @return the material itself allowing "fluent" like uniform updates
  75358. */
  75359. setFloat(name: string, value: number): ShaderMaterial;
  75360. /**
  75361. * Set a int in the shader.
  75362. * @param name Define the name of the uniform as defined in the shader
  75363. * @param value Define the value to give to the uniform
  75364. * @return the material itself allowing "fluent" like uniform updates
  75365. */
  75366. setInt(name: string, value: number): ShaderMaterial;
  75367. /**
  75368. * Set an array of floats in the shader.
  75369. * @param name Define the name of the uniform as defined in the shader
  75370. * @param value Define the value to give to the uniform
  75371. * @return the material itself allowing "fluent" like uniform updates
  75372. */
  75373. setFloats(name: string, value: number[]): ShaderMaterial;
  75374. /**
  75375. * Set a vec3 in the shader from a Color3.
  75376. * @param name Define the name of the uniform as defined in the shader
  75377. * @param value Define the value to give to the uniform
  75378. * @return the material itself allowing "fluent" like uniform updates
  75379. */
  75380. setColor3(name: string, value: Color3): ShaderMaterial;
  75381. /**
  75382. * Set a vec3 array in the shader from a Color3 array.
  75383. * @param name Define the name of the uniform as defined in the shader
  75384. * @param value Define the value to give to the uniform
  75385. * @return the material itself allowing "fluent" like uniform updates
  75386. */
  75387. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75388. /**
  75389. * Set a vec4 in the shader from a Color4.
  75390. * @param name Define the name of the uniform as defined in the shader
  75391. * @param value Define the value to give to the uniform
  75392. * @return the material itself allowing "fluent" like uniform updates
  75393. */
  75394. setColor4(name: string, value: Color4): ShaderMaterial;
  75395. /**
  75396. * Set a vec4 array in the shader from a Color4 array.
  75397. * @param name Define the name of the uniform as defined in the shader
  75398. * @param value Define the value to give to the uniform
  75399. * @return the material itself allowing "fluent" like uniform updates
  75400. */
  75401. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  75402. /**
  75403. * Set a vec2 in the shader from a Vector2.
  75404. * @param name Define the name of the uniform as defined in the shader
  75405. * @param value Define the value to give to the uniform
  75406. * @return the material itself allowing "fluent" like uniform updates
  75407. */
  75408. setVector2(name: string, value: Vector2): ShaderMaterial;
  75409. /**
  75410. * Set a vec3 in the shader from a Vector3.
  75411. * @param name Define the name of the uniform as defined in the shader
  75412. * @param value Define the value to give to the uniform
  75413. * @return the material itself allowing "fluent" like uniform updates
  75414. */
  75415. setVector3(name: string, value: Vector3): ShaderMaterial;
  75416. /**
  75417. * Set a vec4 in the shader from a Vector4.
  75418. * @param name Define the name of the uniform as defined in the shader
  75419. * @param value Define the value to give to the uniform
  75420. * @return the material itself allowing "fluent" like uniform updates
  75421. */
  75422. setVector4(name: string, value: Vector4): ShaderMaterial;
  75423. /**
  75424. * Set a mat4 in the shader from a Matrix.
  75425. * @param name Define the name of the uniform as defined in the shader
  75426. * @param value Define the value to give to the uniform
  75427. * @return the material itself allowing "fluent" like uniform updates
  75428. */
  75429. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75430. /**
  75431. * Set a mat3 in the shader from a Float32Array.
  75432. * @param name Define the name of the uniform as defined in the shader
  75433. * @param value Define the value to give to the uniform
  75434. * @return the material itself allowing "fluent" like uniform updates
  75435. */
  75436. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75437. /**
  75438. * Set a mat2 in the shader from a Float32Array.
  75439. * @param name Define the name of the uniform as defined in the shader
  75440. * @param value Define the value to give to the uniform
  75441. * @return the material itself allowing "fluent" like uniform updates
  75442. */
  75443. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75444. /**
  75445. * Set a vec2 array in the shader from a number array.
  75446. * @param name Define the name of the uniform as defined in the shader
  75447. * @param value Define the value to give to the uniform
  75448. * @return the material itself allowing "fluent" like uniform updates
  75449. */
  75450. setArray2(name: string, value: number[]): ShaderMaterial;
  75451. /**
  75452. * Set a vec3 array in the shader from a number array.
  75453. * @param name Define the name of the uniform as defined in the shader
  75454. * @param value Define the value to give to the uniform
  75455. * @return the material itself allowing "fluent" like uniform updates
  75456. */
  75457. setArray3(name: string, value: number[]): ShaderMaterial;
  75458. /**
  75459. * Set a vec4 array in the shader from a number array.
  75460. * @param name Define the name of the uniform as defined in the shader
  75461. * @param value Define the value to give to the uniform
  75462. * @return the material itself allowing "fluent" like uniform updates
  75463. */
  75464. setArray4(name: string, value: number[]): ShaderMaterial;
  75465. private _checkCache;
  75466. /**
  75467. * Specifies that the submesh is ready to be used
  75468. * @param mesh defines the mesh to check
  75469. * @param subMesh defines which submesh to check
  75470. * @param useInstances specifies that instances should be used
  75471. * @returns a boolean indicating that the submesh is ready or not
  75472. */
  75473. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75474. /**
  75475. * Checks if the material is ready to render the requested mesh
  75476. * @param mesh Define the mesh to render
  75477. * @param useInstances Define whether or not the material is used with instances
  75478. * @returns true if ready, otherwise false
  75479. */
  75480. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75481. /**
  75482. * Binds the world matrix to the material
  75483. * @param world defines the world transformation matrix
  75484. */
  75485. bindOnlyWorldMatrix(world: Matrix): void;
  75486. /**
  75487. * Binds the material to the mesh
  75488. * @param world defines the world transformation matrix
  75489. * @param mesh defines the mesh to bind the material to
  75490. */
  75491. bind(world: Matrix, mesh?: Mesh): void;
  75492. /**
  75493. * Gets the active textures from the material
  75494. * @returns an array of textures
  75495. */
  75496. getActiveTextures(): BaseTexture[];
  75497. /**
  75498. * Specifies if the material uses a texture
  75499. * @param texture defines the texture to check against the material
  75500. * @returns a boolean specifying if the material uses the texture
  75501. */
  75502. hasTexture(texture: BaseTexture): boolean;
  75503. /**
  75504. * Makes a duplicate of the material, and gives it a new name
  75505. * @param name defines the new name for the duplicated material
  75506. * @returns the cloned material
  75507. */
  75508. clone(name: string): ShaderMaterial;
  75509. /**
  75510. * Disposes the material
  75511. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75512. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75513. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75514. */
  75515. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75516. /**
  75517. * Serializes this material in a JSON representation
  75518. * @returns the serialized material object
  75519. */
  75520. serialize(): any;
  75521. /**
  75522. * Creates a shader material from parsed shader material data
  75523. * @param source defines the JSON represnetation of the material
  75524. * @param scene defines the hosting scene
  75525. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75526. * @returns a new material
  75527. */
  75528. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75529. }
  75530. }
  75531. declare module BABYLON {
  75532. /** @hidden */
  75533. export var clipPlaneFragmentDeclaration: {
  75534. name: string;
  75535. shader: string;
  75536. };
  75537. }
  75538. declare module BABYLON {
  75539. /** @hidden */
  75540. export var clipPlaneFragment: {
  75541. name: string;
  75542. shader: string;
  75543. };
  75544. }
  75545. declare module BABYLON {
  75546. /** @hidden */
  75547. export var colorPixelShader: {
  75548. name: string;
  75549. shader: string;
  75550. };
  75551. }
  75552. declare module BABYLON {
  75553. /** @hidden */
  75554. export var clipPlaneVertexDeclaration: {
  75555. name: string;
  75556. shader: string;
  75557. };
  75558. }
  75559. declare module BABYLON {
  75560. /** @hidden */
  75561. export var clipPlaneVertex: {
  75562. name: string;
  75563. shader: string;
  75564. };
  75565. }
  75566. declare module BABYLON {
  75567. /** @hidden */
  75568. export var colorVertexShader: {
  75569. name: string;
  75570. shader: string;
  75571. };
  75572. }
  75573. declare module BABYLON {
  75574. /**
  75575. * Line mesh
  75576. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75577. */
  75578. export class LinesMesh extends Mesh {
  75579. /**
  75580. * If vertex color should be applied to the mesh
  75581. */
  75582. readonly useVertexColor?: boolean | undefined;
  75583. /**
  75584. * If vertex alpha should be applied to the mesh
  75585. */
  75586. readonly useVertexAlpha?: boolean | undefined;
  75587. /**
  75588. * Color of the line (Default: White)
  75589. */
  75590. color: Color3;
  75591. /**
  75592. * Alpha of the line (Default: 1)
  75593. */
  75594. alpha: number;
  75595. /**
  75596. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75597. * This margin is expressed in world space coordinates, so its value may vary.
  75598. * Default value is 0.1
  75599. */
  75600. intersectionThreshold: number;
  75601. private _colorShader;
  75602. private color4;
  75603. /**
  75604. * Creates a new LinesMesh
  75605. * @param name defines the name
  75606. * @param scene defines the hosting scene
  75607. * @param parent defines the parent mesh if any
  75608. * @param source defines the optional source LinesMesh used to clone data from
  75609. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75610. * When false, achieved by calling a clone(), also passing False.
  75611. * This will make creation of children, recursive.
  75612. * @param useVertexColor defines if this LinesMesh supports vertex color
  75613. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75614. */
  75615. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75616. /**
  75617. * If vertex color should be applied to the mesh
  75618. */
  75619. useVertexColor?: boolean | undefined,
  75620. /**
  75621. * If vertex alpha should be applied to the mesh
  75622. */
  75623. useVertexAlpha?: boolean | undefined);
  75624. private _addClipPlaneDefine;
  75625. private _removeClipPlaneDefine;
  75626. isReady(): boolean;
  75627. /**
  75628. * Returns the string "LineMesh"
  75629. */
  75630. getClassName(): string;
  75631. /**
  75632. * @hidden
  75633. */
  75634. /**
  75635. * @hidden
  75636. */
  75637. material: Material;
  75638. /**
  75639. * @hidden
  75640. */
  75641. readonly checkCollisions: boolean;
  75642. /** @hidden */
  75643. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75644. /** @hidden */
  75645. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75646. /**
  75647. * Disposes of the line mesh
  75648. * @param doNotRecurse If children should be disposed
  75649. */
  75650. dispose(doNotRecurse?: boolean): void;
  75651. /**
  75652. * Returns a new LineMesh object cloned from the current one.
  75653. */
  75654. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75655. /**
  75656. * Creates a new InstancedLinesMesh object from the mesh model.
  75657. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75658. * @param name defines the name of the new instance
  75659. * @returns a new InstancedLinesMesh
  75660. */
  75661. createInstance(name: string): InstancedLinesMesh;
  75662. }
  75663. /**
  75664. * Creates an instance based on a source LinesMesh
  75665. */
  75666. export class InstancedLinesMesh extends InstancedMesh {
  75667. /**
  75668. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75669. * This margin is expressed in world space coordinates, so its value may vary.
  75670. * Initilized with the intersectionThreshold value of the source LinesMesh
  75671. */
  75672. intersectionThreshold: number;
  75673. constructor(name: string, source: LinesMesh);
  75674. /**
  75675. * Returns the string "InstancedLinesMesh".
  75676. */
  75677. getClassName(): string;
  75678. }
  75679. }
  75680. declare module BABYLON {
  75681. /**
  75682. * Mesh representing the gorund
  75683. */
  75684. export class GroundMesh extends Mesh {
  75685. /** If octree should be generated */
  75686. generateOctree: boolean;
  75687. private _heightQuads;
  75688. /** @hidden */
  75689. _subdivisionsX: number;
  75690. /** @hidden */
  75691. _subdivisionsY: number;
  75692. /** @hidden */
  75693. _width: number;
  75694. /** @hidden */
  75695. _height: number;
  75696. /** @hidden */
  75697. _minX: number;
  75698. /** @hidden */
  75699. _maxX: number;
  75700. /** @hidden */
  75701. _minZ: number;
  75702. /** @hidden */
  75703. _maxZ: number;
  75704. constructor(name: string, scene: Scene);
  75705. /**
  75706. * "GroundMesh"
  75707. * @returns "GroundMesh"
  75708. */
  75709. getClassName(): string;
  75710. /**
  75711. * The minimum of x and y subdivisions
  75712. */
  75713. readonly subdivisions: number;
  75714. /**
  75715. * X subdivisions
  75716. */
  75717. readonly subdivisionsX: number;
  75718. /**
  75719. * Y subdivisions
  75720. */
  75721. readonly subdivisionsY: number;
  75722. /**
  75723. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75724. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75725. * @param chunksCount the number of subdivisions for x and y
  75726. * @param octreeBlocksSize (Default: 32)
  75727. */
  75728. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75729. /**
  75730. * Returns a height (y) value in the Worl system :
  75731. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75732. * @param x x coordinate
  75733. * @param z z coordinate
  75734. * @returns the ground y position if (x, z) are outside the ground surface.
  75735. */
  75736. getHeightAtCoordinates(x: number, z: number): number;
  75737. /**
  75738. * Returns a normalized vector (Vector3) orthogonal to the ground
  75739. * at the ground coordinates (x, z) expressed in the World system.
  75740. * @param x x coordinate
  75741. * @param z z coordinate
  75742. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75743. */
  75744. getNormalAtCoordinates(x: number, z: number): Vector3;
  75745. /**
  75746. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75747. * at the ground coordinates (x, z) expressed in the World system.
  75748. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75749. * @param x x coordinate
  75750. * @param z z coordinate
  75751. * @param ref vector to store the result
  75752. * @returns the GroundMesh.
  75753. */
  75754. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75755. /**
  75756. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75757. * if the ground has been updated.
  75758. * This can be used in the render loop.
  75759. * @returns the GroundMesh.
  75760. */
  75761. updateCoordinateHeights(): GroundMesh;
  75762. private _getFacetAt;
  75763. private _initHeightQuads;
  75764. private _computeHeightQuads;
  75765. /**
  75766. * Serializes this ground mesh
  75767. * @param serializationObject object to write serialization to
  75768. */
  75769. serialize(serializationObject: any): void;
  75770. /**
  75771. * Parses a serialized ground mesh
  75772. * @param parsedMesh the serialized mesh
  75773. * @param scene the scene to create the ground mesh in
  75774. * @returns the created ground mesh
  75775. */
  75776. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75777. }
  75778. }
  75779. declare module BABYLON {
  75780. /**
  75781. * Interface for Physics-Joint data
  75782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75783. */
  75784. export interface PhysicsJointData {
  75785. /**
  75786. * The main pivot of the joint
  75787. */
  75788. mainPivot?: Vector3;
  75789. /**
  75790. * The connected pivot of the joint
  75791. */
  75792. connectedPivot?: Vector3;
  75793. /**
  75794. * The main axis of the joint
  75795. */
  75796. mainAxis?: Vector3;
  75797. /**
  75798. * The connected axis of the joint
  75799. */
  75800. connectedAxis?: Vector3;
  75801. /**
  75802. * The collision of the joint
  75803. */
  75804. collision?: boolean;
  75805. /**
  75806. * Native Oimo/Cannon/Energy data
  75807. */
  75808. nativeParams?: any;
  75809. }
  75810. /**
  75811. * This is a holder class for the physics joint created by the physics plugin
  75812. * It holds a set of functions to control the underlying joint
  75813. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75814. */
  75815. export class PhysicsJoint {
  75816. /**
  75817. * The type of the physics joint
  75818. */
  75819. type: number;
  75820. /**
  75821. * The data for the physics joint
  75822. */
  75823. jointData: PhysicsJointData;
  75824. private _physicsJoint;
  75825. protected _physicsPlugin: IPhysicsEnginePlugin;
  75826. /**
  75827. * Initializes the physics joint
  75828. * @param type The type of the physics joint
  75829. * @param jointData The data for the physics joint
  75830. */
  75831. constructor(
  75832. /**
  75833. * The type of the physics joint
  75834. */
  75835. type: number,
  75836. /**
  75837. * The data for the physics joint
  75838. */
  75839. jointData: PhysicsJointData);
  75840. /**
  75841. * Gets the physics joint
  75842. */
  75843. /**
  75844. * Sets the physics joint
  75845. */
  75846. physicsJoint: any;
  75847. /**
  75848. * Sets the physics plugin
  75849. */
  75850. physicsPlugin: IPhysicsEnginePlugin;
  75851. /**
  75852. * Execute a function that is physics-plugin specific.
  75853. * @param {Function} func the function that will be executed.
  75854. * It accepts two parameters: the physics world and the physics joint
  75855. */
  75856. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75857. /**
  75858. * Distance-Joint type
  75859. */
  75860. static DistanceJoint: number;
  75861. /**
  75862. * Hinge-Joint type
  75863. */
  75864. static HingeJoint: number;
  75865. /**
  75866. * Ball-and-Socket joint type
  75867. */
  75868. static BallAndSocketJoint: number;
  75869. /**
  75870. * Wheel-Joint type
  75871. */
  75872. static WheelJoint: number;
  75873. /**
  75874. * Slider-Joint type
  75875. */
  75876. static SliderJoint: number;
  75877. /**
  75878. * Prismatic-Joint type
  75879. */
  75880. static PrismaticJoint: number;
  75881. /**
  75882. * Universal-Joint type
  75883. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75884. */
  75885. static UniversalJoint: number;
  75886. /**
  75887. * Hinge-Joint 2 type
  75888. */
  75889. static Hinge2Joint: number;
  75890. /**
  75891. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75892. */
  75893. static PointToPointJoint: number;
  75894. /**
  75895. * Spring-Joint type
  75896. */
  75897. static SpringJoint: number;
  75898. /**
  75899. * Lock-Joint type
  75900. */
  75901. static LockJoint: number;
  75902. }
  75903. /**
  75904. * A class representing a physics distance joint
  75905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75906. */
  75907. export class DistanceJoint extends PhysicsJoint {
  75908. /**
  75909. *
  75910. * @param jointData The data for the Distance-Joint
  75911. */
  75912. constructor(jointData: DistanceJointData);
  75913. /**
  75914. * Update the predefined distance.
  75915. * @param maxDistance The maximum preferred distance
  75916. * @param minDistance The minimum preferred distance
  75917. */
  75918. updateDistance(maxDistance: number, minDistance?: number): void;
  75919. }
  75920. /**
  75921. * Represents a Motor-Enabled Joint
  75922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75923. */
  75924. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75925. /**
  75926. * Initializes the Motor-Enabled Joint
  75927. * @param type The type of the joint
  75928. * @param jointData The physica joint data for the joint
  75929. */
  75930. constructor(type: number, jointData: PhysicsJointData);
  75931. /**
  75932. * Set the motor values.
  75933. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75934. * @param force the force to apply
  75935. * @param maxForce max force for this motor.
  75936. */
  75937. setMotor(force?: number, maxForce?: number): void;
  75938. /**
  75939. * Set the motor's limits.
  75940. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75941. * @param upperLimit The upper limit of the motor
  75942. * @param lowerLimit The lower limit of the motor
  75943. */
  75944. setLimit(upperLimit: number, lowerLimit?: number): void;
  75945. }
  75946. /**
  75947. * This class represents a single physics Hinge-Joint
  75948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75949. */
  75950. export class HingeJoint extends MotorEnabledJoint {
  75951. /**
  75952. * Initializes the Hinge-Joint
  75953. * @param jointData The joint data for the Hinge-Joint
  75954. */
  75955. constructor(jointData: PhysicsJointData);
  75956. /**
  75957. * Set the motor values.
  75958. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75959. * @param {number} force the force to apply
  75960. * @param {number} maxForce max force for this motor.
  75961. */
  75962. setMotor(force?: number, maxForce?: number): void;
  75963. /**
  75964. * Set the motor's limits.
  75965. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75966. * @param upperLimit The upper limit of the motor
  75967. * @param lowerLimit The lower limit of the motor
  75968. */
  75969. setLimit(upperLimit: number, lowerLimit?: number): void;
  75970. }
  75971. /**
  75972. * This class represents a dual hinge physics joint (same as wheel joint)
  75973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75974. */
  75975. export class Hinge2Joint extends MotorEnabledJoint {
  75976. /**
  75977. * Initializes the Hinge2-Joint
  75978. * @param jointData The joint data for the Hinge2-Joint
  75979. */
  75980. constructor(jointData: PhysicsJointData);
  75981. /**
  75982. * Set the motor values.
  75983. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75984. * @param {number} targetSpeed the speed the motor is to reach
  75985. * @param {number} maxForce max force for this motor.
  75986. * @param {motorIndex} the motor's index, 0 or 1.
  75987. */
  75988. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75989. /**
  75990. * Set the motor limits.
  75991. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75992. * @param {number} upperLimit the upper limit
  75993. * @param {number} lowerLimit lower limit
  75994. * @param {motorIndex} the motor's index, 0 or 1.
  75995. */
  75996. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75997. }
  75998. /**
  75999. * Interface for a motor enabled joint
  76000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76001. */
  76002. export interface IMotorEnabledJoint {
  76003. /**
  76004. * Physics joint
  76005. */
  76006. physicsJoint: any;
  76007. /**
  76008. * Sets the motor of the motor-enabled joint
  76009. * @param force The force of the motor
  76010. * @param maxForce The maximum force of the motor
  76011. * @param motorIndex The index of the motor
  76012. */
  76013. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  76014. /**
  76015. * Sets the limit of the motor
  76016. * @param upperLimit The upper limit of the motor
  76017. * @param lowerLimit The lower limit of the motor
  76018. * @param motorIndex The index of the motor
  76019. */
  76020. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76021. }
  76022. /**
  76023. * Joint data for a Distance-Joint
  76024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76025. */
  76026. export interface DistanceJointData extends PhysicsJointData {
  76027. /**
  76028. * Max distance the 2 joint objects can be apart
  76029. */
  76030. maxDistance: number;
  76031. }
  76032. /**
  76033. * Joint data from a spring joint
  76034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76035. */
  76036. export interface SpringJointData extends PhysicsJointData {
  76037. /**
  76038. * Length of the spring
  76039. */
  76040. length: number;
  76041. /**
  76042. * Stiffness of the spring
  76043. */
  76044. stiffness: number;
  76045. /**
  76046. * Damping of the spring
  76047. */
  76048. damping: number;
  76049. /** this callback will be called when applying the force to the impostors. */
  76050. forceApplicationCallback: () => void;
  76051. }
  76052. }
  76053. declare module BABYLON {
  76054. /**
  76055. * Holds the data for the raycast result
  76056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76057. */
  76058. export class PhysicsRaycastResult {
  76059. private _hasHit;
  76060. private _hitDistance;
  76061. private _hitNormalWorld;
  76062. private _hitPointWorld;
  76063. private _rayFromWorld;
  76064. private _rayToWorld;
  76065. /**
  76066. * Gets if there was a hit
  76067. */
  76068. readonly hasHit: boolean;
  76069. /**
  76070. * Gets the distance from the hit
  76071. */
  76072. readonly hitDistance: number;
  76073. /**
  76074. * Gets the hit normal/direction in the world
  76075. */
  76076. readonly hitNormalWorld: Vector3;
  76077. /**
  76078. * Gets the hit point in the world
  76079. */
  76080. readonly hitPointWorld: Vector3;
  76081. /**
  76082. * Gets the ray "start point" of the ray in the world
  76083. */
  76084. readonly rayFromWorld: Vector3;
  76085. /**
  76086. * Gets the ray "end point" of the ray in the world
  76087. */
  76088. readonly rayToWorld: Vector3;
  76089. /**
  76090. * Sets the hit data (normal & point in world space)
  76091. * @param hitNormalWorld defines the normal in world space
  76092. * @param hitPointWorld defines the point in world space
  76093. */
  76094. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  76095. /**
  76096. * Sets the distance from the start point to the hit point
  76097. * @param distance
  76098. */
  76099. setHitDistance(distance: number): void;
  76100. /**
  76101. * Calculates the distance manually
  76102. */
  76103. calculateHitDistance(): void;
  76104. /**
  76105. * Resets all the values to default
  76106. * @param from The from point on world space
  76107. * @param to The to point on world space
  76108. */
  76109. reset(from?: Vector3, to?: Vector3): void;
  76110. }
  76111. /**
  76112. * Interface for the size containing width and height
  76113. */
  76114. interface IXYZ {
  76115. /**
  76116. * X
  76117. */
  76118. x: number;
  76119. /**
  76120. * Y
  76121. */
  76122. y: number;
  76123. /**
  76124. * Z
  76125. */
  76126. z: number;
  76127. }
  76128. }
  76129. declare module BABYLON {
  76130. /**
  76131. * Interface used to describe a physics joint
  76132. */
  76133. export interface PhysicsImpostorJoint {
  76134. /** Defines the main impostor to which the joint is linked */
  76135. mainImpostor: PhysicsImpostor;
  76136. /** Defines the impostor that is connected to the main impostor using this joint */
  76137. connectedImpostor: PhysicsImpostor;
  76138. /** Defines the joint itself */
  76139. joint: PhysicsJoint;
  76140. }
  76141. /** @hidden */
  76142. export interface IPhysicsEnginePlugin {
  76143. world: any;
  76144. name: string;
  76145. setGravity(gravity: Vector3): void;
  76146. setTimeStep(timeStep: number): void;
  76147. getTimeStep(): number;
  76148. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76149. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76150. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76151. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76152. removePhysicsBody(impostor: PhysicsImpostor): void;
  76153. generateJoint(joint: PhysicsImpostorJoint): void;
  76154. removeJoint(joint: PhysicsImpostorJoint): void;
  76155. isSupported(): boolean;
  76156. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76157. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76158. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76159. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76160. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76161. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76162. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76163. getBodyMass(impostor: PhysicsImpostor): number;
  76164. getBodyFriction(impostor: PhysicsImpostor): number;
  76165. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76166. getBodyRestitution(impostor: PhysicsImpostor): number;
  76167. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76168. getBodyPressure?(impostor: PhysicsImpostor): number;
  76169. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  76170. getBodyStiffness?(impostor: PhysicsImpostor): number;
  76171. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  76172. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  76173. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  76174. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  76175. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  76176. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  76177. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  76178. sleepBody(impostor: PhysicsImpostor): void;
  76179. wakeUpBody(impostor: PhysicsImpostor): void;
  76180. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  76181. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76182. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76183. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76184. getRadius(impostor: PhysicsImpostor): number;
  76185. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76186. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76187. dispose(): void;
  76188. }
  76189. /**
  76190. * Interface used to define a physics engine
  76191. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76192. */
  76193. export interface IPhysicsEngine {
  76194. /**
  76195. * Gets the gravity vector used by the simulation
  76196. */
  76197. gravity: Vector3;
  76198. /**
  76199. * Sets the gravity vector used by the simulation
  76200. * @param gravity defines the gravity vector to use
  76201. */
  76202. setGravity(gravity: Vector3): void;
  76203. /**
  76204. * Set the time step of the physics engine.
  76205. * Default is 1/60.
  76206. * To slow it down, enter 1/600 for example.
  76207. * To speed it up, 1/30
  76208. * @param newTimeStep the new timestep to apply to this world.
  76209. */
  76210. setTimeStep(newTimeStep: number): void;
  76211. /**
  76212. * Get the time step of the physics engine.
  76213. * @returns the current time step
  76214. */
  76215. getTimeStep(): number;
  76216. /**
  76217. * Release all resources
  76218. */
  76219. dispose(): void;
  76220. /**
  76221. * Gets the name of the current physics plugin
  76222. * @returns the name of the plugin
  76223. */
  76224. getPhysicsPluginName(): string;
  76225. /**
  76226. * Adding a new impostor for the impostor tracking.
  76227. * This will be done by the impostor itself.
  76228. * @param impostor the impostor to add
  76229. */
  76230. addImpostor(impostor: PhysicsImpostor): void;
  76231. /**
  76232. * Remove an impostor from the engine.
  76233. * This impostor and its mesh will not longer be updated by the physics engine.
  76234. * @param impostor the impostor to remove
  76235. */
  76236. removeImpostor(impostor: PhysicsImpostor): void;
  76237. /**
  76238. * Add a joint to the physics engine
  76239. * @param mainImpostor defines the main impostor to which the joint is added.
  76240. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76241. * @param joint defines the joint that will connect both impostors.
  76242. */
  76243. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76244. /**
  76245. * Removes a joint from the simulation
  76246. * @param mainImpostor defines the impostor used with the joint
  76247. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76248. * @param joint defines the joint to remove
  76249. */
  76250. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76251. /**
  76252. * Gets the current plugin used to run the simulation
  76253. * @returns current plugin
  76254. */
  76255. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76256. /**
  76257. * Gets the list of physic impostors
  76258. * @returns an array of PhysicsImpostor
  76259. */
  76260. getImpostors(): Array<PhysicsImpostor>;
  76261. /**
  76262. * Gets the impostor for a physics enabled object
  76263. * @param object defines the object impersonated by the impostor
  76264. * @returns the PhysicsImpostor or null if not found
  76265. */
  76266. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76267. /**
  76268. * Gets the impostor for a physics body object
  76269. * @param body defines physics body used by the impostor
  76270. * @returns the PhysicsImpostor or null if not found
  76271. */
  76272. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76273. /**
  76274. * Does a raycast in the physics world
  76275. * @param from when should the ray start?
  76276. * @param to when should the ray end?
  76277. * @returns PhysicsRaycastResult
  76278. */
  76279. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  76280. /**
  76281. * Called by the scene. No need to call it.
  76282. * @param delta defines the timespam between frames
  76283. */
  76284. _step(delta: number): void;
  76285. }
  76286. }
  76287. declare module BABYLON {
  76288. /**
  76289. * The interface for the physics imposter parameters
  76290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76291. */
  76292. export interface PhysicsImpostorParameters {
  76293. /**
  76294. * The mass of the physics imposter
  76295. */
  76296. mass: number;
  76297. /**
  76298. * The friction of the physics imposter
  76299. */
  76300. friction?: number;
  76301. /**
  76302. * The coefficient of restitution of the physics imposter
  76303. */
  76304. restitution?: number;
  76305. /**
  76306. * The native options of the physics imposter
  76307. */
  76308. nativeOptions?: any;
  76309. /**
  76310. * Specifies if the parent should be ignored
  76311. */
  76312. ignoreParent?: boolean;
  76313. /**
  76314. * Specifies if bi-directional transformations should be disabled
  76315. */
  76316. disableBidirectionalTransformation?: boolean;
  76317. /**
  76318. * The pressure inside the physics imposter, soft object only
  76319. */
  76320. pressure?: number;
  76321. /**
  76322. * The stiffness the physics imposter, soft object only
  76323. */
  76324. stiffness?: number;
  76325. /**
  76326. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  76327. */
  76328. velocityIterations?: number;
  76329. /**
  76330. * The number of iterations used in maintaining consistent vertex positions, soft object only
  76331. */
  76332. positionIterations?: number;
  76333. /**
  76334. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  76335. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  76336. * Add to fix multiple points
  76337. */
  76338. fixedPoints?: number;
  76339. /**
  76340. * The collision margin around a soft object
  76341. */
  76342. margin?: number;
  76343. /**
  76344. * The collision margin around a soft object
  76345. */
  76346. damping?: number;
  76347. /**
  76348. * The path for a rope based on an extrusion
  76349. */
  76350. path?: any;
  76351. /**
  76352. * The shape of an extrusion used for a rope based on an extrusion
  76353. */
  76354. shape?: any;
  76355. }
  76356. /**
  76357. * Interface for a physics-enabled object
  76358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76359. */
  76360. export interface IPhysicsEnabledObject {
  76361. /**
  76362. * The position of the physics-enabled object
  76363. */
  76364. position: Vector3;
  76365. /**
  76366. * The rotation of the physics-enabled object
  76367. */
  76368. rotationQuaternion: Nullable<Quaternion>;
  76369. /**
  76370. * The scale of the physics-enabled object
  76371. */
  76372. scaling: Vector3;
  76373. /**
  76374. * The rotation of the physics-enabled object
  76375. */
  76376. rotation?: Vector3;
  76377. /**
  76378. * The parent of the physics-enabled object
  76379. */
  76380. parent?: any;
  76381. /**
  76382. * The bounding info of the physics-enabled object
  76383. * @returns The bounding info of the physics-enabled object
  76384. */
  76385. getBoundingInfo(): BoundingInfo;
  76386. /**
  76387. * Computes the world matrix
  76388. * @param force Specifies if the world matrix should be computed by force
  76389. * @returns A world matrix
  76390. */
  76391. computeWorldMatrix(force: boolean): Matrix;
  76392. /**
  76393. * Gets the world matrix
  76394. * @returns A world matrix
  76395. */
  76396. getWorldMatrix?(): Matrix;
  76397. /**
  76398. * Gets the child meshes
  76399. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76400. * @returns An array of abstract meshes
  76401. */
  76402. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76403. /**
  76404. * Gets the vertex data
  76405. * @param kind The type of vertex data
  76406. * @returns A nullable array of numbers, or a float32 array
  76407. */
  76408. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76409. /**
  76410. * Gets the indices from the mesh
  76411. * @returns A nullable array of index arrays
  76412. */
  76413. getIndices?(): Nullable<IndicesArray>;
  76414. /**
  76415. * Gets the scene from the mesh
  76416. * @returns the indices array or null
  76417. */
  76418. getScene?(): Scene;
  76419. /**
  76420. * Gets the absolute position from the mesh
  76421. * @returns the absolute position
  76422. */
  76423. getAbsolutePosition(): Vector3;
  76424. /**
  76425. * Gets the absolute pivot point from the mesh
  76426. * @returns the absolute pivot point
  76427. */
  76428. getAbsolutePivotPoint(): Vector3;
  76429. /**
  76430. * Rotates the mesh
  76431. * @param axis The axis of rotation
  76432. * @param amount The amount of rotation
  76433. * @param space The space of the rotation
  76434. * @returns The rotation transform node
  76435. */
  76436. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76437. /**
  76438. * Translates the mesh
  76439. * @param axis The axis of translation
  76440. * @param distance The distance of translation
  76441. * @param space The space of the translation
  76442. * @returns The transform node
  76443. */
  76444. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76445. /**
  76446. * Sets the absolute position of the mesh
  76447. * @param absolutePosition The absolute position of the mesh
  76448. * @returns The transform node
  76449. */
  76450. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76451. /**
  76452. * Gets the class name of the mesh
  76453. * @returns The class name
  76454. */
  76455. getClassName(): string;
  76456. }
  76457. /**
  76458. * Represents a physics imposter
  76459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76460. */
  76461. export class PhysicsImpostor {
  76462. /**
  76463. * The physics-enabled object used as the physics imposter
  76464. */
  76465. object: IPhysicsEnabledObject;
  76466. /**
  76467. * The type of the physics imposter
  76468. */
  76469. type: number;
  76470. private _options;
  76471. private _scene?;
  76472. /**
  76473. * The default object size of the imposter
  76474. */
  76475. static DEFAULT_OBJECT_SIZE: Vector3;
  76476. /**
  76477. * The identity quaternion of the imposter
  76478. */
  76479. static IDENTITY_QUATERNION: Quaternion;
  76480. /** @hidden */
  76481. _pluginData: any;
  76482. private _physicsEngine;
  76483. private _physicsBody;
  76484. private _bodyUpdateRequired;
  76485. private _onBeforePhysicsStepCallbacks;
  76486. private _onAfterPhysicsStepCallbacks;
  76487. /** @hidden */
  76488. _onPhysicsCollideCallbacks: Array<{
  76489. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76490. otherImpostors: Array<PhysicsImpostor>;
  76491. }>;
  76492. private _deltaPosition;
  76493. private _deltaRotation;
  76494. private _deltaRotationConjugated;
  76495. /** @hidden */
  76496. _isFromLine: boolean;
  76497. private _parent;
  76498. private _isDisposed;
  76499. private static _tmpVecs;
  76500. private static _tmpQuat;
  76501. /**
  76502. * Specifies if the physics imposter is disposed
  76503. */
  76504. readonly isDisposed: boolean;
  76505. /**
  76506. * Gets the mass of the physics imposter
  76507. */
  76508. mass: number;
  76509. /**
  76510. * Gets the coefficient of friction
  76511. */
  76512. /**
  76513. * Sets the coefficient of friction
  76514. */
  76515. friction: number;
  76516. /**
  76517. * Gets the coefficient of restitution
  76518. */
  76519. /**
  76520. * Sets the coefficient of restitution
  76521. */
  76522. restitution: number;
  76523. /**
  76524. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  76525. */
  76526. /**
  76527. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  76528. */
  76529. pressure: number;
  76530. /**
  76531. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76532. */
  76533. /**
  76534. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76535. */
  76536. stiffness: number;
  76537. /**
  76538. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76539. */
  76540. /**
  76541. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76542. */
  76543. velocityIterations: number;
  76544. /**
  76545. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76546. */
  76547. /**
  76548. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76549. */
  76550. positionIterations: number;
  76551. /**
  76552. * The unique id of the physics imposter
  76553. * set by the physics engine when adding this impostor to the array
  76554. */
  76555. uniqueId: number;
  76556. /**
  76557. * @hidden
  76558. */
  76559. soft: boolean;
  76560. /**
  76561. * @hidden
  76562. */
  76563. segments: number;
  76564. private _joints;
  76565. /**
  76566. * Initializes the physics imposter
  76567. * @param object The physics-enabled object used as the physics imposter
  76568. * @param type The type of the physics imposter
  76569. * @param _options The options for the physics imposter
  76570. * @param _scene The Babylon scene
  76571. */
  76572. constructor(
  76573. /**
  76574. * The physics-enabled object used as the physics imposter
  76575. */
  76576. object: IPhysicsEnabledObject,
  76577. /**
  76578. * The type of the physics imposter
  76579. */
  76580. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76581. /**
  76582. * This function will completly initialize this impostor.
  76583. * It will create a new body - but only if this mesh has no parent.
  76584. * If it has, this impostor will not be used other than to define the impostor
  76585. * of the child mesh.
  76586. * @hidden
  76587. */
  76588. _init(): void;
  76589. private _getPhysicsParent;
  76590. /**
  76591. * Should a new body be generated.
  76592. * @returns boolean specifying if body initialization is required
  76593. */
  76594. isBodyInitRequired(): boolean;
  76595. /**
  76596. * Sets the updated scaling
  76597. * @param updated Specifies if the scaling is updated
  76598. */
  76599. setScalingUpdated(): void;
  76600. /**
  76601. * Force a regeneration of this or the parent's impostor's body.
  76602. * Use under cautious - This will remove all joints already implemented.
  76603. */
  76604. forceUpdate(): void;
  76605. /**
  76606. * Gets the body that holds this impostor. Either its own, or its parent.
  76607. */
  76608. /**
  76609. * Set the physics body. Used mainly by the physics engine/plugin
  76610. */
  76611. physicsBody: any;
  76612. /**
  76613. * Get the parent of the physics imposter
  76614. * @returns Physics imposter or null
  76615. */
  76616. /**
  76617. * Sets the parent of the physics imposter
  76618. */
  76619. parent: Nullable<PhysicsImpostor>;
  76620. /**
  76621. * Resets the update flags
  76622. */
  76623. resetUpdateFlags(): void;
  76624. /**
  76625. * Gets the object extend size
  76626. * @returns the object extend size
  76627. */
  76628. getObjectExtendSize(): Vector3;
  76629. /**
  76630. * Gets the object center
  76631. * @returns The object center
  76632. */
  76633. getObjectCenter(): Vector3;
  76634. /**
  76635. * Get a specific parametes from the options parameter
  76636. * @param paramName The object parameter name
  76637. * @returns The object parameter
  76638. */
  76639. getParam(paramName: string): any;
  76640. /**
  76641. * Sets a specific parameter in the options given to the physics plugin
  76642. * @param paramName The parameter name
  76643. * @param value The value of the parameter
  76644. */
  76645. setParam(paramName: string, value: number): void;
  76646. /**
  76647. * Specifically change the body's mass option. Won't recreate the physics body object
  76648. * @param mass The mass of the physics imposter
  76649. */
  76650. setMass(mass: number): void;
  76651. /**
  76652. * Gets the linear velocity
  76653. * @returns linear velocity or null
  76654. */
  76655. getLinearVelocity(): Nullable<Vector3>;
  76656. /**
  76657. * Sets the linear velocity
  76658. * @param velocity linear velocity or null
  76659. */
  76660. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76661. /**
  76662. * Gets the angular velocity
  76663. * @returns angular velocity or null
  76664. */
  76665. getAngularVelocity(): Nullable<Vector3>;
  76666. /**
  76667. * Sets the angular velocity
  76668. * @param velocity The velocity or null
  76669. */
  76670. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76671. /**
  76672. * Execute a function with the physics plugin native code
  76673. * Provide a function the will have two variables - the world object and the physics body object
  76674. * @param func The function to execute with the physics plugin native code
  76675. */
  76676. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76677. /**
  76678. * Register a function that will be executed before the physics world is stepping forward
  76679. * @param func The function to execute before the physics world is stepped forward
  76680. */
  76681. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76682. /**
  76683. * Unregister a function that will be executed before the physics world is stepping forward
  76684. * @param func The function to execute before the physics world is stepped forward
  76685. */
  76686. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76687. /**
  76688. * Register a function that will be executed after the physics step
  76689. * @param func The function to execute after physics step
  76690. */
  76691. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76692. /**
  76693. * Unregisters a function that will be executed after the physics step
  76694. * @param func The function to execute after physics step
  76695. */
  76696. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76697. /**
  76698. * register a function that will be executed when this impostor collides against a different body
  76699. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76700. * @param func Callback that is executed on collision
  76701. */
  76702. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76703. /**
  76704. * Unregisters the physics imposter on contact
  76705. * @param collideAgainst The physics object to collide against
  76706. * @param func Callback to execute on collision
  76707. */
  76708. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76709. private _tmpQuat;
  76710. private _tmpQuat2;
  76711. /**
  76712. * Get the parent rotation
  76713. * @returns The parent rotation
  76714. */
  76715. getParentsRotation(): Quaternion;
  76716. /**
  76717. * this function is executed by the physics engine.
  76718. */
  76719. beforeStep: () => void;
  76720. /**
  76721. * this function is executed by the physics engine
  76722. */
  76723. afterStep: () => void;
  76724. /**
  76725. * Legacy collision detection event support
  76726. */
  76727. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76728. /**
  76729. * event and body object due to cannon's event-based architecture.
  76730. */
  76731. onCollide: (e: {
  76732. body: any;
  76733. }) => void;
  76734. /**
  76735. * Apply a force
  76736. * @param force The force to apply
  76737. * @param contactPoint The contact point for the force
  76738. * @returns The physics imposter
  76739. */
  76740. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76741. /**
  76742. * Apply an impulse
  76743. * @param force The impulse force
  76744. * @param contactPoint The contact point for the impulse force
  76745. * @returns The physics imposter
  76746. */
  76747. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76748. /**
  76749. * A help function to create a joint
  76750. * @param otherImpostor A physics imposter used to create a joint
  76751. * @param jointType The type of joint
  76752. * @param jointData The data for the joint
  76753. * @returns The physics imposter
  76754. */
  76755. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76756. /**
  76757. * Add a joint to this impostor with a different impostor
  76758. * @param otherImpostor A physics imposter used to add a joint
  76759. * @param joint The joint to add
  76760. * @returns The physics imposter
  76761. */
  76762. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76763. /**
  76764. * Add an anchor to a cloth impostor
  76765. * @param otherImpostor rigid impostor to anchor to
  76766. * @param width ratio across width from 0 to 1
  76767. * @param height ratio up height from 0 to 1
  76768. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  76769. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  76770. * @returns impostor the soft imposter
  76771. */
  76772. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76773. /**
  76774. * Add a hook to a rope impostor
  76775. * @param otherImpostor rigid impostor to anchor to
  76776. * @param length ratio across rope from 0 to 1
  76777. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  76778. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  76779. * @returns impostor the rope imposter
  76780. */
  76781. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76782. /**
  76783. * Will keep this body still, in a sleep mode.
  76784. * @returns the physics imposter
  76785. */
  76786. sleep(): PhysicsImpostor;
  76787. /**
  76788. * Wake the body up.
  76789. * @returns The physics imposter
  76790. */
  76791. wakeUp(): PhysicsImpostor;
  76792. /**
  76793. * Clones the physics imposter
  76794. * @param newObject The physics imposter clones to this physics-enabled object
  76795. * @returns A nullable physics imposter
  76796. */
  76797. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76798. /**
  76799. * Disposes the physics imposter
  76800. */
  76801. dispose(): void;
  76802. /**
  76803. * Sets the delta position
  76804. * @param position The delta position amount
  76805. */
  76806. setDeltaPosition(position: Vector3): void;
  76807. /**
  76808. * Sets the delta rotation
  76809. * @param rotation The delta rotation amount
  76810. */
  76811. setDeltaRotation(rotation: Quaternion): void;
  76812. /**
  76813. * Gets the box size of the physics imposter and stores the result in the input parameter
  76814. * @param result Stores the box size
  76815. * @returns The physics imposter
  76816. */
  76817. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76818. /**
  76819. * Gets the radius of the physics imposter
  76820. * @returns Radius of the physics imposter
  76821. */
  76822. getRadius(): number;
  76823. /**
  76824. * Sync a bone with this impostor
  76825. * @param bone The bone to sync to the impostor.
  76826. * @param boneMesh The mesh that the bone is influencing.
  76827. * @param jointPivot The pivot of the joint / bone in local space.
  76828. * @param distToJoint Optional distance from the impostor to the joint.
  76829. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76830. */
  76831. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76832. /**
  76833. * Sync impostor to a bone
  76834. * @param bone The bone that the impostor will be synced to.
  76835. * @param boneMesh The mesh that the bone is influencing.
  76836. * @param jointPivot The pivot of the joint / bone in local space.
  76837. * @param distToJoint Optional distance from the impostor to the joint.
  76838. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76839. * @param boneAxis Optional vector3 axis the bone is aligned with
  76840. */
  76841. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76842. /**
  76843. * No-Imposter type
  76844. */
  76845. static NoImpostor: number;
  76846. /**
  76847. * Sphere-Imposter type
  76848. */
  76849. static SphereImpostor: number;
  76850. /**
  76851. * Box-Imposter type
  76852. */
  76853. static BoxImpostor: number;
  76854. /**
  76855. * Plane-Imposter type
  76856. */
  76857. static PlaneImpostor: number;
  76858. /**
  76859. * Mesh-imposter type
  76860. */
  76861. static MeshImpostor: number;
  76862. /**
  76863. * Capsule-Impostor type (Ammo.js plugin only)
  76864. */
  76865. static CapsuleImpostor: number;
  76866. /**
  76867. * Cylinder-Imposter type
  76868. */
  76869. static CylinderImpostor: number;
  76870. /**
  76871. * Particle-Imposter type
  76872. */
  76873. static ParticleImpostor: number;
  76874. /**
  76875. * Heightmap-Imposter type
  76876. */
  76877. static HeightmapImpostor: number;
  76878. /**
  76879. * ConvexHull-Impostor type (Ammo.js plugin only)
  76880. */
  76881. static ConvexHullImpostor: number;
  76882. /**
  76883. * Rope-Imposter type
  76884. */
  76885. static RopeImpostor: number;
  76886. /**
  76887. * Cloth-Imposter type
  76888. */
  76889. static ClothImpostor: number;
  76890. /**
  76891. * Softbody-Imposter type
  76892. */
  76893. static SoftbodyImpostor: number;
  76894. }
  76895. }
  76896. declare module BABYLON {
  76897. /**
  76898. * @hidden
  76899. **/
  76900. export class _CreationDataStorage {
  76901. closePath?: boolean;
  76902. closeArray?: boolean;
  76903. idx: number[];
  76904. dashSize: number;
  76905. gapSize: number;
  76906. path3D: Path3D;
  76907. pathArray: Vector3[][];
  76908. arc: number;
  76909. radius: number;
  76910. cap: number;
  76911. tessellation: number;
  76912. }
  76913. /**
  76914. * @hidden
  76915. **/
  76916. class _InstanceDataStorage {
  76917. visibleInstances: any;
  76918. batchCache: _InstancesBatch;
  76919. instancesBufferSize: number;
  76920. instancesBuffer: Nullable<Buffer>;
  76921. instancesData: Float32Array;
  76922. overridenInstanceCount: number;
  76923. isFrozen: boolean;
  76924. previousBatch: Nullable<_InstancesBatch>;
  76925. hardwareInstancedRendering: boolean;
  76926. sideOrientation: number;
  76927. }
  76928. /**
  76929. * @hidden
  76930. **/
  76931. export class _InstancesBatch {
  76932. mustReturn: boolean;
  76933. visibleInstances: Nullable<InstancedMesh[]>[];
  76934. renderSelf: boolean[];
  76935. hardwareInstancedRendering: boolean[];
  76936. }
  76937. /**
  76938. * Class used to represent renderable models
  76939. */
  76940. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76941. /**
  76942. * Mesh side orientation : usually the external or front surface
  76943. */
  76944. static readonly FRONTSIDE: number;
  76945. /**
  76946. * Mesh side orientation : usually the internal or back surface
  76947. */
  76948. static readonly BACKSIDE: number;
  76949. /**
  76950. * Mesh side orientation : both internal and external or front and back surfaces
  76951. */
  76952. static readonly DOUBLESIDE: number;
  76953. /**
  76954. * Mesh side orientation : by default, `FRONTSIDE`
  76955. */
  76956. static readonly DEFAULTSIDE: number;
  76957. /**
  76958. * Mesh cap setting : no cap
  76959. */
  76960. static readonly NO_CAP: number;
  76961. /**
  76962. * Mesh cap setting : one cap at the beginning of the mesh
  76963. */
  76964. static readonly CAP_START: number;
  76965. /**
  76966. * Mesh cap setting : one cap at the end of the mesh
  76967. */
  76968. static readonly CAP_END: number;
  76969. /**
  76970. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76971. */
  76972. static readonly CAP_ALL: number;
  76973. /**
  76974. * Mesh pattern setting : no flip or rotate
  76975. */
  76976. static readonly NO_FLIP: number;
  76977. /**
  76978. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  76979. */
  76980. static readonly FLIP_TILE: number;
  76981. /**
  76982. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  76983. */
  76984. static readonly ROTATE_TILE: number;
  76985. /**
  76986. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  76987. */
  76988. static readonly FLIP_ROW: number;
  76989. /**
  76990. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  76991. */
  76992. static readonly ROTATE_ROW: number;
  76993. /**
  76994. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  76995. */
  76996. static readonly FLIP_N_ROTATE_TILE: number;
  76997. /**
  76998. * Mesh pattern setting : rotate pattern and rotate
  76999. */
  77000. static readonly FLIP_N_ROTATE_ROW: number;
  77001. /**
  77002. * Mesh tile positioning : part tiles same on left/right or top/bottom
  77003. */
  77004. static readonly CENTER: number;
  77005. /**
  77006. * Mesh tile positioning : part tiles on left
  77007. */
  77008. static readonly LEFT: number;
  77009. /**
  77010. * Mesh tile positioning : part tiles on right
  77011. */
  77012. static readonly RIGHT: number;
  77013. /**
  77014. * Mesh tile positioning : part tiles on top
  77015. */
  77016. static readonly TOP: number;
  77017. /**
  77018. * Mesh tile positioning : part tiles on bottom
  77019. */
  77020. static readonly BOTTOM: number;
  77021. /**
  77022. * Gets the default side orientation.
  77023. * @param orientation the orientation to value to attempt to get
  77024. * @returns the default orientation
  77025. * @hidden
  77026. */
  77027. static _GetDefaultSideOrientation(orientation?: number): number;
  77028. private _internalMeshDataInfo;
  77029. /**
  77030. * An event triggered before rendering the mesh
  77031. */
  77032. readonly onBeforeRenderObservable: Observable<Mesh>;
  77033. /**
  77034. * An event triggered before binding the mesh
  77035. */
  77036. readonly onBeforeBindObservable: Observable<Mesh>;
  77037. /**
  77038. * An event triggered after rendering the mesh
  77039. */
  77040. readonly onAfterRenderObservable: Observable<Mesh>;
  77041. /**
  77042. * An event triggered before drawing the mesh
  77043. */
  77044. readonly onBeforeDrawObservable: Observable<Mesh>;
  77045. private _onBeforeDrawObserver;
  77046. /**
  77047. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77048. */
  77049. onBeforeDraw: () => void;
  77050. /**
  77051. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77052. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77053. */
  77054. delayLoadState: number;
  77055. /**
  77056. * Gets the list of instances created from this mesh
  77057. * it is not supposed to be modified manually.
  77058. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77059. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77060. */
  77061. instances: InstancedMesh[];
  77062. /**
  77063. * Gets the file containing delay loading data for this mesh
  77064. */
  77065. delayLoadingFile: string;
  77066. /** @hidden */
  77067. _binaryInfo: any;
  77068. /**
  77069. * User defined function used to change how LOD level selection is done
  77070. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77071. */
  77072. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77073. /**
  77074. * Gets or sets the morph target manager
  77075. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77076. */
  77077. morphTargetManager: Nullable<MorphTargetManager>;
  77078. /** @hidden */
  77079. _creationDataStorage: Nullable<_CreationDataStorage>;
  77080. /** @hidden */
  77081. _geometry: Nullable<Geometry>;
  77082. /** @hidden */
  77083. _delayInfo: Array<string>;
  77084. /** @hidden */
  77085. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77086. /** @hidden */
  77087. _instanceDataStorage: _InstanceDataStorage;
  77088. private _effectiveMaterial;
  77089. /** @hidden */
  77090. _shouldGenerateFlatShading: boolean;
  77091. /** @hidden */
  77092. _originalBuilderSideOrientation: number;
  77093. /**
  77094. * Use this property to change the original side orientation defined at construction time
  77095. */
  77096. overrideMaterialSideOrientation: Nullable<number>;
  77097. /**
  77098. * Gets the source mesh (the one used to clone this one from)
  77099. */
  77100. readonly source: Nullable<Mesh>;
  77101. /**
  77102. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77103. */
  77104. isUnIndexed: boolean;
  77105. /**
  77106. * @constructor
  77107. * @param name The value used by scene.getMeshByName() to do a lookup.
  77108. * @param scene The scene to add this mesh to.
  77109. * @param parent The parent of this mesh, if it has one
  77110. * @param source An optional Mesh from which geometry is shared, cloned.
  77111. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77112. * When false, achieved by calling a clone(), also passing False.
  77113. * This will make creation of children, recursive.
  77114. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77115. */
  77116. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77117. /**
  77118. * Gets the class name
  77119. * @returns the string "Mesh".
  77120. */
  77121. getClassName(): string;
  77122. /** @hidden */
  77123. readonly _isMesh: boolean;
  77124. /**
  77125. * Returns a description of this mesh
  77126. * @param fullDetails define if full details about this mesh must be used
  77127. * @returns a descriptive string representing this mesh
  77128. */
  77129. toString(fullDetails?: boolean): string;
  77130. /** @hidden */
  77131. _unBindEffect(): void;
  77132. /**
  77133. * Gets a boolean indicating if this mesh has LOD
  77134. */
  77135. readonly hasLODLevels: boolean;
  77136. /**
  77137. * Gets the list of MeshLODLevel associated with the current mesh
  77138. * @returns an array of MeshLODLevel
  77139. */
  77140. getLODLevels(): MeshLODLevel[];
  77141. private _sortLODLevels;
  77142. /**
  77143. * Add a mesh as LOD level triggered at the given distance.
  77144. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77145. * @param distance The distance from the center of the object to show this level
  77146. * @param mesh The mesh to be added as LOD level (can be null)
  77147. * @return This mesh (for chaining)
  77148. */
  77149. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77150. /**
  77151. * Returns the LOD level mesh at the passed distance or null if not found.
  77152. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77153. * @param distance The distance from the center of the object to show this level
  77154. * @returns a Mesh or `null`
  77155. */
  77156. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77157. /**
  77158. * Remove a mesh from the LOD array
  77159. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77160. * @param mesh defines the mesh to be removed
  77161. * @return This mesh (for chaining)
  77162. */
  77163. removeLODLevel(mesh: Mesh): Mesh;
  77164. /**
  77165. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77166. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77167. * @param camera defines the camera to use to compute distance
  77168. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77169. * @return This mesh (for chaining)
  77170. */
  77171. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77172. /**
  77173. * Gets the mesh internal Geometry object
  77174. */
  77175. readonly geometry: Nullable<Geometry>;
  77176. /**
  77177. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77178. * @returns the total number of vertices
  77179. */
  77180. getTotalVertices(): number;
  77181. /**
  77182. * Returns the content of an associated vertex buffer
  77183. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77184. * - VertexBuffer.PositionKind
  77185. * - VertexBuffer.UVKind
  77186. * - VertexBuffer.UV2Kind
  77187. * - VertexBuffer.UV3Kind
  77188. * - VertexBuffer.UV4Kind
  77189. * - VertexBuffer.UV5Kind
  77190. * - VertexBuffer.UV6Kind
  77191. * - VertexBuffer.ColorKind
  77192. * - VertexBuffer.MatricesIndicesKind
  77193. * - VertexBuffer.MatricesIndicesExtraKind
  77194. * - VertexBuffer.MatricesWeightsKind
  77195. * - VertexBuffer.MatricesWeightsExtraKind
  77196. * @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
  77197. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77198. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77199. */
  77200. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77201. /**
  77202. * Returns the mesh VertexBuffer object from the requested `kind`
  77203. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77204. * - VertexBuffer.PositionKind
  77205. * - VertexBuffer.NormalKind
  77206. * - VertexBuffer.UVKind
  77207. * - VertexBuffer.UV2Kind
  77208. * - VertexBuffer.UV3Kind
  77209. * - VertexBuffer.UV4Kind
  77210. * - VertexBuffer.UV5Kind
  77211. * - VertexBuffer.UV6Kind
  77212. * - VertexBuffer.ColorKind
  77213. * - VertexBuffer.MatricesIndicesKind
  77214. * - VertexBuffer.MatricesIndicesExtraKind
  77215. * - VertexBuffer.MatricesWeightsKind
  77216. * - VertexBuffer.MatricesWeightsExtraKind
  77217. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77218. */
  77219. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77220. /**
  77221. * Tests if a specific vertex buffer is associated with this mesh
  77222. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77223. * - VertexBuffer.PositionKind
  77224. * - VertexBuffer.NormalKind
  77225. * - VertexBuffer.UVKind
  77226. * - VertexBuffer.UV2Kind
  77227. * - VertexBuffer.UV3Kind
  77228. * - VertexBuffer.UV4Kind
  77229. * - VertexBuffer.UV5Kind
  77230. * - VertexBuffer.UV6Kind
  77231. * - VertexBuffer.ColorKind
  77232. * - VertexBuffer.MatricesIndicesKind
  77233. * - VertexBuffer.MatricesIndicesExtraKind
  77234. * - VertexBuffer.MatricesWeightsKind
  77235. * - VertexBuffer.MatricesWeightsExtraKind
  77236. * @returns a boolean
  77237. */
  77238. isVerticesDataPresent(kind: string): boolean;
  77239. /**
  77240. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77241. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77242. * - VertexBuffer.PositionKind
  77243. * - VertexBuffer.UVKind
  77244. * - VertexBuffer.UV2Kind
  77245. * - VertexBuffer.UV3Kind
  77246. * - VertexBuffer.UV4Kind
  77247. * - VertexBuffer.UV5Kind
  77248. * - VertexBuffer.UV6Kind
  77249. * - VertexBuffer.ColorKind
  77250. * - VertexBuffer.MatricesIndicesKind
  77251. * - VertexBuffer.MatricesIndicesExtraKind
  77252. * - VertexBuffer.MatricesWeightsKind
  77253. * - VertexBuffer.MatricesWeightsExtraKind
  77254. * @returns a boolean
  77255. */
  77256. isVertexBufferUpdatable(kind: string): boolean;
  77257. /**
  77258. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77259. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77260. * - VertexBuffer.PositionKind
  77261. * - VertexBuffer.NormalKind
  77262. * - VertexBuffer.UVKind
  77263. * - VertexBuffer.UV2Kind
  77264. * - VertexBuffer.UV3Kind
  77265. * - VertexBuffer.UV4Kind
  77266. * - VertexBuffer.UV5Kind
  77267. * - VertexBuffer.UV6Kind
  77268. * - VertexBuffer.ColorKind
  77269. * - VertexBuffer.MatricesIndicesKind
  77270. * - VertexBuffer.MatricesIndicesExtraKind
  77271. * - VertexBuffer.MatricesWeightsKind
  77272. * - VertexBuffer.MatricesWeightsExtraKind
  77273. * @returns an array of strings
  77274. */
  77275. getVerticesDataKinds(): string[];
  77276. /**
  77277. * Returns a positive integer : the total number of indices in this mesh geometry.
  77278. * @returns the numner of indices or zero if the mesh has no geometry.
  77279. */
  77280. getTotalIndices(): number;
  77281. /**
  77282. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77283. * @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.
  77284. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77285. * @returns the indices array or an empty array if the mesh has no geometry
  77286. */
  77287. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77288. readonly isBlocked: boolean;
  77289. /**
  77290. * Determine if the current mesh is ready to be rendered
  77291. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77292. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77293. * @returns true if all associated assets are ready (material, textures, shaders)
  77294. */
  77295. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77296. /**
  77297. * 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.
  77298. */
  77299. readonly areNormalsFrozen: boolean;
  77300. /**
  77301. * 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.
  77302. * @returns the current mesh
  77303. */
  77304. freezeNormals(): Mesh;
  77305. /**
  77306. * 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
  77307. * @returns the current mesh
  77308. */
  77309. unfreezeNormals(): Mesh;
  77310. /**
  77311. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77312. */
  77313. overridenInstanceCount: number;
  77314. /** @hidden */
  77315. _preActivate(): Mesh;
  77316. /** @hidden */
  77317. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77318. /** @hidden */
  77319. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77320. /**
  77321. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77322. * This means the mesh underlying bounding box and sphere are recomputed.
  77323. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77324. * @returns the current mesh
  77325. */
  77326. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77327. /** @hidden */
  77328. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77329. /**
  77330. * This function will subdivide the mesh into multiple submeshes
  77331. * @param count defines the expected number of submeshes
  77332. */
  77333. subdivide(count: number): void;
  77334. /**
  77335. * Copy a FloatArray into a specific associated vertex buffer
  77336. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77337. * - VertexBuffer.PositionKind
  77338. * - VertexBuffer.UVKind
  77339. * - VertexBuffer.UV2Kind
  77340. * - VertexBuffer.UV3Kind
  77341. * - VertexBuffer.UV4Kind
  77342. * - VertexBuffer.UV5Kind
  77343. * - VertexBuffer.UV6Kind
  77344. * - VertexBuffer.ColorKind
  77345. * - VertexBuffer.MatricesIndicesKind
  77346. * - VertexBuffer.MatricesIndicesExtraKind
  77347. * - VertexBuffer.MatricesWeightsKind
  77348. * - VertexBuffer.MatricesWeightsExtraKind
  77349. * @param data defines the data source
  77350. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77351. * @param stride defines the data stride size (can be null)
  77352. * @returns the current mesh
  77353. */
  77354. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77355. /**
  77356. * Flags an associated vertex buffer as updatable
  77357. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77358. * - VertexBuffer.PositionKind
  77359. * - VertexBuffer.UVKind
  77360. * - VertexBuffer.UV2Kind
  77361. * - VertexBuffer.UV3Kind
  77362. * - VertexBuffer.UV4Kind
  77363. * - VertexBuffer.UV5Kind
  77364. * - VertexBuffer.UV6Kind
  77365. * - VertexBuffer.ColorKind
  77366. * - VertexBuffer.MatricesIndicesKind
  77367. * - VertexBuffer.MatricesIndicesExtraKind
  77368. * - VertexBuffer.MatricesWeightsKind
  77369. * - VertexBuffer.MatricesWeightsExtraKind
  77370. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77371. */
  77372. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77373. /**
  77374. * Sets the mesh global Vertex Buffer
  77375. * @param buffer defines the buffer to use
  77376. * @returns the current mesh
  77377. */
  77378. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77379. /**
  77380. * Update a specific associated vertex buffer
  77381. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77382. * - VertexBuffer.PositionKind
  77383. * - VertexBuffer.UVKind
  77384. * - VertexBuffer.UV2Kind
  77385. * - VertexBuffer.UV3Kind
  77386. * - VertexBuffer.UV4Kind
  77387. * - VertexBuffer.UV5Kind
  77388. * - VertexBuffer.UV6Kind
  77389. * - VertexBuffer.ColorKind
  77390. * - VertexBuffer.MatricesIndicesKind
  77391. * - VertexBuffer.MatricesIndicesExtraKind
  77392. * - VertexBuffer.MatricesWeightsKind
  77393. * - VertexBuffer.MatricesWeightsExtraKind
  77394. * @param data defines the data source
  77395. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77396. * @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)
  77397. * @returns the current mesh
  77398. */
  77399. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77400. /**
  77401. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77402. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77403. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77404. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77405. * @returns the current mesh
  77406. */
  77407. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77408. /**
  77409. * Creates a un-shared specific occurence of the geometry for the mesh.
  77410. * @returns the current mesh
  77411. */
  77412. makeGeometryUnique(): Mesh;
  77413. /**
  77414. * Set the index buffer of this mesh
  77415. * @param indices defines the source data
  77416. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77417. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77418. * @returns the current mesh
  77419. */
  77420. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77421. /**
  77422. * Update the current index buffer
  77423. * @param indices defines the source data
  77424. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77425. * @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)
  77426. * @returns the current mesh
  77427. */
  77428. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  77429. /**
  77430. * Invert the geometry to move from a right handed system to a left handed one.
  77431. * @returns the current mesh
  77432. */
  77433. toLeftHanded(): Mesh;
  77434. /** @hidden */
  77435. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77436. /** @hidden */
  77437. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  77438. /**
  77439. * Registers for this mesh a javascript function called just before the rendering process
  77440. * @param func defines the function to call before rendering this mesh
  77441. * @returns the current mesh
  77442. */
  77443. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77444. /**
  77445. * Disposes a previously registered javascript function called before the rendering
  77446. * @param func defines the function to remove
  77447. * @returns the current mesh
  77448. */
  77449. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77450. /**
  77451. * Registers for this mesh a javascript function called just after the rendering is complete
  77452. * @param func defines the function to call after rendering this mesh
  77453. * @returns the current mesh
  77454. */
  77455. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77456. /**
  77457. * Disposes a previously registered javascript function called after the rendering.
  77458. * @param func defines the function to remove
  77459. * @returns the current mesh
  77460. */
  77461. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77462. /** @hidden */
  77463. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77464. /** @hidden */
  77465. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77466. /** @hidden */
  77467. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77468. /** @hidden */
  77469. _rebuild(): void;
  77470. /** @hidden */
  77471. _freeze(): void;
  77472. /** @hidden */
  77473. _unFreeze(): void;
  77474. /**
  77475. * 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
  77476. * @param subMesh defines the subMesh to render
  77477. * @param enableAlphaMode defines if alpha mode can be changed
  77478. * @returns the current mesh
  77479. */
  77480. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77481. private _onBeforeDraw;
  77482. /**
  77483. * Renormalize the mesh and patch it up if there are no weights
  77484. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77485. * However in the case of zero weights then we set just a single influence to 1.
  77486. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77487. */
  77488. cleanMatrixWeights(): void;
  77489. private normalizeSkinFourWeights;
  77490. private normalizeSkinWeightsAndExtra;
  77491. /**
  77492. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77493. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77494. * the user know there was an issue with importing the mesh
  77495. * @returns a validation object with skinned, valid and report string
  77496. */
  77497. validateSkinning(): {
  77498. skinned: boolean;
  77499. valid: boolean;
  77500. report: string;
  77501. };
  77502. /** @hidden */
  77503. _checkDelayState(): Mesh;
  77504. private _queueLoad;
  77505. /**
  77506. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77507. * A mesh is in the frustum if its bounding box intersects the frustum
  77508. * @param frustumPlanes defines the frustum to test
  77509. * @returns true if the mesh is in the frustum planes
  77510. */
  77511. isInFrustum(frustumPlanes: Plane[]): boolean;
  77512. /**
  77513. * Sets the mesh material by the material or multiMaterial `id` property
  77514. * @param id is a string identifying the material or the multiMaterial
  77515. * @returns the current mesh
  77516. */
  77517. setMaterialByID(id: string): Mesh;
  77518. /**
  77519. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77520. * @returns an array of IAnimatable
  77521. */
  77522. getAnimatables(): IAnimatable[];
  77523. /**
  77524. * Modifies the mesh geometry according to the passed transformation matrix.
  77525. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77526. * The mesh normals are modified using the same transformation.
  77527. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77528. * @param transform defines the transform matrix to use
  77529. * @see http://doc.babylonjs.com/resources/baking_transformations
  77530. * @returns the current mesh
  77531. */
  77532. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77533. /**
  77534. * Modifies the mesh geometry according to its own current World Matrix.
  77535. * The mesh World Matrix is then reset.
  77536. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77537. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77538. * @see http://doc.babylonjs.com/resources/baking_transformations
  77539. * @returns the current mesh
  77540. */
  77541. bakeCurrentTransformIntoVertices(): Mesh;
  77542. /** @hidden */
  77543. readonly _positions: Nullable<Vector3[]>;
  77544. /** @hidden */
  77545. _resetPointsArrayCache(): Mesh;
  77546. /** @hidden */
  77547. _generatePointsArray(): boolean;
  77548. /**
  77549. * Returns a new Mesh object generated from the current mesh properties.
  77550. * This method must not get confused with createInstance()
  77551. * @param name is a string, the name given to the new mesh
  77552. * @param newParent can be any Node object (default `null`)
  77553. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77554. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77555. * @returns a new mesh
  77556. */
  77557. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77558. /**
  77559. * Releases resources associated with this mesh.
  77560. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77561. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77562. */
  77563. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77564. /**
  77565. * Modifies the mesh geometry according to a displacement map.
  77566. * 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.
  77567. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77568. * @param url is a string, the URL from the image file is to be downloaded.
  77569. * @param minHeight is the lower limit of the displacement.
  77570. * @param maxHeight is the upper limit of the displacement.
  77571. * @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.
  77572. * @param uvOffset is an optional vector2 used to offset UV.
  77573. * @param uvScale is an optional vector2 used to scale UV.
  77574. * @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.
  77575. * @returns the Mesh.
  77576. */
  77577. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77578. /**
  77579. * Modifies the mesh geometry according to a displacementMap buffer.
  77580. * 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.
  77581. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77582. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77583. * @param heightMapWidth is the width of the buffer image.
  77584. * @param heightMapHeight is the height of the buffer image.
  77585. * @param minHeight is the lower limit of the displacement.
  77586. * @param maxHeight is the upper limit of the displacement.
  77587. * @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.
  77588. * @param uvOffset is an optional vector2 used to offset UV.
  77589. * @param uvScale is an optional vector2 used to scale UV.
  77590. * @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.
  77591. * @returns the Mesh.
  77592. */
  77593. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77594. /**
  77595. * Modify the mesh to get a flat shading rendering.
  77596. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77597. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77598. * @returns current mesh
  77599. */
  77600. convertToFlatShadedMesh(): Mesh;
  77601. /**
  77602. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77603. * In other words, more vertices, no more indices and a single bigger VBO.
  77604. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77605. * @returns current mesh
  77606. */
  77607. convertToUnIndexedMesh(): Mesh;
  77608. /**
  77609. * Inverses facet orientations.
  77610. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77611. * @param flipNormals will also inverts the normals
  77612. * @returns current mesh
  77613. */
  77614. flipFaces(flipNormals?: boolean): Mesh;
  77615. /**
  77616. * Increase the number of facets and hence vertices in a mesh
  77617. * Vertex normals are interpolated from existing vertex normals
  77618. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77619. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  77620. */
  77621. increaseVertices(numberPerEdge: number): void;
  77622. /**
  77623. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  77624. * This will undo any application of covertToFlatShadedMesh
  77625. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77626. */
  77627. forceSharedVertices(): void;
  77628. /** @hidden */
  77629. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77630. /** @hidden */
  77631. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77632. /**
  77633. * Creates a new InstancedMesh object from the mesh model.
  77634. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77635. * @param name defines the name of the new instance
  77636. * @returns a new InstancedMesh
  77637. */
  77638. createInstance(name: string): InstancedMesh;
  77639. /**
  77640. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77641. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77642. * @returns the current mesh
  77643. */
  77644. synchronizeInstances(): Mesh;
  77645. /**
  77646. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77647. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77648. * This should be used together with the simplification to avoid disappearing triangles.
  77649. * @param successCallback an optional success callback to be called after the optimization finished.
  77650. * @returns the current mesh
  77651. */
  77652. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77653. /**
  77654. * Serialize current mesh
  77655. * @param serializationObject defines the object which will receive the serialization data
  77656. */
  77657. serialize(serializationObject: any): void;
  77658. /** @hidden */
  77659. _syncGeometryWithMorphTargetManager(): void;
  77660. /** @hidden */
  77661. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77662. /**
  77663. * Returns a new Mesh object parsed from the source provided.
  77664. * @param parsedMesh is the source
  77665. * @param scene defines the hosting scene
  77666. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77667. * @returns a new Mesh
  77668. */
  77669. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77670. /**
  77671. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77672. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77673. * @param name defines the name of the mesh to create
  77674. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77675. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77676. * @param closePath creates a seam between the first and the last points of each path of the path array
  77677. * @param offset is taken in account only if the `pathArray` is containing a single path
  77678. * @param scene defines the hosting scene
  77679. * @param updatable defines if the mesh must be flagged as updatable
  77680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77681. * @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)
  77682. * @returns a new Mesh
  77683. */
  77684. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77685. /**
  77686. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77687. * @param name defines the name of the mesh to create
  77688. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77689. * @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
  77690. * @param scene defines the hosting scene
  77691. * @param updatable defines if the mesh must be flagged as updatable
  77692. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77693. * @returns a new Mesh
  77694. */
  77695. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77696. /**
  77697. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77698. * @param name defines the name of the mesh to create
  77699. * @param size sets the size (float) of each box side (default 1)
  77700. * @param scene defines the hosting scene
  77701. * @param updatable defines if the mesh must be flagged as updatable
  77702. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77703. * @returns a new Mesh
  77704. */
  77705. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77706. /**
  77707. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77708. * @param name defines the name of the mesh to create
  77709. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77710. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77711. * @param scene defines the hosting scene
  77712. * @param updatable defines if the mesh must be flagged as updatable
  77713. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77714. * @returns a new Mesh
  77715. */
  77716. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77717. /**
  77718. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  77719. * @param name defines the name of the mesh to create
  77720. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77721. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77722. * @param scene defines the hosting scene
  77723. * @returns a new Mesh
  77724. */
  77725. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  77726. /**
  77727. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77728. * @param name defines the name of the mesh to create
  77729. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77730. * @param diameterTop set the top cap diameter (floats, default 1)
  77731. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77732. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77733. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77734. * @param scene defines the hosting scene
  77735. * @param updatable defines if the mesh must be flagged as updatable
  77736. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77737. * @returns a new Mesh
  77738. */
  77739. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77740. /**
  77741. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77742. * @param name defines the name of the mesh to create
  77743. * @param diameter sets the diameter size (float) of the torus (default 1)
  77744. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77745. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77746. * @param scene defines the hosting scene
  77747. * @param updatable defines if the mesh must be flagged as updatable
  77748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77749. * @returns a new Mesh
  77750. */
  77751. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77752. /**
  77753. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77754. * @param name defines the name of the mesh to create
  77755. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77756. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77757. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77758. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77759. * @param p the number of windings on X axis (positive integers, default 2)
  77760. * @param q the number of windings on Y axis (positive integers, default 3)
  77761. * @param scene defines the hosting scene
  77762. * @param updatable defines if the mesh must be flagged as updatable
  77763. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77764. * @returns a new Mesh
  77765. */
  77766. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77767. /**
  77768. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77769. * @param name defines the name of the mesh to create
  77770. * @param points is an array successive Vector3
  77771. * @param scene defines the hosting scene
  77772. * @param updatable defines if the mesh must be flagged as updatable
  77773. * @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).
  77774. * @returns a new Mesh
  77775. */
  77776. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77777. /**
  77778. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77779. * @param name defines the name of the mesh to create
  77780. * @param points is an array successive Vector3
  77781. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77782. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77783. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77784. * @param scene defines the hosting scene
  77785. * @param updatable defines if the mesh must be flagged as updatable
  77786. * @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)
  77787. * @returns a new Mesh
  77788. */
  77789. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77790. /**
  77791. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77792. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77793. * 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.
  77794. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77795. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77796. * Remember you can only change the shape positions, not their number when updating a polygon.
  77797. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77798. * @param name defines the name of the mesh to create
  77799. * @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
  77800. * @param scene defines the hosting scene
  77801. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77802. * @param updatable defines if the mesh must be flagged as updatable
  77803. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77804. * @param earcutInjection can be used to inject your own earcut reference
  77805. * @returns a new Mesh
  77806. */
  77807. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77808. /**
  77809. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77810. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77811. * @param name defines the name of the mesh to create
  77812. * @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
  77813. * @param depth defines the height of extrusion
  77814. * @param scene defines the hosting scene
  77815. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77816. * @param updatable defines if the mesh must be flagged as updatable
  77817. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77818. * @param earcutInjection can be used to inject your own earcut reference
  77819. * @returns a new Mesh
  77820. */
  77821. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77822. /**
  77823. * Creates an extruded shape mesh.
  77824. * 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
  77825. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77826. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77827. * @param name defines the name of the mesh to create
  77828. * @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
  77829. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77830. * @param scale is the value to scale the shape
  77831. * @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
  77832. * @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
  77833. * @param scene defines the hosting scene
  77834. * @param updatable defines if the mesh must be flagged as updatable
  77835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77836. * @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)
  77837. * @returns a new Mesh
  77838. */
  77839. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77840. /**
  77841. * Creates an custom extruded shape mesh.
  77842. * The custom extrusion is a parametric shape.
  77843. * It has no predefined shape. Its final shape will depend on the input parameters.
  77844. * Please consider using the same method from the MeshBuilder class instead
  77845. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77846. * @param name defines the name of the mesh to create
  77847. * @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
  77848. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77849. * @param scaleFunction is a custom Javascript function called on each path point
  77850. * @param rotationFunction is a custom Javascript function called on each path point
  77851. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77852. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77853. * @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
  77854. * @param scene defines the hosting scene
  77855. * @param updatable defines if the mesh must be flagged as updatable
  77856. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77857. * @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)
  77858. * @returns a new Mesh
  77859. */
  77860. 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;
  77861. /**
  77862. * Creates lathe mesh.
  77863. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77864. * Please consider using the same method from the MeshBuilder class instead
  77865. * @param name defines the name of the mesh to create
  77866. * @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
  77867. * @param radius is the radius value of the lathe
  77868. * @param tessellation is the side number of the lathe.
  77869. * @param scene defines the hosting scene
  77870. * @param updatable defines if the mesh must be flagged as updatable
  77871. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77872. * @returns a new Mesh
  77873. */
  77874. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77875. /**
  77876. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77877. * @param name defines the name of the mesh to create
  77878. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77879. * @param scene defines the hosting scene
  77880. * @param updatable defines if the mesh must be flagged as updatable
  77881. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77882. * @returns a new Mesh
  77883. */
  77884. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77885. /**
  77886. * Creates a ground mesh.
  77887. * Please consider using the same method from the MeshBuilder class instead
  77888. * @param name defines the name of the mesh to create
  77889. * @param width set the width of the ground
  77890. * @param height set the height of the ground
  77891. * @param subdivisions sets the number of subdivisions per side
  77892. * @param scene defines the hosting scene
  77893. * @param updatable defines if the mesh must be flagged as updatable
  77894. * @returns a new Mesh
  77895. */
  77896. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77897. /**
  77898. * Creates a tiled ground mesh.
  77899. * Please consider using the same method from the MeshBuilder class instead
  77900. * @param name defines the name of the mesh to create
  77901. * @param xmin set the ground minimum X coordinate
  77902. * @param zmin set the ground minimum Y coordinate
  77903. * @param xmax set the ground maximum X coordinate
  77904. * @param zmax set the ground maximum Z coordinate
  77905. * @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
  77906. * @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
  77907. * @param scene defines the hosting scene
  77908. * @param updatable defines if the mesh must be flagged as updatable
  77909. * @returns a new Mesh
  77910. */
  77911. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77912. w: number;
  77913. h: number;
  77914. }, precision: {
  77915. w: number;
  77916. h: number;
  77917. }, scene: Scene, updatable?: boolean): Mesh;
  77918. /**
  77919. * Creates a ground mesh from a height map.
  77920. * Please consider using the same method from the MeshBuilder class instead
  77921. * @see http://doc.babylonjs.com/babylon101/height_map
  77922. * @param name defines the name of the mesh to create
  77923. * @param url sets the URL of the height map image resource
  77924. * @param width set the ground width size
  77925. * @param height set the ground height size
  77926. * @param subdivisions sets the number of subdivision per side
  77927. * @param minHeight is the minimum altitude on the ground
  77928. * @param maxHeight is the maximum altitude on the ground
  77929. * @param scene defines the hosting scene
  77930. * @param updatable defines if the mesh must be flagged as updatable
  77931. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77932. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77933. * @returns a new Mesh
  77934. */
  77935. 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;
  77936. /**
  77937. * Creates a tube mesh.
  77938. * The tube is a parametric shape.
  77939. * It has no predefined shape. Its final shape will depend on the input parameters.
  77940. * Please consider using the same method from the MeshBuilder class instead
  77941. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77942. * @param name defines the name of the mesh to create
  77943. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77944. * @param radius sets the tube radius size
  77945. * @param tessellation is the number of sides on the tubular surface
  77946. * @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
  77947. * @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
  77948. * @param scene defines the hosting scene
  77949. * @param updatable defines if the mesh must be flagged as updatable
  77950. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77951. * @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)
  77952. * @returns a new Mesh
  77953. */
  77954. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77955. (i: number, distance: number): number;
  77956. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77957. /**
  77958. * Creates a polyhedron mesh.
  77959. * Please consider using the same method from the MeshBuilder class instead.
  77960. * * 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
  77961. * * The parameter `size` (positive float, default 1) sets the polygon size
  77962. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77963. * * 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`
  77964. * * 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
  77965. * * 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)`)
  77966. * * 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
  77967. * * 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
  77968. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77969. * * If you create a double-sided mesh, you can choose what parts of 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
  77970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77971. * @param name defines the name of the mesh to create
  77972. * @param options defines the options used to create the mesh
  77973. * @param scene defines the hosting scene
  77974. * @returns a new Mesh
  77975. */
  77976. static CreatePolyhedron(name: string, options: {
  77977. type?: number;
  77978. size?: number;
  77979. sizeX?: number;
  77980. sizeY?: number;
  77981. sizeZ?: number;
  77982. custom?: any;
  77983. faceUV?: Vector4[];
  77984. faceColors?: Color4[];
  77985. updatable?: boolean;
  77986. sideOrientation?: number;
  77987. }, scene: Scene): Mesh;
  77988. /**
  77989. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77990. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77991. * * 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`)
  77992. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77993. * * 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
  77994. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77995. * * If you create a double-sided mesh, you can choose what parts of 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
  77996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77997. * @param name defines the name of the mesh
  77998. * @param options defines the options used to create the mesh
  77999. * @param scene defines the hosting scene
  78000. * @returns a new Mesh
  78001. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78002. */
  78003. static CreateIcoSphere(name: string, options: {
  78004. radius?: number;
  78005. flat?: boolean;
  78006. subdivisions?: number;
  78007. sideOrientation?: number;
  78008. updatable?: boolean;
  78009. }, scene: Scene): Mesh;
  78010. /**
  78011. * Creates a decal mesh.
  78012. * Please consider using the same method from the MeshBuilder class instead.
  78013. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78014. * @param name defines the name of the mesh
  78015. * @param sourceMesh defines the mesh receiving the decal
  78016. * @param position sets the position of the decal in world coordinates
  78017. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78018. * @param size sets the decal scaling
  78019. * @param angle sets the angle to rotate the decal
  78020. * @returns a new Mesh
  78021. */
  78022. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78023. /**
  78024. * Prepare internal position array for software CPU skinning
  78025. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78026. */
  78027. setPositionsForCPUSkinning(): Float32Array;
  78028. /**
  78029. * Prepare internal normal array for software CPU skinning
  78030. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78031. */
  78032. setNormalsForCPUSkinning(): Float32Array;
  78033. /**
  78034. * Updates the vertex buffer by applying transformation from the bones
  78035. * @param skeleton defines the skeleton to apply to current mesh
  78036. * @returns the current mesh
  78037. */
  78038. applySkeleton(skeleton: Skeleton): Mesh;
  78039. /**
  78040. * 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
  78041. * @param meshes defines the list of meshes to scan
  78042. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78043. */
  78044. static MinMax(meshes: AbstractMesh[]): {
  78045. min: Vector3;
  78046. max: Vector3;
  78047. };
  78048. /**
  78049. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78050. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78051. * @returns a vector3
  78052. */
  78053. static Center(meshesOrMinMaxVector: {
  78054. min: Vector3;
  78055. max: Vector3;
  78056. } | AbstractMesh[]): Vector3;
  78057. /**
  78058. * Merge the array of meshes into a single mesh for performance reasons.
  78059. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78060. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78061. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78062. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78063. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78064. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78065. * @returns a new mesh
  78066. */
  78067. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78068. /** @hidden */
  78069. addInstance(instance: InstancedMesh): void;
  78070. /** @hidden */
  78071. removeInstance(instance: InstancedMesh): void;
  78072. }
  78073. }
  78074. declare module BABYLON {
  78075. /**
  78076. * Interface used to define Action
  78077. */
  78078. export interface IAction {
  78079. /**
  78080. * Trigger for the action
  78081. */
  78082. trigger: number;
  78083. /** Options of the trigger */
  78084. triggerOptions: any;
  78085. /**
  78086. * Gets the trigger parameters
  78087. * @returns the trigger parameters
  78088. */
  78089. getTriggerParameter(): any;
  78090. /**
  78091. * Internal only - executes current action event
  78092. * @hidden
  78093. */
  78094. _executeCurrent(evt?: ActionEvent): void;
  78095. /**
  78096. * Serialize placeholder for child classes
  78097. * @param parent of child
  78098. * @returns the serialized object
  78099. */
  78100. serialize(parent: any): any;
  78101. /**
  78102. * Internal only
  78103. * @hidden
  78104. */
  78105. _prepare(): void;
  78106. /**
  78107. * Internal only - manager for action
  78108. * @hidden
  78109. */
  78110. _actionManager: AbstractActionManager;
  78111. /**
  78112. * Adds action to chain of actions, may be a DoNothingAction
  78113. * @param action defines the next action to execute
  78114. * @returns The action passed in
  78115. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78116. */
  78117. then(action: IAction): IAction;
  78118. }
  78119. /**
  78120. * The action to be carried out following a trigger
  78121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78122. */
  78123. export class Action implements IAction {
  78124. /** the trigger, with or without parameters, for the action */
  78125. triggerOptions: any;
  78126. /**
  78127. * Trigger for the action
  78128. */
  78129. trigger: number;
  78130. /**
  78131. * Internal only - manager for action
  78132. * @hidden
  78133. */
  78134. _actionManager: ActionManager;
  78135. private _nextActiveAction;
  78136. private _child;
  78137. private _condition?;
  78138. private _triggerParameter;
  78139. /**
  78140. * An event triggered prior to action being executed.
  78141. */
  78142. onBeforeExecuteObservable: Observable<Action>;
  78143. /**
  78144. * Creates a new Action
  78145. * @param triggerOptions the trigger, with or without parameters, for the action
  78146. * @param condition an optional determinant of action
  78147. */
  78148. constructor(
  78149. /** the trigger, with or without parameters, for the action */
  78150. triggerOptions: any, condition?: Condition);
  78151. /**
  78152. * Internal only
  78153. * @hidden
  78154. */
  78155. _prepare(): void;
  78156. /**
  78157. * Gets the trigger parameters
  78158. * @returns the trigger parameters
  78159. */
  78160. getTriggerParameter(): any;
  78161. /**
  78162. * Internal only - executes current action event
  78163. * @hidden
  78164. */
  78165. _executeCurrent(evt?: ActionEvent): void;
  78166. /**
  78167. * Execute placeholder for child classes
  78168. * @param evt optional action event
  78169. */
  78170. execute(evt?: ActionEvent): void;
  78171. /**
  78172. * Skips to next active action
  78173. */
  78174. skipToNextActiveAction(): void;
  78175. /**
  78176. * Adds action to chain of actions, may be a DoNothingAction
  78177. * @param action defines the next action to execute
  78178. * @returns The action passed in
  78179. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78180. */
  78181. then(action: Action): Action;
  78182. /**
  78183. * Internal only
  78184. * @hidden
  78185. */
  78186. _getProperty(propertyPath: string): string;
  78187. /**
  78188. * Internal only
  78189. * @hidden
  78190. */
  78191. _getEffectiveTarget(target: any, propertyPath: string): any;
  78192. /**
  78193. * Serialize placeholder for child classes
  78194. * @param parent of child
  78195. * @returns the serialized object
  78196. */
  78197. serialize(parent: any): any;
  78198. /**
  78199. * Internal only called by serialize
  78200. * @hidden
  78201. */
  78202. protected _serialize(serializedAction: any, parent?: any): any;
  78203. /**
  78204. * Internal only
  78205. * @hidden
  78206. */
  78207. static _SerializeValueAsString: (value: any) => string;
  78208. /**
  78209. * Internal only
  78210. * @hidden
  78211. */
  78212. static _GetTargetProperty: (target: Scene | Node) => {
  78213. name: string;
  78214. targetType: string;
  78215. value: string;
  78216. };
  78217. }
  78218. }
  78219. declare module BABYLON {
  78220. /**
  78221. * A Condition applied to an Action
  78222. */
  78223. export class Condition {
  78224. /**
  78225. * Internal only - manager for action
  78226. * @hidden
  78227. */
  78228. _actionManager: ActionManager;
  78229. /**
  78230. * Internal only
  78231. * @hidden
  78232. */
  78233. _evaluationId: number;
  78234. /**
  78235. * Internal only
  78236. * @hidden
  78237. */
  78238. _currentResult: boolean;
  78239. /**
  78240. * Creates a new Condition
  78241. * @param actionManager the manager of the action the condition is applied to
  78242. */
  78243. constructor(actionManager: ActionManager);
  78244. /**
  78245. * Check if the current condition is valid
  78246. * @returns a boolean
  78247. */
  78248. isValid(): boolean;
  78249. /**
  78250. * Internal only
  78251. * @hidden
  78252. */
  78253. _getProperty(propertyPath: string): string;
  78254. /**
  78255. * Internal only
  78256. * @hidden
  78257. */
  78258. _getEffectiveTarget(target: any, propertyPath: string): any;
  78259. /**
  78260. * Serialize placeholder for child classes
  78261. * @returns the serialized object
  78262. */
  78263. serialize(): any;
  78264. /**
  78265. * Internal only
  78266. * @hidden
  78267. */
  78268. protected _serialize(serializedCondition: any): any;
  78269. }
  78270. /**
  78271. * Defines specific conditional operators as extensions of Condition
  78272. */
  78273. export class ValueCondition extends Condition {
  78274. /** path to specify the property of the target the conditional operator uses */
  78275. propertyPath: string;
  78276. /** the value compared by the conditional operator against the current value of the property */
  78277. value: any;
  78278. /** the conditional operator, default ValueCondition.IsEqual */
  78279. operator: number;
  78280. /**
  78281. * Internal only
  78282. * @hidden
  78283. */
  78284. private static _IsEqual;
  78285. /**
  78286. * Internal only
  78287. * @hidden
  78288. */
  78289. private static _IsDifferent;
  78290. /**
  78291. * Internal only
  78292. * @hidden
  78293. */
  78294. private static _IsGreater;
  78295. /**
  78296. * Internal only
  78297. * @hidden
  78298. */
  78299. private static _IsLesser;
  78300. /**
  78301. * returns the number for IsEqual
  78302. */
  78303. static readonly IsEqual: number;
  78304. /**
  78305. * Returns the number for IsDifferent
  78306. */
  78307. static readonly IsDifferent: number;
  78308. /**
  78309. * Returns the number for IsGreater
  78310. */
  78311. static readonly IsGreater: number;
  78312. /**
  78313. * Returns the number for IsLesser
  78314. */
  78315. static readonly IsLesser: number;
  78316. /**
  78317. * Internal only The action manager for the condition
  78318. * @hidden
  78319. */
  78320. _actionManager: ActionManager;
  78321. /**
  78322. * Internal only
  78323. * @hidden
  78324. */
  78325. private _target;
  78326. /**
  78327. * Internal only
  78328. * @hidden
  78329. */
  78330. private _effectiveTarget;
  78331. /**
  78332. * Internal only
  78333. * @hidden
  78334. */
  78335. private _property;
  78336. /**
  78337. * Creates a new ValueCondition
  78338. * @param actionManager manager for the action the condition applies to
  78339. * @param target for the action
  78340. * @param propertyPath path to specify the property of the target the conditional operator uses
  78341. * @param value the value compared by the conditional operator against the current value of the property
  78342. * @param operator the conditional operator, default ValueCondition.IsEqual
  78343. */
  78344. constructor(actionManager: ActionManager, target: any,
  78345. /** path to specify the property of the target the conditional operator uses */
  78346. propertyPath: string,
  78347. /** the value compared by the conditional operator against the current value of the property */
  78348. value: any,
  78349. /** the conditional operator, default ValueCondition.IsEqual */
  78350. operator?: number);
  78351. /**
  78352. * Compares the given value with the property value for the specified conditional operator
  78353. * @returns the result of the comparison
  78354. */
  78355. isValid(): boolean;
  78356. /**
  78357. * Serialize the ValueCondition into a JSON compatible object
  78358. * @returns serialization object
  78359. */
  78360. serialize(): any;
  78361. /**
  78362. * Gets the name of the conditional operator for the ValueCondition
  78363. * @param operator the conditional operator
  78364. * @returns the name
  78365. */
  78366. static GetOperatorName(operator: number): string;
  78367. }
  78368. /**
  78369. * Defines a predicate condition as an extension of Condition
  78370. */
  78371. export class PredicateCondition extends Condition {
  78372. /** defines the predicate function used to validate the condition */
  78373. predicate: () => boolean;
  78374. /**
  78375. * Internal only - manager for action
  78376. * @hidden
  78377. */
  78378. _actionManager: ActionManager;
  78379. /**
  78380. * Creates a new PredicateCondition
  78381. * @param actionManager manager for the action the condition applies to
  78382. * @param predicate defines the predicate function used to validate the condition
  78383. */
  78384. constructor(actionManager: ActionManager,
  78385. /** defines the predicate function used to validate the condition */
  78386. predicate: () => boolean);
  78387. /**
  78388. * @returns the validity of the predicate condition
  78389. */
  78390. isValid(): boolean;
  78391. }
  78392. /**
  78393. * Defines a state condition as an extension of Condition
  78394. */
  78395. export class StateCondition extends Condition {
  78396. /** Value to compare with target state */
  78397. value: string;
  78398. /**
  78399. * Internal only - manager for action
  78400. * @hidden
  78401. */
  78402. _actionManager: ActionManager;
  78403. /**
  78404. * Internal only
  78405. * @hidden
  78406. */
  78407. private _target;
  78408. /**
  78409. * Creates a new StateCondition
  78410. * @param actionManager manager for the action the condition applies to
  78411. * @param target of the condition
  78412. * @param value to compare with target state
  78413. */
  78414. constructor(actionManager: ActionManager, target: any,
  78415. /** Value to compare with target state */
  78416. value: string);
  78417. /**
  78418. * Gets a boolean indicating if the current condition is met
  78419. * @returns the validity of the state
  78420. */
  78421. isValid(): boolean;
  78422. /**
  78423. * Serialize the StateCondition into a JSON compatible object
  78424. * @returns serialization object
  78425. */
  78426. serialize(): any;
  78427. }
  78428. }
  78429. declare module BABYLON {
  78430. /**
  78431. * This defines an action responsible to toggle a boolean once triggered.
  78432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78433. */
  78434. export class SwitchBooleanAction extends Action {
  78435. /**
  78436. * The path to the boolean property in the target object
  78437. */
  78438. propertyPath: string;
  78439. private _target;
  78440. private _effectiveTarget;
  78441. private _property;
  78442. /**
  78443. * Instantiate the action
  78444. * @param triggerOptions defines the trigger options
  78445. * @param target defines the object containing the boolean
  78446. * @param propertyPath defines the path to the boolean property in the target object
  78447. * @param condition defines the trigger related conditions
  78448. */
  78449. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78450. /** @hidden */
  78451. _prepare(): void;
  78452. /**
  78453. * Execute the action toggle the boolean value.
  78454. */
  78455. execute(): void;
  78456. /**
  78457. * Serializes the actions and its related information.
  78458. * @param parent defines the object to serialize in
  78459. * @returns the serialized object
  78460. */
  78461. serialize(parent: any): any;
  78462. }
  78463. /**
  78464. * This defines an action responsible to set a the state field of the target
  78465. * to a desired value once triggered.
  78466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78467. */
  78468. export class SetStateAction extends Action {
  78469. /**
  78470. * The value to store in the state field.
  78471. */
  78472. value: string;
  78473. private _target;
  78474. /**
  78475. * Instantiate the action
  78476. * @param triggerOptions defines the trigger options
  78477. * @param target defines the object containing the state property
  78478. * @param value defines the value to store in the state field
  78479. * @param condition defines the trigger related conditions
  78480. */
  78481. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78482. /**
  78483. * Execute the action and store the value on the target state property.
  78484. */
  78485. execute(): void;
  78486. /**
  78487. * Serializes the actions and its related information.
  78488. * @param parent defines the object to serialize in
  78489. * @returns the serialized object
  78490. */
  78491. serialize(parent: any): any;
  78492. }
  78493. /**
  78494. * This defines an action responsible to set a property of the target
  78495. * to a desired value once triggered.
  78496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78497. */
  78498. export class SetValueAction extends Action {
  78499. /**
  78500. * The path of the property to set in the target.
  78501. */
  78502. propertyPath: string;
  78503. /**
  78504. * The value to set in the property
  78505. */
  78506. value: any;
  78507. private _target;
  78508. private _effectiveTarget;
  78509. private _property;
  78510. /**
  78511. * Instantiate the action
  78512. * @param triggerOptions defines the trigger options
  78513. * @param target defines the object containing the property
  78514. * @param propertyPath defines the path of the property to set in the target
  78515. * @param value defines the value to set in the property
  78516. * @param condition defines the trigger related conditions
  78517. */
  78518. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78519. /** @hidden */
  78520. _prepare(): void;
  78521. /**
  78522. * Execute the action and set the targetted property to the desired value.
  78523. */
  78524. execute(): void;
  78525. /**
  78526. * Serializes the actions and its related information.
  78527. * @param parent defines the object to serialize in
  78528. * @returns the serialized object
  78529. */
  78530. serialize(parent: any): any;
  78531. }
  78532. /**
  78533. * This defines an action responsible to increment the target value
  78534. * to a desired value once triggered.
  78535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78536. */
  78537. export class IncrementValueAction extends Action {
  78538. /**
  78539. * The path of the property to increment in the target.
  78540. */
  78541. propertyPath: string;
  78542. /**
  78543. * The value we should increment the property by.
  78544. */
  78545. value: any;
  78546. private _target;
  78547. private _effectiveTarget;
  78548. private _property;
  78549. /**
  78550. * Instantiate the action
  78551. * @param triggerOptions defines the trigger options
  78552. * @param target defines the object containing the property
  78553. * @param propertyPath defines the path of the property to increment in the target
  78554. * @param value defines the value value we should increment the property by
  78555. * @param condition defines the trigger related conditions
  78556. */
  78557. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78558. /** @hidden */
  78559. _prepare(): void;
  78560. /**
  78561. * Execute the action and increment the target of the value amount.
  78562. */
  78563. execute(): void;
  78564. /**
  78565. * Serializes the actions and its related information.
  78566. * @param parent defines the object to serialize in
  78567. * @returns the serialized object
  78568. */
  78569. serialize(parent: any): any;
  78570. }
  78571. /**
  78572. * This defines an action responsible to start an animation once triggered.
  78573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78574. */
  78575. export class PlayAnimationAction extends Action {
  78576. /**
  78577. * Where the animation should start (animation frame)
  78578. */
  78579. from: number;
  78580. /**
  78581. * Where the animation should stop (animation frame)
  78582. */
  78583. to: number;
  78584. /**
  78585. * Define if the animation should loop or stop after the first play.
  78586. */
  78587. loop?: boolean;
  78588. private _target;
  78589. /**
  78590. * Instantiate the action
  78591. * @param triggerOptions defines the trigger options
  78592. * @param target defines the target animation or animation name
  78593. * @param from defines from where the animation should start (animation frame)
  78594. * @param end defines where the animation should stop (animation frame)
  78595. * @param loop defines if the animation should loop or stop after the first play
  78596. * @param condition defines the trigger related conditions
  78597. */
  78598. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78599. /** @hidden */
  78600. _prepare(): void;
  78601. /**
  78602. * Execute the action and play the animation.
  78603. */
  78604. execute(): void;
  78605. /**
  78606. * Serializes the actions and its related information.
  78607. * @param parent defines the object to serialize in
  78608. * @returns the serialized object
  78609. */
  78610. serialize(parent: any): any;
  78611. }
  78612. /**
  78613. * This defines an action responsible to stop an animation once triggered.
  78614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78615. */
  78616. export class StopAnimationAction extends Action {
  78617. private _target;
  78618. /**
  78619. * Instantiate the action
  78620. * @param triggerOptions defines the trigger options
  78621. * @param target defines the target animation or animation name
  78622. * @param condition defines the trigger related conditions
  78623. */
  78624. constructor(triggerOptions: any, target: any, condition?: Condition);
  78625. /** @hidden */
  78626. _prepare(): void;
  78627. /**
  78628. * Execute the action and stop the animation.
  78629. */
  78630. execute(): void;
  78631. /**
  78632. * Serializes the actions and its related information.
  78633. * @param parent defines the object to serialize in
  78634. * @returns the serialized object
  78635. */
  78636. serialize(parent: any): any;
  78637. }
  78638. /**
  78639. * This defines an action responsible that does nothing once triggered.
  78640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78641. */
  78642. export class DoNothingAction extends Action {
  78643. /**
  78644. * Instantiate the action
  78645. * @param triggerOptions defines the trigger options
  78646. * @param condition defines the trigger related conditions
  78647. */
  78648. constructor(triggerOptions?: any, condition?: Condition);
  78649. /**
  78650. * Execute the action and do nothing.
  78651. */
  78652. execute(): void;
  78653. /**
  78654. * Serializes the actions and its related information.
  78655. * @param parent defines the object to serialize in
  78656. * @returns the serialized object
  78657. */
  78658. serialize(parent: any): any;
  78659. }
  78660. /**
  78661. * This defines an action responsible to trigger several actions once triggered.
  78662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78663. */
  78664. export class CombineAction extends Action {
  78665. /**
  78666. * The list of aggregated animations to run.
  78667. */
  78668. children: Action[];
  78669. /**
  78670. * Instantiate the action
  78671. * @param triggerOptions defines the trigger options
  78672. * @param children defines the list of aggregated animations to run
  78673. * @param condition defines the trigger related conditions
  78674. */
  78675. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78676. /** @hidden */
  78677. _prepare(): void;
  78678. /**
  78679. * Execute the action and executes all the aggregated actions.
  78680. */
  78681. execute(evt: ActionEvent): void;
  78682. /**
  78683. * Serializes the actions and its related information.
  78684. * @param parent defines the object to serialize in
  78685. * @returns the serialized object
  78686. */
  78687. serialize(parent: any): any;
  78688. }
  78689. /**
  78690. * This defines an action responsible to run code (external event) once triggered.
  78691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78692. */
  78693. export class ExecuteCodeAction extends Action {
  78694. /**
  78695. * The callback function to run.
  78696. */
  78697. func: (evt: ActionEvent) => void;
  78698. /**
  78699. * Instantiate the action
  78700. * @param triggerOptions defines the trigger options
  78701. * @param func defines the callback function to run
  78702. * @param condition defines the trigger related conditions
  78703. */
  78704. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78705. /**
  78706. * Execute the action and run the attached code.
  78707. */
  78708. execute(evt: ActionEvent): void;
  78709. }
  78710. /**
  78711. * This defines an action responsible to set the parent property of the target once triggered.
  78712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78713. */
  78714. export class SetParentAction extends Action {
  78715. private _parent;
  78716. private _target;
  78717. /**
  78718. * Instantiate the action
  78719. * @param triggerOptions defines the trigger options
  78720. * @param target defines the target containing the parent property
  78721. * @param parent defines from where the animation should start (animation frame)
  78722. * @param condition defines the trigger related conditions
  78723. */
  78724. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78725. /** @hidden */
  78726. _prepare(): void;
  78727. /**
  78728. * Execute the action and set the parent property.
  78729. */
  78730. execute(): void;
  78731. /**
  78732. * Serializes the actions and its related information.
  78733. * @param parent defines the object to serialize in
  78734. * @returns the serialized object
  78735. */
  78736. serialize(parent: any): any;
  78737. }
  78738. }
  78739. declare module BABYLON {
  78740. /**
  78741. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78742. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78744. */
  78745. export class ActionManager extends AbstractActionManager {
  78746. /**
  78747. * Nothing
  78748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78749. */
  78750. static readonly NothingTrigger: number;
  78751. /**
  78752. * On pick
  78753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78754. */
  78755. static readonly OnPickTrigger: number;
  78756. /**
  78757. * On left pick
  78758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78759. */
  78760. static readonly OnLeftPickTrigger: number;
  78761. /**
  78762. * On right pick
  78763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78764. */
  78765. static readonly OnRightPickTrigger: number;
  78766. /**
  78767. * On center pick
  78768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78769. */
  78770. static readonly OnCenterPickTrigger: number;
  78771. /**
  78772. * On pick down
  78773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78774. */
  78775. static readonly OnPickDownTrigger: number;
  78776. /**
  78777. * On double pick
  78778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78779. */
  78780. static readonly OnDoublePickTrigger: number;
  78781. /**
  78782. * On pick up
  78783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78784. */
  78785. static readonly OnPickUpTrigger: number;
  78786. /**
  78787. * On pick out.
  78788. * This trigger will only be raised if you also declared a OnPickDown
  78789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78790. */
  78791. static readonly OnPickOutTrigger: number;
  78792. /**
  78793. * On long press
  78794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78795. */
  78796. static readonly OnLongPressTrigger: number;
  78797. /**
  78798. * On pointer over
  78799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78800. */
  78801. static readonly OnPointerOverTrigger: number;
  78802. /**
  78803. * On pointer out
  78804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78805. */
  78806. static readonly OnPointerOutTrigger: number;
  78807. /**
  78808. * On every frame
  78809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78810. */
  78811. static readonly OnEveryFrameTrigger: number;
  78812. /**
  78813. * On intersection enter
  78814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78815. */
  78816. static readonly OnIntersectionEnterTrigger: number;
  78817. /**
  78818. * On intersection exit
  78819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78820. */
  78821. static readonly OnIntersectionExitTrigger: number;
  78822. /**
  78823. * On key down
  78824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78825. */
  78826. static readonly OnKeyDownTrigger: number;
  78827. /**
  78828. * On key up
  78829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78830. */
  78831. static readonly OnKeyUpTrigger: number;
  78832. private _scene;
  78833. /**
  78834. * Creates a new action manager
  78835. * @param scene defines the hosting scene
  78836. */
  78837. constructor(scene: Scene);
  78838. /**
  78839. * Releases all associated resources
  78840. */
  78841. dispose(): void;
  78842. /**
  78843. * Gets hosting scene
  78844. * @returns the hosting scene
  78845. */
  78846. getScene(): Scene;
  78847. /**
  78848. * Does this action manager handles actions of any of the given triggers
  78849. * @param triggers defines the triggers to be tested
  78850. * @return a boolean indicating whether one (or more) of the triggers is handled
  78851. */
  78852. hasSpecificTriggers(triggers: number[]): boolean;
  78853. /**
  78854. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78855. * speed.
  78856. * @param triggerA defines the trigger to be tested
  78857. * @param triggerB defines the trigger to be tested
  78858. * @return a boolean indicating whether one (or more) of the triggers is handled
  78859. */
  78860. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78861. /**
  78862. * Does this action manager handles actions of a given trigger
  78863. * @param trigger defines the trigger to be tested
  78864. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78865. * @return whether the trigger is handled
  78866. */
  78867. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78868. /**
  78869. * Does this action manager has pointer triggers
  78870. */
  78871. readonly hasPointerTriggers: boolean;
  78872. /**
  78873. * Does this action manager has pick triggers
  78874. */
  78875. readonly hasPickTriggers: boolean;
  78876. /**
  78877. * Registers an action to this action manager
  78878. * @param action defines the action to be registered
  78879. * @return the action amended (prepared) after registration
  78880. */
  78881. registerAction(action: IAction): Nullable<IAction>;
  78882. /**
  78883. * Unregisters an action to this action manager
  78884. * @param action defines the action to be unregistered
  78885. * @return a boolean indicating whether the action has been unregistered
  78886. */
  78887. unregisterAction(action: IAction): Boolean;
  78888. /**
  78889. * Process a specific trigger
  78890. * @param trigger defines the trigger to process
  78891. * @param evt defines the event details to be processed
  78892. */
  78893. processTrigger(trigger: number, evt?: IActionEvent): void;
  78894. /** @hidden */
  78895. _getEffectiveTarget(target: any, propertyPath: string): any;
  78896. /** @hidden */
  78897. _getProperty(propertyPath: string): string;
  78898. /**
  78899. * Serialize this manager to a JSON object
  78900. * @param name defines the property name to store this manager
  78901. * @returns a JSON representation of this manager
  78902. */
  78903. serialize(name: string): any;
  78904. /**
  78905. * Creates a new ActionManager from a JSON data
  78906. * @param parsedActions defines the JSON data to read from
  78907. * @param object defines the hosting mesh
  78908. * @param scene defines the hosting scene
  78909. */
  78910. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78911. /**
  78912. * Get a trigger name by index
  78913. * @param trigger defines the trigger index
  78914. * @returns a trigger name
  78915. */
  78916. static GetTriggerName(trigger: number): string;
  78917. }
  78918. }
  78919. declare module BABYLON {
  78920. /**
  78921. * Class representing a ray with position and direction
  78922. */
  78923. export class Ray {
  78924. /** origin point */
  78925. origin: Vector3;
  78926. /** direction */
  78927. direction: Vector3;
  78928. /** length of the ray */
  78929. length: number;
  78930. private static readonly TmpVector3;
  78931. private _tmpRay;
  78932. /**
  78933. * Creates a new ray
  78934. * @param origin origin point
  78935. * @param direction direction
  78936. * @param length length of the ray
  78937. */
  78938. constructor(
  78939. /** origin point */
  78940. origin: Vector3,
  78941. /** direction */
  78942. direction: Vector3,
  78943. /** length of the ray */
  78944. length?: number);
  78945. /**
  78946. * Checks if the ray intersects a box
  78947. * @param minimum bound of the box
  78948. * @param maximum bound of the box
  78949. * @param intersectionTreshold extra extend to be added to the box in all direction
  78950. * @returns if the box was hit
  78951. */
  78952. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78953. /**
  78954. * Checks if the ray intersects a box
  78955. * @param box the bounding box to check
  78956. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78957. * @returns if the box was hit
  78958. */
  78959. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78960. /**
  78961. * If the ray hits a sphere
  78962. * @param sphere the bounding sphere to check
  78963. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78964. * @returns true if it hits the sphere
  78965. */
  78966. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78967. /**
  78968. * If the ray hits a triange
  78969. * @param vertex0 triangle vertex
  78970. * @param vertex1 triangle vertex
  78971. * @param vertex2 triangle vertex
  78972. * @returns intersection information if hit
  78973. */
  78974. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78975. /**
  78976. * Checks if ray intersects a plane
  78977. * @param plane the plane to check
  78978. * @returns the distance away it was hit
  78979. */
  78980. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78981. /**
  78982. * Checks if ray intersects a mesh
  78983. * @param mesh the mesh to check
  78984. * @param fastCheck if only the bounding box should checked
  78985. * @returns picking info of the intersecton
  78986. */
  78987. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78988. /**
  78989. * Checks if ray intersects a mesh
  78990. * @param meshes the meshes to check
  78991. * @param fastCheck if only the bounding box should checked
  78992. * @param results array to store result in
  78993. * @returns Array of picking infos
  78994. */
  78995. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78996. private _comparePickingInfo;
  78997. private static smallnum;
  78998. private static rayl;
  78999. /**
  79000. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  79001. * @param sega the first point of the segment to test the intersection against
  79002. * @param segb the second point of the segment to test the intersection against
  79003. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  79004. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  79005. */
  79006. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  79007. /**
  79008. * Update the ray from viewport position
  79009. * @param x position
  79010. * @param y y position
  79011. * @param viewportWidth viewport width
  79012. * @param viewportHeight viewport height
  79013. * @param world world matrix
  79014. * @param view view matrix
  79015. * @param projection projection matrix
  79016. * @returns this ray updated
  79017. */
  79018. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79019. /**
  79020. * Creates a ray with origin and direction of 0,0,0
  79021. * @returns the new ray
  79022. */
  79023. static Zero(): Ray;
  79024. /**
  79025. * Creates a new ray from screen space and viewport
  79026. * @param x position
  79027. * @param y y position
  79028. * @param viewportWidth viewport width
  79029. * @param viewportHeight viewport height
  79030. * @param world world matrix
  79031. * @param view view matrix
  79032. * @param projection projection matrix
  79033. * @returns new ray
  79034. */
  79035. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79036. /**
  79037. * 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
  79038. * transformed to the given world matrix.
  79039. * @param origin The origin point
  79040. * @param end The end point
  79041. * @param world a matrix to transform the ray to. Default is the identity matrix.
  79042. * @returns the new ray
  79043. */
  79044. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  79045. /**
  79046. * Transforms a ray by a matrix
  79047. * @param ray ray to transform
  79048. * @param matrix matrix to apply
  79049. * @returns the resulting new ray
  79050. */
  79051. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  79052. /**
  79053. * Transforms a ray by a matrix
  79054. * @param ray ray to transform
  79055. * @param matrix matrix to apply
  79056. * @param result ray to store result in
  79057. */
  79058. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  79059. /**
  79060. * Unproject a ray from screen space to object space
  79061. * @param sourceX defines the screen space x coordinate to use
  79062. * @param sourceY defines the screen space y coordinate to use
  79063. * @param viewportWidth defines the current width of the viewport
  79064. * @param viewportHeight defines the current height of the viewport
  79065. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79066. * @param view defines the view matrix to use
  79067. * @param projection defines the projection matrix to use
  79068. */
  79069. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  79070. }
  79071. /**
  79072. * Type used to define predicate used to select faces when a mesh intersection is detected
  79073. */
  79074. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79075. interface Scene {
  79076. /** @hidden */
  79077. _tempPickingRay: Nullable<Ray>;
  79078. /** @hidden */
  79079. _cachedRayForTransform: Ray;
  79080. /** @hidden */
  79081. _pickWithRayInverseMatrix: Matrix;
  79082. /** @hidden */
  79083. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79084. /** @hidden */
  79085. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79086. }
  79087. }
  79088. declare module BABYLON {
  79089. interface Scene {
  79090. /** @hidden */
  79091. _pointerOverSprite: Nullable<Sprite>;
  79092. /** @hidden */
  79093. _pickedDownSprite: Nullable<Sprite>;
  79094. /** @hidden */
  79095. _tempSpritePickingRay: Nullable<Ray>;
  79096. /**
  79097. * All of the sprite managers added to this scene
  79098. * @see http://doc.babylonjs.com/babylon101/sprites
  79099. */
  79100. spriteManagers: Array<ISpriteManager>;
  79101. /**
  79102. * An event triggered when sprites rendering is about to start
  79103. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79104. */
  79105. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79106. /**
  79107. * An event triggered when sprites rendering is done
  79108. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79109. */
  79110. onAfterSpritesRenderingObservable: Observable<Scene>;
  79111. /** @hidden */
  79112. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79113. /** Launch a ray to try to pick a sprite in the scene
  79114. * @param x position on screen
  79115. * @param y position on screen
  79116. * @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
  79117. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79118. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79119. * @returns a PickingInfo
  79120. */
  79121. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79122. /** Use the given ray to pick a sprite in the scene
  79123. * @param ray The ray (in world space) to use to pick meshes
  79124. * @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
  79125. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79126. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79127. * @returns a PickingInfo
  79128. */
  79129. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79130. /**
  79131. * Force the sprite under the pointer
  79132. * @param sprite defines the sprite to use
  79133. */
  79134. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79135. /**
  79136. * Gets the sprite under the pointer
  79137. * @returns a Sprite or null if no sprite is under the pointer
  79138. */
  79139. getPointerOverSprite(): Nullable<Sprite>;
  79140. }
  79141. /**
  79142. * Defines the sprite scene component responsible to manage sprites
  79143. * in a given scene.
  79144. */
  79145. export class SpriteSceneComponent implements ISceneComponent {
  79146. /**
  79147. * The component name helpfull to identify the component in the list of scene components.
  79148. */
  79149. readonly name: string;
  79150. /**
  79151. * The scene the component belongs to.
  79152. */
  79153. scene: Scene;
  79154. /** @hidden */
  79155. private _spritePredicate;
  79156. /**
  79157. * Creates a new instance of the component for the given scene
  79158. * @param scene Defines the scene to register the component in
  79159. */
  79160. constructor(scene: Scene);
  79161. /**
  79162. * Registers the component in a given scene
  79163. */
  79164. register(): void;
  79165. /**
  79166. * Rebuilds the elements related to this component in case of
  79167. * context lost for instance.
  79168. */
  79169. rebuild(): void;
  79170. /**
  79171. * Disposes the component and the associated ressources.
  79172. */
  79173. dispose(): void;
  79174. private _pickSpriteButKeepRay;
  79175. private _pointerMove;
  79176. private _pointerDown;
  79177. private _pointerUp;
  79178. }
  79179. }
  79180. declare module BABYLON {
  79181. /** @hidden */
  79182. export var fogFragmentDeclaration: {
  79183. name: string;
  79184. shader: string;
  79185. };
  79186. }
  79187. declare module BABYLON {
  79188. /** @hidden */
  79189. export var fogFragment: {
  79190. name: string;
  79191. shader: string;
  79192. };
  79193. }
  79194. declare module BABYLON {
  79195. /** @hidden */
  79196. export var spritesPixelShader: {
  79197. name: string;
  79198. shader: string;
  79199. };
  79200. }
  79201. declare module BABYLON {
  79202. /** @hidden */
  79203. export var fogVertexDeclaration: {
  79204. name: string;
  79205. shader: string;
  79206. };
  79207. }
  79208. declare module BABYLON {
  79209. /** @hidden */
  79210. export var spritesVertexShader: {
  79211. name: string;
  79212. shader: string;
  79213. };
  79214. }
  79215. declare module BABYLON {
  79216. /**
  79217. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79218. */
  79219. export interface ISpriteManager extends IDisposable {
  79220. /**
  79221. * Restricts the camera to viewing objects with the same layerMask.
  79222. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79223. */
  79224. layerMask: number;
  79225. /**
  79226. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79227. */
  79228. isPickable: boolean;
  79229. /**
  79230. * Specifies the rendering group id for this mesh (0 by default)
  79231. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79232. */
  79233. renderingGroupId: number;
  79234. /**
  79235. * Defines the list of sprites managed by the manager.
  79236. */
  79237. sprites: Array<Sprite>;
  79238. /**
  79239. * Tests the intersection of a sprite with a specific ray.
  79240. * @param ray The ray we are sending to test the collision
  79241. * @param camera The camera space we are sending rays in
  79242. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79243. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79244. * @returns picking info or null.
  79245. */
  79246. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79247. /**
  79248. * Renders the list of sprites on screen.
  79249. */
  79250. render(): void;
  79251. }
  79252. /**
  79253. * Class used to manage multiple sprites on the same spritesheet
  79254. * @see http://doc.babylonjs.com/babylon101/sprites
  79255. */
  79256. export class SpriteManager implements ISpriteManager {
  79257. /** defines the manager's name */
  79258. name: string;
  79259. /** Gets the list of sprites */
  79260. sprites: Sprite[];
  79261. /** Gets or sets the rendering group id (0 by default) */
  79262. renderingGroupId: number;
  79263. /** Gets or sets camera layer mask */
  79264. layerMask: number;
  79265. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79266. fogEnabled: boolean;
  79267. /** Gets or sets a boolean indicating if the sprites are pickable */
  79268. isPickable: boolean;
  79269. /** Defines the default width of a cell in the spritesheet */
  79270. cellWidth: number;
  79271. /** Defines the default height of a cell in the spritesheet */
  79272. cellHeight: number;
  79273. /**
  79274. * An event triggered when the manager is disposed.
  79275. */
  79276. onDisposeObservable: Observable<SpriteManager>;
  79277. private _onDisposeObserver;
  79278. /**
  79279. * Callback called when the manager is disposed
  79280. */
  79281. onDispose: () => void;
  79282. private _capacity;
  79283. private _spriteTexture;
  79284. private _epsilon;
  79285. private _scene;
  79286. private _vertexData;
  79287. private _buffer;
  79288. private _vertexBuffers;
  79289. private _indexBuffer;
  79290. private _effectBase;
  79291. private _effectFog;
  79292. /**
  79293. * Gets or sets the spritesheet texture
  79294. */
  79295. texture: Texture;
  79296. /**
  79297. * Creates a new sprite manager
  79298. * @param name defines the manager's name
  79299. * @param imgUrl defines the sprite sheet url
  79300. * @param capacity defines the maximum allowed number of sprites
  79301. * @param cellSize defines the size of a sprite cell
  79302. * @param scene defines the hosting scene
  79303. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79304. * @param samplingMode defines the smapling mode to use with spritesheet
  79305. */
  79306. constructor(
  79307. /** defines the manager's name */
  79308. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  79309. private _appendSpriteVertex;
  79310. /**
  79311. * Intersects the sprites with a ray
  79312. * @param ray defines the ray to intersect with
  79313. * @param camera defines the current active camera
  79314. * @param predicate defines a predicate used to select candidate sprites
  79315. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79316. * @returns null if no hit or a PickingInfo
  79317. */
  79318. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79319. /**
  79320. * Render all child sprites
  79321. */
  79322. render(): void;
  79323. /**
  79324. * Release associated resources
  79325. */
  79326. dispose(): void;
  79327. }
  79328. }
  79329. declare module BABYLON {
  79330. /**
  79331. * Class used to represent a sprite
  79332. * @see http://doc.babylonjs.com/babylon101/sprites
  79333. */
  79334. export class Sprite {
  79335. /** defines the name */
  79336. name: string;
  79337. /** Gets or sets the current world position */
  79338. position: Vector3;
  79339. /** Gets or sets the main color */
  79340. color: Color4;
  79341. /** Gets or sets the width */
  79342. width: number;
  79343. /** Gets or sets the height */
  79344. height: number;
  79345. /** Gets or sets rotation angle */
  79346. angle: number;
  79347. /** Gets or sets the cell index in the sprite sheet */
  79348. cellIndex: number;
  79349. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79350. invertU: number;
  79351. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79352. invertV: number;
  79353. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79354. disposeWhenFinishedAnimating: boolean;
  79355. /** Gets the list of attached animations */
  79356. animations: Animation[];
  79357. /** Gets or sets a boolean indicating if the sprite can be picked */
  79358. isPickable: boolean;
  79359. /**
  79360. * Gets or sets the associated action manager
  79361. */
  79362. actionManager: Nullable<ActionManager>;
  79363. private _animationStarted;
  79364. private _loopAnimation;
  79365. private _fromIndex;
  79366. private _toIndex;
  79367. private _delay;
  79368. private _direction;
  79369. private _manager;
  79370. private _time;
  79371. private _onAnimationEnd;
  79372. /**
  79373. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79374. */
  79375. isVisible: boolean;
  79376. /**
  79377. * Gets or sets the sprite size
  79378. */
  79379. size: number;
  79380. /**
  79381. * Creates a new Sprite
  79382. * @param name defines the name
  79383. * @param manager defines the manager
  79384. */
  79385. constructor(
  79386. /** defines the name */
  79387. name: string, manager: ISpriteManager);
  79388. /**
  79389. * Starts an animation
  79390. * @param from defines the initial key
  79391. * @param to defines the end key
  79392. * @param loop defines if the animation must loop
  79393. * @param delay defines the start delay (in ms)
  79394. * @param onAnimationEnd defines a callback to call when animation ends
  79395. */
  79396. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79397. /** Stops current animation (if any) */
  79398. stopAnimation(): void;
  79399. /** @hidden */
  79400. _animate(deltaTime: number): void;
  79401. /** Release associated resources */
  79402. dispose(): void;
  79403. }
  79404. }
  79405. declare module BABYLON {
  79406. /**
  79407. * Information about the result of picking within a scene
  79408. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79409. */
  79410. export class PickingInfo {
  79411. /** @hidden */
  79412. _pickingUnavailable: boolean;
  79413. /**
  79414. * If the pick collided with an object
  79415. */
  79416. hit: boolean;
  79417. /**
  79418. * Distance away where the pick collided
  79419. */
  79420. distance: number;
  79421. /**
  79422. * The location of pick collision
  79423. */
  79424. pickedPoint: Nullable<Vector3>;
  79425. /**
  79426. * The mesh corresponding the the pick collision
  79427. */
  79428. pickedMesh: Nullable<AbstractMesh>;
  79429. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79430. bu: number;
  79431. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79432. bv: number;
  79433. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79434. faceId: number;
  79435. /** Id of the the submesh that was picked */
  79436. subMeshId: number;
  79437. /** If a sprite was picked, this will be the sprite the pick collided with */
  79438. pickedSprite: Nullable<Sprite>;
  79439. /**
  79440. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79441. */
  79442. originMesh: Nullable<AbstractMesh>;
  79443. /**
  79444. * The ray that was used to perform the picking.
  79445. */
  79446. ray: Nullable<Ray>;
  79447. /**
  79448. * Gets the normal correspodning to the face the pick collided with
  79449. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79450. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79451. * @returns The normal correspodning to the face the pick collided with
  79452. */
  79453. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79454. /**
  79455. * Gets the texture coordinates of where the pick occured
  79456. * @returns the vector containing the coordnates of the texture
  79457. */
  79458. getTextureCoordinates(): Nullable<Vector2>;
  79459. }
  79460. }
  79461. declare module BABYLON {
  79462. /**
  79463. * Gather the list of pointer event types as constants.
  79464. */
  79465. export class PointerEventTypes {
  79466. /**
  79467. * 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.
  79468. */
  79469. static readonly POINTERDOWN: number;
  79470. /**
  79471. * The pointerup event is fired when a pointer is no longer active.
  79472. */
  79473. static readonly POINTERUP: number;
  79474. /**
  79475. * The pointermove event is fired when a pointer changes coordinates.
  79476. */
  79477. static readonly POINTERMOVE: number;
  79478. /**
  79479. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79480. */
  79481. static readonly POINTERWHEEL: number;
  79482. /**
  79483. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79484. */
  79485. static readonly POINTERPICK: number;
  79486. /**
  79487. * The pointertap event is fired when a the object has been touched and released without drag.
  79488. */
  79489. static readonly POINTERTAP: number;
  79490. /**
  79491. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79492. */
  79493. static readonly POINTERDOUBLETAP: number;
  79494. }
  79495. /**
  79496. * Base class of pointer info types.
  79497. */
  79498. export class PointerInfoBase {
  79499. /**
  79500. * Defines the type of event (PointerEventTypes)
  79501. */
  79502. type: number;
  79503. /**
  79504. * Defines the related dom event
  79505. */
  79506. event: PointerEvent | MouseWheelEvent;
  79507. /**
  79508. * Instantiates the base class of pointers info.
  79509. * @param type Defines the type of event (PointerEventTypes)
  79510. * @param event Defines the related dom event
  79511. */
  79512. constructor(
  79513. /**
  79514. * Defines the type of event (PointerEventTypes)
  79515. */
  79516. type: number,
  79517. /**
  79518. * Defines the related dom event
  79519. */
  79520. event: PointerEvent | MouseWheelEvent);
  79521. }
  79522. /**
  79523. * This class is used to store pointer related info for the onPrePointerObservable event.
  79524. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79525. */
  79526. export class PointerInfoPre extends PointerInfoBase {
  79527. /**
  79528. * Ray from a pointer if availible (eg. 6dof controller)
  79529. */
  79530. ray: Nullable<Ray>;
  79531. /**
  79532. * Defines the local position of the pointer on the canvas.
  79533. */
  79534. localPosition: Vector2;
  79535. /**
  79536. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79537. */
  79538. skipOnPointerObservable: boolean;
  79539. /**
  79540. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79541. * @param type Defines the type of event (PointerEventTypes)
  79542. * @param event Defines the related dom event
  79543. * @param localX Defines the local x coordinates of the pointer when the event occured
  79544. * @param localY Defines the local y coordinates of the pointer when the event occured
  79545. */
  79546. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79547. }
  79548. /**
  79549. * This type contains all the data related to a pointer event in Babylon.js.
  79550. * 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.
  79551. */
  79552. export class PointerInfo extends PointerInfoBase {
  79553. /**
  79554. * Defines the picking info associated to the info (if any)\
  79555. */
  79556. pickInfo: Nullable<PickingInfo>;
  79557. /**
  79558. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79559. * @param type Defines the type of event (PointerEventTypes)
  79560. * @param event Defines the related dom event
  79561. * @param pickInfo Defines the picking info associated to the info (if any)\
  79562. */
  79563. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79564. /**
  79565. * Defines the picking info associated to the info (if any)\
  79566. */
  79567. pickInfo: Nullable<PickingInfo>);
  79568. }
  79569. /**
  79570. * Data relating to a touch event on the screen.
  79571. */
  79572. export interface PointerTouch {
  79573. /**
  79574. * X coordinate of touch.
  79575. */
  79576. x: number;
  79577. /**
  79578. * Y coordinate of touch.
  79579. */
  79580. y: number;
  79581. /**
  79582. * Id of touch. Unique for each finger.
  79583. */
  79584. pointerId: number;
  79585. /**
  79586. * Event type passed from DOM.
  79587. */
  79588. type: any;
  79589. }
  79590. }
  79591. declare module BABYLON {
  79592. /**
  79593. * Manage the mouse inputs to control the movement of a free camera.
  79594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79595. */
  79596. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79597. /**
  79598. * Define if touch is enabled in the mouse input
  79599. */
  79600. touchEnabled: boolean;
  79601. /**
  79602. * Defines the camera the input is attached to.
  79603. */
  79604. camera: FreeCamera;
  79605. /**
  79606. * Defines the buttons associated with the input to handle camera move.
  79607. */
  79608. buttons: number[];
  79609. /**
  79610. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79611. */
  79612. angularSensibility: number;
  79613. private _pointerInput;
  79614. private _onMouseMove;
  79615. private _observer;
  79616. private previousPosition;
  79617. /**
  79618. * Observable for when a pointer move event occurs containing the move offset
  79619. */
  79620. onPointerMovedObservable: Observable<{
  79621. offsetX: number;
  79622. offsetY: number;
  79623. }>;
  79624. /**
  79625. * @hidden
  79626. * If the camera should be rotated automatically based on pointer movement
  79627. */
  79628. _allowCameraRotation: boolean;
  79629. /**
  79630. * Manage the mouse inputs to control the movement of a free camera.
  79631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79632. * @param touchEnabled Defines if touch is enabled or not
  79633. */
  79634. constructor(
  79635. /**
  79636. * Define if touch is enabled in the mouse input
  79637. */
  79638. touchEnabled?: boolean);
  79639. /**
  79640. * Attach the input controls to a specific dom element to get the input from.
  79641. * @param element Defines the element the controls should be listened from
  79642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79643. */
  79644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79645. /**
  79646. * Called on JS contextmenu event.
  79647. * Override this method to provide functionality.
  79648. */
  79649. protected onContextMenu(evt: PointerEvent): void;
  79650. /**
  79651. * Detach the current controls from the specified dom element.
  79652. * @param element Defines the element to stop listening the inputs from
  79653. */
  79654. detachControl(element: Nullable<HTMLElement>): void;
  79655. /**
  79656. * Gets the class name of the current intput.
  79657. * @returns the class name
  79658. */
  79659. getClassName(): string;
  79660. /**
  79661. * Get the friendly name associated with the input class.
  79662. * @returns the input friendly name
  79663. */
  79664. getSimpleName(): string;
  79665. }
  79666. }
  79667. declare module BABYLON {
  79668. /**
  79669. * Manage the touch inputs to control the movement of a free camera.
  79670. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79671. */
  79672. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79673. /**
  79674. * Defines the camera the input is attached to.
  79675. */
  79676. camera: FreeCamera;
  79677. /**
  79678. * Defines the touch sensibility for rotation.
  79679. * The higher the faster.
  79680. */
  79681. touchAngularSensibility: number;
  79682. /**
  79683. * Defines the touch sensibility for move.
  79684. * The higher the faster.
  79685. */
  79686. touchMoveSensibility: number;
  79687. private _offsetX;
  79688. private _offsetY;
  79689. private _pointerPressed;
  79690. private _pointerInput;
  79691. private _observer;
  79692. private _onLostFocus;
  79693. /**
  79694. * Attach the input controls to a specific dom element to get the input from.
  79695. * @param element Defines the element the controls should be listened from
  79696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79697. */
  79698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79699. /**
  79700. * Detach the current controls from the specified dom element.
  79701. * @param element Defines the element to stop listening the inputs from
  79702. */
  79703. detachControl(element: Nullable<HTMLElement>): void;
  79704. /**
  79705. * Update the current camera state depending on the inputs that have been used this frame.
  79706. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79707. */
  79708. checkInputs(): void;
  79709. /**
  79710. * Gets the class name of the current intput.
  79711. * @returns the class name
  79712. */
  79713. getClassName(): string;
  79714. /**
  79715. * Get the friendly name associated with the input class.
  79716. * @returns the input friendly name
  79717. */
  79718. getSimpleName(): string;
  79719. }
  79720. }
  79721. declare module BABYLON {
  79722. /**
  79723. * Default Inputs manager for the FreeCamera.
  79724. * It groups all the default supported inputs for ease of use.
  79725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79726. */
  79727. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79728. /**
  79729. * @hidden
  79730. */
  79731. _mouseInput: Nullable<FreeCameraMouseInput>;
  79732. /**
  79733. * Instantiates a new FreeCameraInputsManager.
  79734. * @param camera Defines the camera the inputs belong to
  79735. */
  79736. constructor(camera: FreeCamera);
  79737. /**
  79738. * Add keyboard input support to the input manager.
  79739. * @returns the current input manager
  79740. */
  79741. addKeyboard(): FreeCameraInputsManager;
  79742. /**
  79743. * Add mouse input support to the input manager.
  79744. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79745. * @returns the current input manager
  79746. */
  79747. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79748. /**
  79749. * Removes the mouse input support from the manager
  79750. * @returns the current input manager
  79751. */
  79752. removeMouse(): FreeCameraInputsManager;
  79753. /**
  79754. * Add touch input support to the input manager.
  79755. * @returns the current input manager
  79756. */
  79757. addTouch(): FreeCameraInputsManager;
  79758. /**
  79759. * Remove all attached input methods from a camera
  79760. */
  79761. clear(): void;
  79762. }
  79763. }
  79764. declare module BABYLON {
  79765. /**
  79766. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79767. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79768. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79769. */
  79770. export class FreeCamera extends TargetCamera {
  79771. /**
  79772. * Define the collision ellipsoid of the camera.
  79773. * This is helpful to simulate a camera body like the player body around the camera
  79774. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79775. */
  79776. ellipsoid: Vector3;
  79777. /**
  79778. * Define an offset for the position of the ellipsoid around the camera.
  79779. * This can be helpful to determine the center of the body near the gravity center of the body
  79780. * instead of its head.
  79781. */
  79782. ellipsoidOffset: Vector3;
  79783. /**
  79784. * Enable or disable collisions of the camera with the rest of the scene objects.
  79785. */
  79786. checkCollisions: boolean;
  79787. /**
  79788. * Enable or disable gravity on the camera.
  79789. */
  79790. applyGravity: boolean;
  79791. /**
  79792. * Define the input manager associated to the camera.
  79793. */
  79794. inputs: FreeCameraInputsManager;
  79795. /**
  79796. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79797. * Higher values reduce sensitivity.
  79798. */
  79799. /**
  79800. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79801. * Higher values reduce sensitivity.
  79802. */
  79803. angularSensibility: number;
  79804. /**
  79805. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79806. */
  79807. keysUp: number[];
  79808. /**
  79809. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79810. */
  79811. keysDown: number[];
  79812. /**
  79813. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79814. */
  79815. keysLeft: number[];
  79816. /**
  79817. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79818. */
  79819. keysRight: number[];
  79820. /**
  79821. * Event raised when the camera collide with a mesh in the scene.
  79822. */
  79823. onCollide: (collidedMesh: AbstractMesh) => void;
  79824. private _collider;
  79825. private _needMoveForGravity;
  79826. private _oldPosition;
  79827. private _diffPosition;
  79828. private _newPosition;
  79829. /** @hidden */
  79830. _localDirection: Vector3;
  79831. /** @hidden */
  79832. _transformedDirection: Vector3;
  79833. /**
  79834. * Instantiates a Free Camera.
  79835. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79836. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79837. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79838. * @param name Define the name of the camera in the scene
  79839. * @param position Define the start position of the camera in the scene
  79840. * @param scene Define the scene the camera belongs to
  79841. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79842. */
  79843. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79844. /**
  79845. * Attached controls to the current camera.
  79846. * @param element Defines the element the controls should be listened from
  79847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79848. */
  79849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79850. /**
  79851. * Detach the current controls from the camera.
  79852. * The camera will stop reacting to inputs.
  79853. * @param element Defines the element to stop listening the inputs from
  79854. */
  79855. detachControl(element: HTMLElement): void;
  79856. private _collisionMask;
  79857. /**
  79858. * Define a collision mask to limit the list of object the camera can collide with
  79859. */
  79860. collisionMask: number;
  79861. /** @hidden */
  79862. _collideWithWorld(displacement: Vector3): void;
  79863. private _onCollisionPositionChange;
  79864. /** @hidden */
  79865. _checkInputs(): void;
  79866. /** @hidden */
  79867. _decideIfNeedsToMove(): boolean;
  79868. /** @hidden */
  79869. _updatePosition(): void;
  79870. /**
  79871. * Destroy the camera and release the current resources hold by it.
  79872. */
  79873. dispose(): void;
  79874. /**
  79875. * Gets the current object class name.
  79876. * @return the class name
  79877. */
  79878. getClassName(): string;
  79879. }
  79880. }
  79881. declare module BABYLON {
  79882. /**
  79883. * Represents a gamepad control stick position
  79884. */
  79885. export class StickValues {
  79886. /**
  79887. * The x component of the control stick
  79888. */
  79889. x: number;
  79890. /**
  79891. * The y component of the control stick
  79892. */
  79893. y: number;
  79894. /**
  79895. * Initializes the gamepad x and y control stick values
  79896. * @param x The x component of the gamepad control stick value
  79897. * @param y The y component of the gamepad control stick value
  79898. */
  79899. constructor(
  79900. /**
  79901. * The x component of the control stick
  79902. */
  79903. x: number,
  79904. /**
  79905. * The y component of the control stick
  79906. */
  79907. y: number);
  79908. }
  79909. /**
  79910. * An interface which manages callbacks for gamepad button changes
  79911. */
  79912. export interface GamepadButtonChanges {
  79913. /**
  79914. * Called when a gamepad has been changed
  79915. */
  79916. changed: boolean;
  79917. /**
  79918. * Called when a gamepad press event has been triggered
  79919. */
  79920. pressChanged: boolean;
  79921. /**
  79922. * Called when a touch event has been triggered
  79923. */
  79924. touchChanged: boolean;
  79925. /**
  79926. * Called when a value has changed
  79927. */
  79928. valueChanged: boolean;
  79929. }
  79930. /**
  79931. * Represents a gamepad
  79932. */
  79933. export class Gamepad {
  79934. /**
  79935. * The id of the gamepad
  79936. */
  79937. id: string;
  79938. /**
  79939. * The index of the gamepad
  79940. */
  79941. index: number;
  79942. /**
  79943. * The browser gamepad
  79944. */
  79945. browserGamepad: any;
  79946. /**
  79947. * Specifies what type of gamepad this represents
  79948. */
  79949. type: number;
  79950. private _leftStick;
  79951. private _rightStick;
  79952. /** @hidden */
  79953. _isConnected: boolean;
  79954. private _leftStickAxisX;
  79955. private _leftStickAxisY;
  79956. private _rightStickAxisX;
  79957. private _rightStickAxisY;
  79958. /**
  79959. * Triggered when the left control stick has been changed
  79960. */
  79961. private _onleftstickchanged;
  79962. /**
  79963. * Triggered when the right control stick has been changed
  79964. */
  79965. private _onrightstickchanged;
  79966. /**
  79967. * Represents a gamepad controller
  79968. */
  79969. static GAMEPAD: number;
  79970. /**
  79971. * Represents a generic controller
  79972. */
  79973. static GENERIC: number;
  79974. /**
  79975. * Represents an XBox controller
  79976. */
  79977. static XBOX: number;
  79978. /**
  79979. * Represents a pose-enabled controller
  79980. */
  79981. static POSE_ENABLED: number;
  79982. /**
  79983. * Specifies whether the left control stick should be Y-inverted
  79984. */
  79985. protected _invertLeftStickY: boolean;
  79986. /**
  79987. * Specifies if the gamepad has been connected
  79988. */
  79989. readonly isConnected: boolean;
  79990. /**
  79991. * Initializes the gamepad
  79992. * @param id The id of the gamepad
  79993. * @param index The index of the gamepad
  79994. * @param browserGamepad The browser gamepad
  79995. * @param leftStickX The x component of the left joystick
  79996. * @param leftStickY The y component of the left joystick
  79997. * @param rightStickX The x component of the right joystick
  79998. * @param rightStickY The y component of the right joystick
  79999. */
  80000. constructor(
  80001. /**
  80002. * The id of the gamepad
  80003. */
  80004. id: string,
  80005. /**
  80006. * The index of the gamepad
  80007. */
  80008. index: number,
  80009. /**
  80010. * The browser gamepad
  80011. */
  80012. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  80013. /**
  80014. * Callback triggered when the left joystick has changed
  80015. * @param callback
  80016. */
  80017. onleftstickchanged(callback: (values: StickValues) => void): void;
  80018. /**
  80019. * Callback triggered when the right joystick has changed
  80020. * @param callback
  80021. */
  80022. onrightstickchanged(callback: (values: StickValues) => void): void;
  80023. /**
  80024. * Gets the left joystick
  80025. */
  80026. /**
  80027. * Sets the left joystick values
  80028. */
  80029. leftStick: StickValues;
  80030. /**
  80031. * Gets the right joystick
  80032. */
  80033. /**
  80034. * Sets the right joystick value
  80035. */
  80036. rightStick: StickValues;
  80037. /**
  80038. * Updates the gamepad joystick positions
  80039. */
  80040. update(): void;
  80041. /**
  80042. * Disposes the gamepad
  80043. */
  80044. dispose(): void;
  80045. }
  80046. /**
  80047. * Represents a generic gamepad
  80048. */
  80049. export class GenericPad extends Gamepad {
  80050. private _buttons;
  80051. private _onbuttondown;
  80052. private _onbuttonup;
  80053. /**
  80054. * Observable triggered when a button has been pressed
  80055. */
  80056. onButtonDownObservable: Observable<number>;
  80057. /**
  80058. * Observable triggered when a button has been released
  80059. */
  80060. onButtonUpObservable: Observable<number>;
  80061. /**
  80062. * Callback triggered when a button has been pressed
  80063. * @param callback Called when a button has been pressed
  80064. */
  80065. onbuttondown(callback: (buttonPressed: number) => void): void;
  80066. /**
  80067. * Callback triggered when a button has been released
  80068. * @param callback Called when a button has been released
  80069. */
  80070. onbuttonup(callback: (buttonReleased: number) => void): void;
  80071. /**
  80072. * Initializes the generic gamepad
  80073. * @param id The id of the generic gamepad
  80074. * @param index The index of the generic gamepad
  80075. * @param browserGamepad The browser gamepad
  80076. */
  80077. constructor(id: string, index: number, browserGamepad: any);
  80078. private _setButtonValue;
  80079. /**
  80080. * Updates the generic gamepad
  80081. */
  80082. update(): void;
  80083. /**
  80084. * Disposes the generic gamepad
  80085. */
  80086. dispose(): void;
  80087. }
  80088. }
  80089. declare module BABYLON {
  80090. /**
  80091. * Defines the types of pose enabled controllers that are supported
  80092. */
  80093. export enum PoseEnabledControllerType {
  80094. /**
  80095. * HTC Vive
  80096. */
  80097. VIVE = 0,
  80098. /**
  80099. * Oculus Rift
  80100. */
  80101. OCULUS = 1,
  80102. /**
  80103. * Windows mixed reality
  80104. */
  80105. WINDOWS = 2,
  80106. /**
  80107. * Samsung gear VR
  80108. */
  80109. GEAR_VR = 3,
  80110. /**
  80111. * Google Daydream
  80112. */
  80113. DAYDREAM = 4,
  80114. /**
  80115. * Generic
  80116. */
  80117. GENERIC = 5
  80118. }
  80119. /**
  80120. * Defines the MutableGamepadButton interface for the state of a gamepad button
  80121. */
  80122. export interface MutableGamepadButton {
  80123. /**
  80124. * Value of the button/trigger
  80125. */
  80126. value: number;
  80127. /**
  80128. * If the button/trigger is currently touched
  80129. */
  80130. touched: boolean;
  80131. /**
  80132. * If the button/trigger is currently pressed
  80133. */
  80134. pressed: boolean;
  80135. }
  80136. /**
  80137. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80138. * @hidden
  80139. */
  80140. export interface ExtendedGamepadButton extends GamepadButton {
  80141. /**
  80142. * If the button/trigger is currently pressed
  80143. */
  80144. readonly pressed: boolean;
  80145. /**
  80146. * If the button/trigger is currently touched
  80147. */
  80148. readonly touched: boolean;
  80149. /**
  80150. * Value of the button/trigger
  80151. */
  80152. readonly value: number;
  80153. }
  80154. /** @hidden */
  80155. export interface _GamePadFactory {
  80156. /**
  80157. * Returns wether or not the current gamepad can be created for this type of controller.
  80158. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80159. * @returns true if it can be created, otherwise false
  80160. */
  80161. canCreate(gamepadInfo: any): boolean;
  80162. /**
  80163. * Creates a new instance of the Gamepad.
  80164. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80165. * @returns the new gamepad instance
  80166. */
  80167. create(gamepadInfo: any): Gamepad;
  80168. }
  80169. /**
  80170. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80171. */
  80172. export class PoseEnabledControllerHelper {
  80173. /** @hidden */
  80174. static _ControllerFactories: _GamePadFactory[];
  80175. /** @hidden */
  80176. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80177. /**
  80178. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80179. * @param vrGamepad the gamepad to initialized
  80180. * @returns a vr controller of the type the gamepad identified as
  80181. */
  80182. static InitiateController(vrGamepad: any): Gamepad;
  80183. }
  80184. /**
  80185. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80186. */
  80187. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80188. private _deviceRoomPosition;
  80189. private _deviceRoomRotationQuaternion;
  80190. /**
  80191. * The device position in babylon space
  80192. */
  80193. devicePosition: Vector3;
  80194. /**
  80195. * The device rotation in babylon space
  80196. */
  80197. deviceRotationQuaternion: Quaternion;
  80198. /**
  80199. * The scale factor of the device in babylon space
  80200. */
  80201. deviceScaleFactor: number;
  80202. /**
  80203. * (Likely devicePosition should be used instead) The device position in its room space
  80204. */
  80205. position: Vector3;
  80206. /**
  80207. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80208. */
  80209. rotationQuaternion: Quaternion;
  80210. /**
  80211. * The type of controller (Eg. Windows mixed reality)
  80212. */
  80213. controllerType: PoseEnabledControllerType;
  80214. protected _calculatedPosition: Vector3;
  80215. private _calculatedRotation;
  80216. /**
  80217. * The raw pose from the device
  80218. */
  80219. rawPose: DevicePose;
  80220. private _trackPosition;
  80221. private _maxRotationDistFromHeadset;
  80222. private _draggedRoomRotation;
  80223. /**
  80224. * @hidden
  80225. */
  80226. _disableTrackPosition(fixedPosition: Vector3): void;
  80227. /**
  80228. * Internal, the mesh attached to the controller
  80229. * @hidden
  80230. */
  80231. _mesh: Nullable<AbstractMesh>;
  80232. private _poseControlledCamera;
  80233. private _leftHandSystemQuaternion;
  80234. /**
  80235. * Internal, matrix used to convert room space to babylon space
  80236. * @hidden
  80237. */
  80238. _deviceToWorld: Matrix;
  80239. /**
  80240. * Node to be used when casting a ray from the controller
  80241. * @hidden
  80242. */
  80243. _pointingPoseNode: Nullable<TransformNode>;
  80244. /**
  80245. * Name of the child mesh that can be used to cast a ray from the controller
  80246. */
  80247. static readonly POINTING_POSE: string;
  80248. /**
  80249. * Creates a new PoseEnabledController from a gamepad
  80250. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80251. */
  80252. constructor(browserGamepad: any);
  80253. private _workingMatrix;
  80254. /**
  80255. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80256. */
  80257. update(): void;
  80258. /**
  80259. * Updates only the pose device and mesh without doing any button event checking
  80260. */
  80261. protected _updatePoseAndMesh(): void;
  80262. /**
  80263. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80264. * @param poseData raw pose fromthe device
  80265. */
  80266. updateFromDevice(poseData: DevicePose): void;
  80267. /**
  80268. * @hidden
  80269. */
  80270. _meshAttachedObservable: Observable<AbstractMesh>;
  80271. /**
  80272. * Attaches a mesh to the controller
  80273. * @param mesh the mesh to be attached
  80274. */
  80275. attachToMesh(mesh: AbstractMesh): void;
  80276. /**
  80277. * Attaches the controllers mesh to a camera
  80278. * @param camera the camera the mesh should be attached to
  80279. */
  80280. attachToPoseControlledCamera(camera: TargetCamera): void;
  80281. /**
  80282. * Disposes of the controller
  80283. */
  80284. dispose(): void;
  80285. /**
  80286. * The mesh that is attached to the controller
  80287. */
  80288. readonly mesh: Nullable<AbstractMesh>;
  80289. /**
  80290. * Gets the ray of the controller in the direction the controller is pointing
  80291. * @param length the length the resulting ray should be
  80292. * @returns a ray in the direction the controller is pointing
  80293. */
  80294. getForwardRay(length?: number): Ray;
  80295. }
  80296. }
  80297. declare module BABYLON {
  80298. /**
  80299. * Defines the WebVRController object that represents controllers tracked in 3D space
  80300. */
  80301. export abstract class WebVRController extends PoseEnabledController {
  80302. /**
  80303. * Internal, the default controller model for the controller
  80304. */
  80305. protected _defaultModel: AbstractMesh;
  80306. /**
  80307. * Fired when the trigger state has changed
  80308. */
  80309. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80310. /**
  80311. * Fired when the main button state has changed
  80312. */
  80313. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80314. /**
  80315. * Fired when the secondary button state has changed
  80316. */
  80317. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80318. /**
  80319. * Fired when the pad state has changed
  80320. */
  80321. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80322. /**
  80323. * Fired when controllers stick values have changed
  80324. */
  80325. onPadValuesChangedObservable: Observable<StickValues>;
  80326. /**
  80327. * Array of button availible on the controller
  80328. */
  80329. protected _buttons: Array<MutableGamepadButton>;
  80330. private _onButtonStateChange;
  80331. /**
  80332. * Fired when a controller button's state has changed
  80333. * @param callback the callback containing the button that was modified
  80334. */
  80335. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80336. /**
  80337. * X and Y axis corresponding to the controllers joystick
  80338. */
  80339. pad: StickValues;
  80340. /**
  80341. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80342. */
  80343. hand: string;
  80344. /**
  80345. * The default controller model for the controller
  80346. */
  80347. readonly defaultModel: AbstractMesh;
  80348. /**
  80349. * Creates a new WebVRController from a gamepad
  80350. * @param vrGamepad the gamepad that the WebVRController should be created from
  80351. */
  80352. constructor(vrGamepad: any);
  80353. /**
  80354. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80355. */
  80356. update(): void;
  80357. /**
  80358. * Function to be called when a button is modified
  80359. */
  80360. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80361. /**
  80362. * Loads a mesh and attaches it to the controller
  80363. * @param scene the scene the mesh should be added to
  80364. * @param meshLoaded callback for when the mesh has been loaded
  80365. */
  80366. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80367. private _setButtonValue;
  80368. private _changes;
  80369. private _checkChanges;
  80370. /**
  80371. * Disposes of th webVRCOntroller
  80372. */
  80373. dispose(): void;
  80374. }
  80375. }
  80376. declare module BABYLON {
  80377. /**
  80378. * The HemisphericLight simulates the ambient environment light,
  80379. * so the passed direction is the light reflection direction, not the incoming direction.
  80380. */
  80381. export class HemisphericLight extends Light {
  80382. /**
  80383. * The groundColor is the light in the opposite direction to the one specified during creation.
  80384. * 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.
  80385. */
  80386. groundColor: Color3;
  80387. /**
  80388. * The light reflection direction, not the incoming direction.
  80389. */
  80390. direction: Vector3;
  80391. /**
  80392. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80393. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80394. * The HemisphericLight can't cast shadows.
  80395. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80396. * @param name The friendly name of the light
  80397. * @param direction The direction of the light reflection
  80398. * @param scene The scene the light belongs to
  80399. */
  80400. constructor(name: string, direction: Vector3, scene: Scene);
  80401. protected _buildUniformLayout(): void;
  80402. /**
  80403. * Returns the string "HemisphericLight".
  80404. * @return The class name
  80405. */
  80406. getClassName(): string;
  80407. /**
  80408. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80409. * Returns the updated direction.
  80410. * @param target The target the direction should point to
  80411. * @return The computed direction
  80412. */
  80413. setDirectionToTarget(target: Vector3): Vector3;
  80414. /**
  80415. * Returns the shadow generator associated to the light.
  80416. * @returns Always null for hemispheric lights because it does not support shadows.
  80417. */
  80418. getShadowGenerator(): Nullable<IShadowGenerator>;
  80419. /**
  80420. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80421. * @param effect The effect to update
  80422. * @param lightIndex The index of the light in the effect to update
  80423. * @returns The hemispheric light
  80424. */
  80425. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80426. /**
  80427. * Computes the world matrix of the node
  80428. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80429. * @param useWasUpdatedFlag defines a reserved property
  80430. * @returns the world matrix
  80431. */
  80432. computeWorldMatrix(): Matrix;
  80433. /**
  80434. * Returns the integer 3.
  80435. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80436. */
  80437. getTypeID(): number;
  80438. /**
  80439. * Prepares the list of defines specific to the light type.
  80440. * @param defines the list of defines
  80441. * @param lightIndex defines the index of the light for the effect
  80442. */
  80443. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80444. }
  80445. }
  80446. declare module BABYLON {
  80447. /** @hidden */
  80448. export var vrMultiviewToSingleviewPixelShader: {
  80449. name: string;
  80450. shader: string;
  80451. };
  80452. }
  80453. declare module BABYLON {
  80454. /**
  80455. * Renders to multiple views with a single draw call
  80456. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80457. */
  80458. export class MultiviewRenderTarget extends RenderTargetTexture {
  80459. /**
  80460. * Creates a multiview render target
  80461. * @param scene scene used with the render target
  80462. * @param size the size of the render target (used for each view)
  80463. */
  80464. constructor(scene: Scene, size?: number | {
  80465. width: number;
  80466. height: number;
  80467. } | {
  80468. ratio: number;
  80469. });
  80470. /**
  80471. * @hidden
  80472. * @param faceIndex the face index, if its a cube texture
  80473. */
  80474. _bindFrameBuffer(faceIndex?: number): void;
  80475. /**
  80476. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80477. * @returns the view count
  80478. */
  80479. getViewCount(): number;
  80480. }
  80481. }
  80482. declare module BABYLON {
  80483. interface Engine {
  80484. /**
  80485. * Creates a new multiview render target
  80486. * @param width defines the width of the texture
  80487. * @param height defines the height of the texture
  80488. * @returns the created multiview texture
  80489. */
  80490. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80491. /**
  80492. * Binds a multiview framebuffer to be drawn to
  80493. * @param multiviewTexture texture to bind
  80494. */
  80495. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80496. }
  80497. interface Camera {
  80498. /**
  80499. * @hidden
  80500. * 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)
  80501. */
  80502. _useMultiviewToSingleView: boolean;
  80503. /**
  80504. * @hidden
  80505. * 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)
  80506. */
  80507. _multiviewTexture: Nullable<RenderTargetTexture>;
  80508. /**
  80509. * @hidden
  80510. * ensures the multiview texture of the camera exists and has the specified width/height
  80511. * @param width height to set on the multiview texture
  80512. * @param height width to set on the multiview texture
  80513. */
  80514. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80515. }
  80516. interface Scene {
  80517. /** @hidden */
  80518. _transformMatrixR: Matrix;
  80519. /** @hidden */
  80520. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80521. /** @hidden */
  80522. _createMultiviewUbo(): void;
  80523. /** @hidden */
  80524. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80525. /** @hidden */
  80526. _renderMultiviewToSingleView(camera: Camera): void;
  80527. }
  80528. }
  80529. declare module BABYLON {
  80530. /**
  80531. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80532. * This will not be used for webXR as it supports displaying texture arrays directly
  80533. */
  80534. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80535. /**
  80536. * Initializes a VRMultiviewToSingleview
  80537. * @param name name of the post process
  80538. * @param camera camera to be applied to
  80539. * @param scaleFactor scaling factor to the size of the output texture
  80540. */
  80541. constructor(name: string, camera: Camera, scaleFactor: number);
  80542. }
  80543. }
  80544. declare module BABYLON {
  80545. interface Engine {
  80546. /** @hidden */
  80547. _vrDisplay: any;
  80548. /** @hidden */
  80549. _vrSupported: boolean;
  80550. /** @hidden */
  80551. _oldSize: Size;
  80552. /** @hidden */
  80553. _oldHardwareScaleFactor: number;
  80554. /** @hidden */
  80555. _vrExclusivePointerMode: boolean;
  80556. /** @hidden */
  80557. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80558. /** @hidden */
  80559. _onVRDisplayPointerRestricted: () => void;
  80560. /** @hidden */
  80561. _onVRDisplayPointerUnrestricted: () => void;
  80562. /** @hidden */
  80563. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80564. /** @hidden */
  80565. _onVrDisplayDisconnect: Nullable<() => void>;
  80566. /** @hidden */
  80567. _onVrDisplayPresentChange: Nullable<() => void>;
  80568. /**
  80569. * Observable signaled when VR display mode changes
  80570. */
  80571. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80572. /**
  80573. * Observable signaled when VR request present is complete
  80574. */
  80575. onVRRequestPresentComplete: Observable<boolean>;
  80576. /**
  80577. * Observable signaled when VR request present starts
  80578. */
  80579. onVRRequestPresentStart: Observable<Engine>;
  80580. /**
  80581. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80582. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80583. */
  80584. isInVRExclusivePointerMode: boolean;
  80585. /**
  80586. * Gets a boolean indicating if a webVR device was detected
  80587. * @returns true if a webVR device was detected
  80588. */
  80589. isVRDevicePresent(): boolean;
  80590. /**
  80591. * Gets the current webVR device
  80592. * @returns the current webVR device (or null)
  80593. */
  80594. getVRDevice(): any;
  80595. /**
  80596. * Initializes a webVR display and starts listening to display change events
  80597. * The onVRDisplayChangedObservable will be notified upon these changes
  80598. * @returns A promise containing a VRDisplay and if vr is supported
  80599. */
  80600. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80601. /** @hidden */
  80602. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80603. /**
  80604. * Call this function to switch to webVR mode
  80605. * Will do nothing if webVR is not supported or if there is no webVR device
  80606. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80607. */
  80608. enableVR(): void;
  80609. /** @hidden */
  80610. _onVRFullScreenTriggered(): void;
  80611. }
  80612. }
  80613. declare module BABYLON {
  80614. /**
  80615. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80616. * IMPORTANT!! The data is right-hand data.
  80617. * @export
  80618. * @interface DevicePose
  80619. */
  80620. export interface DevicePose {
  80621. /**
  80622. * The position of the device, values in array are [x,y,z].
  80623. */
  80624. readonly position: Nullable<Float32Array>;
  80625. /**
  80626. * The linearVelocity of the device, values in array are [x,y,z].
  80627. */
  80628. readonly linearVelocity: Nullable<Float32Array>;
  80629. /**
  80630. * The linearAcceleration of the device, values in array are [x,y,z].
  80631. */
  80632. readonly linearAcceleration: Nullable<Float32Array>;
  80633. /**
  80634. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80635. */
  80636. readonly orientation: Nullable<Float32Array>;
  80637. /**
  80638. * The angularVelocity of the device, values in array are [x,y,z].
  80639. */
  80640. readonly angularVelocity: Nullable<Float32Array>;
  80641. /**
  80642. * The angularAcceleration of the device, values in array are [x,y,z].
  80643. */
  80644. readonly angularAcceleration: Nullable<Float32Array>;
  80645. }
  80646. /**
  80647. * Interface representing a pose controlled object in Babylon.
  80648. * A pose controlled object has both regular pose values as well as pose values
  80649. * from an external device such as a VR head mounted display
  80650. */
  80651. export interface PoseControlled {
  80652. /**
  80653. * The position of the object in babylon space.
  80654. */
  80655. position: Vector3;
  80656. /**
  80657. * The rotation quaternion of the object in babylon space.
  80658. */
  80659. rotationQuaternion: Quaternion;
  80660. /**
  80661. * The position of the device in babylon space.
  80662. */
  80663. devicePosition?: Vector3;
  80664. /**
  80665. * The rotation quaternion of the device in babylon space.
  80666. */
  80667. deviceRotationQuaternion: Quaternion;
  80668. /**
  80669. * The raw pose coming from the device.
  80670. */
  80671. rawPose: Nullable<DevicePose>;
  80672. /**
  80673. * The scale of the device to be used when translating from device space to babylon space.
  80674. */
  80675. deviceScaleFactor: number;
  80676. /**
  80677. * Updates the poseControlled values based on the input device pose.
  80678. * @param poseData the pose data to update the object with
  80679. */
  80680. updateFromDevice(poseData: DevicePose): void;
  80681. }
  80682. /**
  80683. * Set of options to customize the webVRCamera
  80684. */
  80685. export interface WebVROptions {
  80686. /**
  80687. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80688. */
  80689. trackPosition?: boolean;
  80690. /**
  80691. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80692. */
  80693. positionScale?: number;
  80694. /**
  80695. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80696. */
  80697. displayName?: string;
  80698. /**
  80699. * Should the native controller meshes be initialized. (default: true)
  80700. */
  80701. controllerMeshes?: boolean;
  80702. /**
  80703. * Creating a default HemiLight only on controllers. (default: true)
  80704. */
  80705. defaultLightingOnControllers?: boolean;
  80706. /**
  80707. * If you don't want to use the default VR button of the helper. (default: false)
  80708. */
  80709. useCustomVRButton?: boolean;
  80710. /**
  80711. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80712. */
  80713. customVRButton?: HTMLButtonElement;
  80714. /**
  80715. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80716. */
  80717. rayLength?: number;
  80718. /**
  80719. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80720. */
  80721. defaultHeight?: number;
  80722. /**
  80723. * If multiview should be used if availible (default: false)
  80724. */
  80725. useMultiview?: boolean;
  80726. }
  80727. /**
  80728. * This represents a WebVR camera.
  80729. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80730. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80731. */
  80732. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80733. private webVROptions;
  80734. /**
  80735. * @hidden
  80736. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80737. */
  80738. _vrDevice: any;
  80739. /**
  80740. * The rawPose of the vrDevice.
  80741. */
  80742. rawPose: Nullable<DevicePose>;
  80743. private _onVREnabled;
  80744. private _specsVersion;
  80745. private _attached;
  80746. private _frameData;
  80747. protected _descendants: Array<Node>;
  80748. private _deviceRoomPosition;
  80749. /** @hidden */
  80750. _deviceRoomRotationQuaternion: Quaternion;
  80751. private _standingMatrix;
  80752. /**
  80753. * Represents device position in babylon space.
  80754. */
  80755. devicePosition: Vector3;
  80756. /**
  80757. * Represents device rotation in babylon space.
  80758. */
  80759. deviceRotationQuaternion: Quaternion;
  80760. /**
  80761. * The scale of the device to be used when translating from device space to babylon space.
  80762. */
  80763. deviceScaleFactor: number;
  80764. private _deviceToWorld;
  80765. private _worldToDevice;
  80766. /**
  80767. * References to the webVR controllers for the vrDevice.
  80768. */
  80769. controllers: Array<WebVRController>;
  80770. /**
  80771. * Emits an event when a controller is attached.
  80772. */
  80773. onControllersAttachedObservable: Observable<WebVRController[]>;
  80774. /**
  80775. * Emits an event when a controller's mesh has been loaded;
  80776. */
  80777. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80778. /**
  80779. * Emits an event when the HMD's pose has been updated.
  80780. */
  80781. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80782. private _poseSet;
  80783. /**
  80784. * If the rig cameras be used as parent instead of this camera.
  80785. */
  80786. rigParenting: boolean;
  80787. private _lightOnControllers;
  80788. private _defaultHeight?;
  80789. /**
  80790. * Instantiates a WebVRFreeCamera.
  80791. * @param name The name of the WebVRFreeCamera
  80792. * @param position The starting anchor position for the camera
  80793. * @param scene The scene the camera belongs to
  80794. * @param webVROptions a set of customizable options for the webVRCamera
  80795. */
  80796. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80797. /**
  80798. * Gets the device distance from the ground in meters.
  80799. * @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.
  80800. */
  80801. deviceDistanceToRoomGround(): number;
  80802. /**
  80803. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80804. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80805. */
  80806. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80807. /**
  80808. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80809. * @returns A promise with a boolean set to if the standing matrix is supported.
  80810. */
  80811. useStandingMatrixAsync(): Promise<boolean>;
  80812. /**
  80813. * Disposes the camera
  80814. */
  80815. dispose(): void;
  80816. /**
  80817. * Gets a vrController by name.
  80818. * @param name The name of the controller to retreive
  80819. * @returns the controller matching the name specified or null if not found
  80820. */
  80821. getControllerByName(name: string): Nullable<WebVRController>;
  80822. private _leftController;
  80823. /**
  80824. * The controller corresponding to the users left hand.
  80825. */
  80826. readonly leftController: Nullable<WebVRController>;
  80827. private _rightController;
  80828. /**
  80829. * The controller corresponding to the users right hand.
  80830. */
  80831. readonly rightController: Nullable<WebVRController>;
  80832. /**
  80833. * Casts a ray forward from the vrCamera's gaze.
  80834. * @param length Length of the ray (default: 100)
  80835. * @returns the ray corresponding to the gaze
  80836. */
  80837. getForwardRay(length?: number): Ray;
  80838. /**
  80839. * @hidden
  80840. * Updates the camera based on device's frame data
  80841. */
  80842. _checkInputs(): void;
  80843. /**
  80844. * Updates the poseControlled values based on the input device pose.
  80845. * @param poseData Pose coming from the device
  80846. */
  80847. updateFromDevice(poseData: DevicePose): void;
  80848. private _htmlElementAttached;
  80849. private _detachIfAttached;
  80850. /**
  80851. * WebVR's attach control will start broadcasting frames to the device.
  80852. * Note that in certain browsers (chrome for example) this function must be called
  80853. * within a user-interaction callback. Example:
  80854. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80855. *
  80856. * @param element html element to attach the vrDevice to
  80857. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80858. */
  80859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80860. /**
  80861. * Detaches the camera from the html element and disables VR
  80862. *
  80863. * @param element html element to detach from
  80864. */
  80865. detachControl(element: HTMLElement): void;
  80866. /**
  80867. * @returns the name of this class
  80868. */
  80869. getClassName(): string;
  80870. /**
  80871. * Calls resetPose on the vrDisplay
  80872. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80873. */
  80874. resetToCurrentRotation(): void;
  80875. /**
  80876. * @hidden
  80877. * Updates the rig cameras (left and right eye)
  80878. */
  80879. _updateRigCameras(): void;
  80880. private _workingVector;
  80881. private _oneVector;
  80882. private _workingMatrix;
  80883. private updateCacheCalled;
  80884. private _correctPositionIfNotTrackPosition;
  80885. /**
  80886. * @hidden
  80887. * Updates the cached values of the camera
  80888. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80889. */
  80890. _updateCache(ignoreParentClass?: boolean): void;
  80891. /**
  80892. * @hidden
  80893. * Get current device position in babylon world
  80894. */
  80895. _computeDevicePosition(): void;
  80896. /**
  80897. * Updates the current device position and rotation in the babylon world
  80898. */
  80899. update(): void;
  80900. /**
  80901. * @hidden
  80902. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80903. * @returns an identity matrix
  80904. */
  80905. _getViewMatrix(): Matrix;
  80906. private _tmpMatrix;
  80907. /**
  80908. * This function is called by the two RIG cameras.
  80909. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80910. * @hidden
  80911. */
  80912. _getWebVRViewMatrix(): Matrix;
  80913. /** @hidden */
  80914. _getWebVRProjectionMatrix(): Matrix;
  80915. private _onGamepadConnectedObserver;
  80916. private _onGamepadDisconnectedObserver;
  80917. private _updateCacheWhenTrackingDisabledObserver;
  80918. /**
  80919. * Initializes the controllers and their meshes
  80920. */
  80921. initControllers(): void;
  80922. }
  80923. }
  80924. declare module BABYLON {
  80925. /**
  80926. * Size options for a post process
  80927. */
  80928. export type PostProcessOptions = {
  80929. width: number;
  80930. height: number;
  80931. };
  80932. /**
  80933. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80934. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80935. */
  80936. export class PostProcess {
  80937. /** Name of the PostProcess. */
  80938. name: string;
  80939. /**
  80940. * Gets or sets the unique id of the post process
  80941. */
  80942. uniqueId: number;
  80943. /**
  80944. * Width of the texture to apply the post process on
  80945. */
  80946. width: number;
  80947. /**
  80948. * Height of the texture to apply the post process on
  80949. */
  80950. height: number;
  80951. /**
  80952. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80953. * @hidden
  80954. */
  80955. _outputTexture: Nullable<InternalTexture>;
  80956. /**
  80957. * Sampling mode used by the shader
  80958. * See https://doc.babylonjs.com/classes/3.1/texture
  80959. */
  80960. renderTargetSamplingMode: number;
  80961. /**
  80962. * Clear color to use when screen clearing
  80963. */
  80964. clearColor: Color4;
  80965. /**
  80966. * If the buffer needs to be cleared before applying the post process. (default: true)
  80967. * Should be set to false if shader will overwrite all previous pixels.
  80968. */
  80969. autoClear: boolean;
  80970. /**
  80971. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80972. */
  80973. alphaMode: number;
  80974. /**
  80975. * Sets the setAlphaBlendConstants of the babylon engine
  80976. */
  80977. alphaConstants: Color4;
  80978. /**
  80979. * Animations to be used for the post processing
  80980. */
  80981. animations: Animation[];
  80982. /**
  80983. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80984. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80985. */
  80986. enablePixelPerfectMode: boolean;
  80987. /**
  80988. * Force the postprocess to be applied without taking in account viewport
  80989. */
  80990. forceFullscreenViewport: boolean;
  80991. /**
  80992. * List of inspectable custom properties (used by the Inspector)
  80993. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80994. */
  80995. inspectableCustomProperties: IInspectable[];
  80996. /**
  80997. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80998. *
  80999. * | Value | Type | Description |
  81000. * | ----- | ----------------------------------- | ----------- |
  81001. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81002. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81003. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81004. *
  81005. */
  81006. scaleMode: number;
  81007. /**
  81008. * Force textures to be a power of two (default: false)
  81009. */
  81010. alwaysForcePOT: boolean;
  81011. private _samples;
  81012. /**
  81013. * Number of sample textures (default: 1)
  81014. */
  81015. samples: number;
  81016. /**
  81017. * Modify the scale of the post process to be the same as the viewport (default: false)
  81018. */
  81019. adaptScaleToCurrentViewport: boolean;
  81020. private _camera;
  81021. private _scene;
  81022. private _engine;
  81023. private _options;
  81024. private _reusable;
  81025. private _textureType;
  81026. /**
  81027. * Smart array of input and output textures for the post process.
  81028. * @hidden
  81029. */
  81030. _textures: SmartArray<InternalTexture>;
  81031. /**
  81032. * The index in _textures that corresponds to the output texture.
  81033. * @hidden
  81034. */
  81035. _currentRenderTextureInd: number;
  81036. private _effect;
  81037. private _samplers;
  81038. private _fragmentUrl;
  81039. private _vertexUrl;
  81040. private _parameters;
  81041. private _scaleRatio;
  81042. protected _indexParameters: any;
  81043. private _shareOutputWithPostProcess;
  81044. private _texelSize;
  81045. private _forcedOutputTexture;
  81046. /**
  81047. * Returns the fragment url or shader name used in the post process.
  81048. * @returns the fragment url or name in the shader store.
  81049. */
  81050. getEffectName(): string;
  81051. /**
  81052. * An event triggered when the postprocess is activated.
  81053. */
  81054. onActivateObservable: Observable<Camera>;
  81055. private _onActivateObserver;
  81056. /**
  81057. * A function that is added to the onActivateObservable
  81058. */
  81059. onActivate: Nullable<(camera: Camera) => void>;
  81060. /**
  81061. * An event triggered when the postprocess changes its size.
  81062. */
  81063. onSizeChangedObservable: Observable<PostProcess>;
  81064. private _onSizeChangedObserver;
  81065. /**
  81066. * A function that is added to the onSizeChangedObservable
  81067. */
  81068. onSizeChanged: (postProcess: PostProcess) => void;
  81069. /**
  81070. * An event triggered when the postprocess applies its effect.
  81071. */
  81072. onApplyObservable: Observable<Effect>;
  81073. private _onApplyObserver;
  81074. /**
  81075. * A function that is added to the onApplyObservable
  81076. */
  81077. onApply: (effect: Effect) => void;
  81078. /**
  81079. * An event triggered before rendering the postprocess
  81080. */
  81081. onBeforeRenderObservable: Observable<Effect>;
  81082. private _onBeforeRenderObserver;
  81083. /**
  81084. * A function that is added to the onBeforeRenderObservable
  81085. */
  81086. onBeforeRender: (effect: Effect) => void;
  81087. /**
  81088. * An event triggered after rendering the postprocess
  81089. */
  81090. onAfterRenderObservable: Observable<Effect>;
  81091. private _onAfterRenderObserver;
  81092. /**
  81093. * A function that is added to the onAfterRenderObservable
  81094. */
  81095. onAfterRender: (efect: Effect) => void;
  81096. /**
  81097. * 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
  81098. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81099. */
  81100. inputTexture: InternalTexture;
  81101. /**
  81102. * Gets the camera which post process is applied to.
  81103. * @returns The camera the post process is applied to.
  81104. */
  81105. getCamera(): Camera;
  81106. /**
  81107. * Gets the texel size of the postprocess.
  81108. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81109. */
  81110. readonly texelSize: Vector2;
  81111. /**
  81112. * Creates a new instance PostProcess
  81113. * @param name The name of the PostProcess.
  81114. * @param fragmentUrl The url of the fragment shader to be used.
  81115. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81116. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81117. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81118. * @param camera The camera to apply the render pass to.
  81119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81120. * @param engine The engine which the post process will be applied. (default: current engine)
  81121. * @param reusable If the post process can be reused on the same frame. (default: false)
  81122. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81123. * @param textureType Type of textures used when performing the post process. (default: 0)
  81124. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81125. * @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
  81126. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81127. */
  81128. constructor(
  81129. /** Name of the PostProcess. */
  81130. 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);
  81131. /**
  81132. * Gets a string idenfifying the name of the class
  81133. * @returns "PostProcess" string
  81134. */
  81135. getClassName(): string;
  81136. /**
  81137. * Gets the engine which this post process belongs to.
  81138. * @returns The engine the post process was enabled with.
  81139. */
  81140. getEngine(): Engine;
  81141. /**
  81142. * The effect that is created when initializing the post process.
  81143. * @returns The created effect corresponding the the postprocess.
  81144. */
  81145. getEffect(): Effect;
  81146. /**
  81147. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81148. * @param postProcess The post process to share the output with.
  81149. * @returns This post process.
  81150. */
  81151. shareOutputWith(postProcess: PostProcess): PostProcess;
  81152. /**
  81153. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81154. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81155. */
  81156. useOwnOutput(): void;
  81157. /**
  81158. * Updates the effect with the current post process compile time values and recompiles the shader.
  81159. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81160. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81161. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81162. * @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
  81163. * @param onCompiled Called when the shader has been compiled.
  81164. * @param onError Called if there is an error when compiling a shader.
  81165. */
  81166. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81167. /**
  81168. * The post process is reusable if it can be used multiple times within one frame.
  81169. * @returns If the post process is reusable
  81170. */
  81171. isReusable(): boolean;
  81172. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81173. markTextureDirty(): void;
  81174. /**
  81175. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81176. * 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.
  81177. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81178. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81179. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81180. * @returns The target texture that was bound to be written to.
  81181. */
  81182. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81183. /**
  81184. * If the post process is supported.
  81185. */
  81186. readonly isSupported: boolean;
  81187. /**
  81188. * The aspect ratio of the output texture.
  81189. */
  81190. readonly aspectRatio: number;
  81191. /**
  81192. * Get a value indicating if the post-process is ready to be used
  81193. * @returns true if the post-process is ready (shader is compiled)
  81194. */
  81195. isReady(): boolean;
  81196. /**
  81197. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81198. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81199. */
  81200. apply(): Nullable<Effect>;
  81201. private _disposeTextures;
  81202. /**
  81203. * Disposes the post process.
  81204. * @param camera The camera to dispose the post process on.
  81205. */
  81206. dispose(camera?: Camera): void;
  81207. }
  81208. }
  81209. declare module BABYLON {
  81210. /** @hidden */
  81211. export var kernelBlurVaryingDeclaration: {
  81212. name: string;
  81213. shader: string;
  81214. };
  81215. }
  81216. declare module BABYLON {
  81217. /** @hidden */
  81218. export var kernelBlurFragment: {
  81219. name: string;
  81220. shader: string;
  81221. };
  81222. }
  81223. declare module BABYLON {
  81224. /** @hidden */
  81225. export var kernelBlurFragment2: {
  81226. name: string;
  81227. shader: string;
  81228. };
  81229. }
  81230. declare module BABYLON {
  81231. /** @hidden */
  81232. export var kernelBlurPixelShader: {
  81233. name: string;
  81234. shader: string;
  81235. };
  81236. }
  81237. declare module BABYLON {
  81238. /** @hidden */
  81239. export var kernelBlurVertex: {
  81240. name: string;
  81241. shader: string;
  81242. };
  81243. }
  81244. declare module BABYLON {
  81245. /** @hidden */
  81246. export var kernelBlurVertexShader: {
  81247. name: string;
  81248. shader: string;
  81249. };
  81250. }
  81251. declare module BABYLON {
  81252. /**
  81253. * The Blur Post Process which blurs an image based on a kernel and direction.
  81254. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81255. */
  81256. export class BlurPostProcess extends PostProcess {
  81257. /** The direction in which to blur the image. */
  81258. direction: Vector2;
  81259. private blockCompilation;
  81260. protected _kernel: number;
  81261. protected _idealKernel: number;
  81262. protected _packedFloat: boolean;
  81263. private _staticDefines;
  81264. /**
  81265. * Sets the length in pixels of the blur sample region
  81266. */
  81267. /**
  81268. * Gets the length in pixels of the blur sample region
  81269. */
  81270. kernel: number;
  81271. /**
  81272. * Sets wether or not the blur needs to unpack/repack floats
  81273. */
  81274. /**
  81275. * Gets wether or not the blur is unpacking/repacking floats
  81276. */
  81277. packedFloat: boolean;
  81278. /**
  81279. * Creates a new instance BlurPostProcess
  81280. * @param name The name of the effect.
  81281. * @param direction The direction in which to blur the image.
  81282. * @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.
  81283. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81284. * @param camera The camera to apply the render pass to.
  81285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81286. * @param engine The engine which the post process will be applied. (default: current engine)
  81287. * @param reusable If the post process can be reused on the same frame. (default: false)
  81288. * @param textureType Type of textures used when performing the post process. (default: 0)
  81289. * @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)
  81290. */
  81291. constructor(name: string,
  81292. /** The direction in which to blur the image. */
  81293. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81294. /**
  81295. * Updates the effect with the current post process compile time values and recompiles the shader.
  81296. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81297. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81298. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81299. * @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
  81300. * @param onCompiled Called when the shader has been compiled.
  81301. * @param onError Called if there is an error when compiling a shader.
  81302. */
  81303. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81304. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81305. /**
  81306. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81307. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81308. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81309. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81310. * The gaps between physical kernels are compensated for in the weighting of the samples
  81311. * @param idealKernel Ideal blur kernel.
  81312. * @return Nearest best kernel.
  81313. */
  81314. protected _nearestBestKernel(idealKernel: number): number;
  81315. /**
  81316. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81317. * @param x The point on the Gaussian distribution to sample.
  81318. * @return the value of the Gaussian function at x.
  81319. */
  81320. protected _gaussianWeight(x: number): number;
  81321. /**
  81322. * Generates a string that can be used as a floating point number in GLSL.
  81323. * @param x Value to print.
  81324. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81325. * @return GLSL float string.
  81326. */
  81327. protected _glslFloat(x: number, decimalFigures?: number): string;
  81328. }
  81329. }
  81330. declare module BABYLON {
  81331. /**
  81332. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81333. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81334. * You can then easily use it as a reflectionTexture on a flat surface.
  81335. * In case the surface is not a plane, please consider relying on reflection probes.
  81336. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81337. */
  81338. export class MirrorTexture extends RenderTargetTexture {
  81339. private scene;
  81340. /**
  81341. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81342. * 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.
  81343. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81344. */
  81345. mirrorPlane: Plane;
  81346. /**
  81347. * Define the blur ratio used to blur the reflection if needed.
  81348. */
  81349. blurRatio: number;
  81350. /**
  81351. * Define the adaptive blur kernel used to blur the reflection if needed.
  81352. * This will autocompute the closest best match for the `blurKernel`
  81353. */
  81354. adaptiveBlurKernel: number;
  81355. /**
  81356. * Define the blur kernel used to blur the reflection if needed.
  81357. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81358. */
  81359. blurKernel: number;
  81360. /**
  81361. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81362. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81363. */
  81364. blurKernelX: number;
  81365. /**
  81366. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81367. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81368. */
  81369. blurKernelY: number;
  81370. private _autoComputeBlurKernel;
  81371. protected _onRatioRescale(): void;
  81372. private _updateGammaSpace;
  81373. private _imageProcessingConfigChangeObserver;
  81374. private _transformMatrix;
  81375. private _mirrorMatrix;
  81376. private _savedViewMatrix;
  81377. private _blurX;
  81378. private _blurY;
  81379. private _adaptiveBlurKernel;
  81380. private _blurKernelX;
  81381. private _blurKernelY;
  81382. private _blurRatio;
  81383. /**
  81384. * Instantiates a Mirror Texture.
  81385. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81386. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81387. * You can then easily use it as a reflectionTexture on a flat surface.
  81388. * In case the surface is not a plane, please consider relying on reflection probes.
  81389. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81390. * @param name
  81391. * @param size
  81392. * @param scene
  81393. * @param generateMipMaps
  81394. * @param type
  81395. * @param samplingMode
  81396. * @param generateDepthBuffer
  81397. */
  81398. constructor(name: string, size: number | {
  81399. width: number;
  81400. height: number;
  81401. } | {
  81402. ratio: number;
  81403. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81404. private _preparePostProcesses;
  81405. /**
  81406. * Clone the mirror texture.
  81407. * @returns the cloned texture
  81408. */
  81409. clone(): MirrorTexture;
  81410. /**
  81411. * Serialize the texture to a JSON representation you could use in Parse later on
  81412. * @returns the serialized JSON representation
  81413. */
  81414. serialize(): any;
  81415. /**
  81416. * Dispose the texture and release its associated resources.
  81417. */
  81418. dispose(): void;
  81419. }
  81420. }
  81421. declare module BABYLON {
  81422. /**
  81423. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81424. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81425. */
  81426. export class Texture extends BaseTexture {
  81427. /** @hidden */
  81428. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81429. /** @hidden */
  81430. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81431. /** @hidden */
  81432. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81433. /** nearest is mag = nearest and min = nearest and mip = linear */
  81434. static readonly NEAREST_SAMPLINGMODE: number;
  81435. /** nearest is mag = nearest and min = nearest and mip = linear */
  81436. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81437. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81438. static readonly BILINEAR_SAMPLINGMODE: number;
  81439. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81440. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81441. /** Trilinear is mag = linear and min = linear and mip = linear */
  81442. static readonly TRILINEAR_SAMPLINGMODE: number;
  81443. /** Trilinear is mag = linear and min = linear and mip = linear */
  81444. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81445. /** mag = nearest and min = nearest and mip = nearest */
  81446. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81447. /** mag = nearest and min = linear and mip = nearest */
  81448. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81449. /** mag = nearest and min = linear and mip = linear */
  81450. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81451. /** mag = nearest and min = linear and mip = none */
  81452. static readonly NEAREST_LINEAR: number;
  81453. /** mag = nearest and min = nearest and mip = none */
  81454. static readonly NEAREST_NEAREST: number;
  81455. /** mag = linear and min = nearest and mip = nearest */
  81456. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81457. /** mag = linear and min = nearest and mip = linear */
  81458. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81459. /** mag = linear and min = linear and mip = none */
  81460. static readonly LINEAR_LINEAR: number;
  81461. /** mag = linear and min = nearest and mip = none */
  81462. static readonly LINEAR_NEAREST: number;
  81463. /** Explicit coordinates mode */
  81464. static readonly EXPLICIT_MODE: number;
  81465. /** Spherical coordinates mode */
  81466. static readonly SPHERICAL_MODE: number;
  81467. /** Planar coordinates mode */
  81468. static readonly PLANAR_MODE: number;
  81469. /** Cubic coordinates mode */
  81470. static readonly CUBIC_MODE: number;
  81471. /** Projection coordinates mode */
  81472. static readonly PROJECTION_MODE: number;
  81473. /** Inverse Cubic coordinates mode */
  81474. static readonly SKYBOX_MODE: number;
  81475. /** Inverse Cubic coordinates mode */
  81476. static readonly INVCUBIC_MODE: number;
  81477. /** Equirectangular coordinates mode */
  81478. static readonly EQUIRECTANGULAR_MODE: number;
  81479. /** Equirectangular Fixed coordinates mode */
  81480. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81481. /** Equirectangular Fixed Mirrored coordinates mode */
  81482. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81483. /** Texture is not repeating outside of 0..1 UVs */
  81484. static readonly CLAMP_ADDRESSMODE: number;
  81485. /** Texture is repeating outside of 0..1 UVs */
  81486. static readonly WRAP_ADDRESSMODE: number;
  81487. /** Texture is repeating and mirrored */
  81488. static readonly MIRROR_ADDRESSMODE: number;
  81489. /**
  81490. * 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
  81491. */
  81492. static UseSerializedUrlIfAny: boolean;
  81493. /**
  81494. * Define the url of the texture.
  81495. */
  81496. url: Nullable<string>;
  81497. /**
  81498. * Define an offset on the texture to offset the u coordinates of the UVs
  81499. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81500. */
  81501. uOffset: number;
  81502. /**
  81503. * Define an offset on the texture to offset the v coordinates of the UVs
  81504. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81505. */
  81506. vOffset: number;
  81507. /**
  81508. * Define an offset on the texture to scale the u coordinates of the UVs
  81509. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81510. */
  81511. uScale: number;
  81512. /**
  81513. * Define an offset on the texture to scale the v coordinates of the UVs
  81514. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81515. */
  81516. vScale: number;
  81517. /**
  81518. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81519. * @see http://doc.babylonjs.com/how_to/more_materials
  81520. */
  81521. uAng: number;
  81522. /**
  81523. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81524. * @see http://doc.babylonjs.com/how_to/more_materials
  81525. */
  81526. vAng: number;
  81527. /**
  81528. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81529. * @see http://doc.babylonjs.com/how_to/more_materials
  81530. */
  81531. wAng: number;
  81532. /**
  81533. * Defines the center of rotation (U)
  81534. */
  81535. uRotationCenter: number;
  81536. /**
  81537. * Defines the center of rotation (V)
  81538. */
  81539. vRotationCenter: number;
  81540. /**
  81541. * Defines the center of rotation (W)
  81542. */
  81543. wRotationCenter: number;
  81544. /**
  81545. * Are mip maps generated for this texture or not.
  81546. */
  81547. readonly noMipmap: boolean;
  81548. /**
  81549. * List of inspectable custom properties (used by the Inspector)
  81550. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81551. */
  81552. inspectableCustomProperties: Nullable<IInspectable[]>;
  81553. private _noMipmap;
  81554. /** @hidden */
  81555. _invertY: boolean;
  81556. private _rowGenerationMatrix;
  81557. private _cachedTextureMatrix;
  81558. private _projectionModeMatrix;
  81559. private _t0;
  81560. private _t1;
  81561. private _t2;
  81562. private _cachedUOffset;
  81563. private _cachedVOffset;
  81564. private _cachedUScale;
  81565. private _cachedVScale;
  81566. private _cachedUAng;
  81567. private _cachedVAng;
  81568. private _cachedWAng;
  81569. private _cachedProjectionMatrixId;
  81570. private _cachedCoordinatesMode;
  81571. /** @hidden */
  81572. protected _initialSamplingMode: number;
  81573. /** @hidden */
  81574. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  81575. private _deleteBuffer;
  81576. protected _format: Nullable<number>;
  81577. private _delayedOnLoad;
  81578. private _delayedOnError;
  81579. /**
  81580. * Observable triggered once the texture has been loaded.
  81581. */
  81582. onLoadObservable: Observable<Texture>;
  81583. protected _isBlocking: boolean;
  81584. /**
  81585. * Is the texture preventing material to render while loading.
  81586. * If false, a default texture will be used instead of the loading one during the preparation step.
  81587. */
  81588. isBlocking: boolean;
  81589. /**
  81590. * Get the current sampling mode associated with the texture.
  81591. */
  81592. readonly samplingMode: number;
  81593. /**
  81594. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81595. */
  81596. readonly invertY: boolean;
  81597. /**
  81598. * Instantiates a new texture.
  81599. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81600. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81601. * @param url define the url of the picture to load as a texture
  81602. * @param scene define the scene the texture will belong to
  81603. * @param noMipmap define if the texture will require mip maps or not
  81604. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81605. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81606. * @param onLoad define a callback triggered when the texture has been loaded
  81607. * @param onError define a callback triggered when an error occurred during the loading session
  81608. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81609. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81610. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81611. */
  81612. 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);
  81613. /**
  81614. * Update the url (and optional buffer) of this texture if url was null during construction.
  81615. * @param url the url of the texture
  81616. * @param buffer the buffer of the texture (defaults to null)
  81617. * @param onLoad callback called when the texture is loaded (defaults to null)
  81618. */
  81619. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81620. /**
  81621. * Finish the loading sequence of a texture flagged as delayed load.
  81622. * @hidden
  81623. */
  81624. delayLoad(): void;
  81625. private _prepareRowForTextureGeneration;
  81626. /**
  81627. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81628. * @returns the transform matrix of the texture.
  81629. */
  81630. getTextureMatrix(): Matrix;
  81631. /**
  81632. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81633. * @returns The reflection texture transform
  81634. */
  81635. getReflectionTextureMatrix(): Matrix;
  81636. /**
  81637. * Clones the texture.
  81638. * @returns the cloned texture
  81639. */
  81640. clone(): Texture;
  81641. /**
  81642. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81643. * @returns The JSON representation of the texture
  81644. */
  81645. serialize(): any;
  81646. /**
  81647. * Get the current class name of the texture useful for serialization or dynamic coding.
  81648. * @returns "Texture"
  81649. */
  81650. getClassName(): string;
  81651. /**
  81652. * Dispose the texture and release its associated resources.
  81653. */
  81654. dispose(): void;
  81655. /**
  81656. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81657. * @param parsedTexture Define the JSON representation of the texture
  81658. * @param scene Define the scene the parsed texture should be instantiated in
  81659. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81660. * @returns The parsed texture if successful
  81661. */
  81662. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81663. /**
  81664. * Creates a texture from its base 64 representation.
  81665. * @param data Define the base64 payload without the data: prefix
  81666. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81667. * @param scene Define the scene the texture should belong to
  81668. * @param noMipmap Forces the texture to not create mip map information if true
  81669. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81670. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81671. * @param onLoad define a callback triggered when the texture has been loaded
  81672. * @param onError define a callback triggered when an error occurred during the loading session
  81673. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81674. * @returns the created texture
  81675. */
  81676. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81677. /**
  81678. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81679. * @param data Define the base64 payload without the data: prefix
  81680. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81681. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81682. * @param scene Define the scene the texture should belong to
  81683. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81684. * @param noMipmap Forces the texture to not create mip map information if true
  81685. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81686. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81687. * @param onLoad define a callback triggered when the texture has been loaded
  81688. * @param onError define a callback triggered when an error occurred during the loading session
  81689. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81690. * @returns the created texture
  81691. */
  81692. 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;
  81693. }
  81694. }
  81695. declare module BABYLON {
  81696. /**
  81697. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81698. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81699. */
  81700. export class PostProcessManager {
  81701. private _scene;
  81702. private _indexBuffer;
  81703. private _vertexBuffers;
  81704. /**
  81705. * Creates a new instance PostProcess
  81706. * @param scene The scene that the post process is associated with.
  81707. */
  81708. constructor(scene: Scene);
  81709. private _prepareBuffers;
  81710. private _buildIndexBuffer;
  81711. /**
  81712. * Rebuilds the vertex buffers of the manager.
  81713. * @hidden
  81714. */
  81715. _rebuild(): void;
  81716. /**
  81717. * Prepares a frame to be run through a post process.
  81718. * @param sourceTexture The input texture to the post procesess. (default: null)
  81719. * @param postProcesses An array of post processes to be run. (default: null)
  81720. * @returns True if the post processes were able to be run.
  81721. * @hidden
  81722. */
  81723. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81724. /**
  81725. * Manually render a set of post processes to a texture.
  81726. * @param postProcesses An array of post processes to be run.
  81727. * @param targetTexture The target texture to render to.
  81728. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81729. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81730. * @param lodLevel defines which lod of the texture to render to
  81731. */
  81732. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81733. /**
  81734. * Finalize the result of the output of the postprocesses.
  81735. * @param doNotPresent If true the result will not be displayed to the screen.
  81736. * @param targetTexture The target texture to render to.
  81737. * @param faceIndex The index of the face to bind the target texture to.
  81738. * @param postProcesses The array of post processes to render.
  81739. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81740. * @hidden
  81741. */
  81742. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81743. /**
  81744. * Disposes of the post process manager.
  81745. */
  81746. dispose(): void;
  81747. }
  81748. }
  81749. declare module BABYLON {
  81750. interface AbstractScene {
  81751. /**
  81752. * The list of procedural textures added to the scene
  81753. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81754. */
  81755. proceduralTextures: Array<ProceduralTexture>;
  81756. }
  81757. /**
  81758. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81759. * in a given scene.
  81760. */
  81761. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81762. /**
  81763. * The component name helpfull to identify the component in the list of scene components.
  81764. */
  81765. readonly name: string;
  81766. /**
  81767. * The scene the component belongs to.
  81768. */
  81769. scene: Scene;
  81770. /**
  81771. * Creates a new instance of the component for the given scene
  81772. * @param scene Defines the scene to register the component in
  81773. */
  81774. constructor(scene: Scene);
  81775. /**
  81776. * Registers the component in a given scene
  81777. */
  81778. register(): void;
  81779. /**
  81780. * Rebuilds the elements related to this component in case of
  81781. * context lost for instance.
  81782. */
  81783. rebuild(): void;
  81784. /**
  81785. * Disposes the component and the associated ressources.
  81786. */
  81787. dispose(): void;
  81788. private _beforeClear;
  81789. }
  81790. }
  81791. declare module BABYLON {
  81792. interface Engine {
  81793. /**
  81794. * Creates a new render target cube texture
  81795. * @param size defines the size of the texture
  81796. * @param options defines the options used to create the texture
  81797. * @returns a new render target cube texture stored in an InternalTexture
  81798. */
  81799. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81800. }
  81801. }
  81802. declare module BABYLON {
  81803. /** @hidden */
  81804. export var proceduralVertexShader: {
  81805. name: string;
  81806. shader: string;
  81807. };
  81808. }
  81809. declare module BABYLON {
  81810. /**
  81811. * 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.
  81812. * This is the base class of any Procedural texture and contains most of the shareable code.
  81813. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81814. */
  81815. export class ProceduralTexture extends Texture {
  81816. isCube: boolean;
  81817. /**
  81818. * Define if the texture is enabled or not (disabled texture will not render)
  81819. */
  81820. isEnabled: boolean;
  81821. /**
  81822. * Define if the texture must be cleared before rendering (default is true)
  81823. */
  81824. autoClear: boolean;
  81825. /**
  81826. * Callback called when the texture is generated
  81827. */
  81828. onGenerated: () => void;
  81829. /**
  81830. * Event raised when the texture is generated
  81831. */
  81832. onGeneratedObservable: Observable<ProceduralTexture>;
  81833. /** @hidden */
  81834. _generateMipMaps: boolean;
  81835. /** @hidden **/
  81836. _effect: Effect;
  81837. /** @hidden */
  81838. _textures: {
  81839. [key: string]: Texture;
  81840. };
  81841. private _size;
  81842. private _currentRefreshId;
  81843. private _refreshRate;
  81844. private _vertexBuffers;
  81845. private _indexBuffer;
  81846. private _uniforms;
  81847. private _samplers;
  81848. private _fragment;
  81849. private _floats;
  81850. private _ints;
  81851. private _floatsArrays;
  81852. private _colors3;
  81853. private _colors4;
  81854. private _vectors2;
  81855. private _vectors3;
  81856. private _matrices;
  81857. private _fallbackTexture;
  81858. private _fallbackTextureUsed;
  81859. private _engine;
  81860. private _cachedDefines;
  81861. private _contentUpdateId;
  81862. private _contentData;
  81863. /**
  81864. * Instantiates a new procedural texture.
  81865. * 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.
  81866. * This is the base class of any Procedural texture and contains most of the shareable code.
  81867. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81868. * @param name Define the name of the texture
  81869. * @param size Define the size of the texture to create
  81870. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81871. * @param scene Define the scene the texture belongs to
  81872. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81873. * @param generateMipMaps Define if the texture should creates mip maps or not
  81874. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81875. */
  81876. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81877. /**
  81878. * The effect that is created when initializing the post process.
  81879. * @returns The created effect corresponding the the postprocess.
  81880. */
  81881. getEffect(): Effect;
  81882. /**
  81883. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81884. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81885. */
  81886. getContent(): Nullable<ArrayBufferView>;
  81887. private _createIndexBuffer;
  81888. /** @hidden */
  81889. _rebuild(): void;
  81890. /**
  81891. * Resets the texture in order to recreate its associated resources.
  81892. * This can be called in case of context loss
  81893. */
  81894. reset(): void;
  81895. protected _getDefines(): string;
  81896. /**
  81897. * Is the texture ready to be used ? (rendered at least once)
  81898. * @returns true if ready, otherwise, false.
  81899. */
  81900. isReady(): boolean;
  81901. /**
  81902. * Resets the refresh counter of the texture and start bak from scratch.
  81903. * Could be useful to regenerate the texture if it is setup to render only once.
  81904. */
  81905. resetRefreshCounter(): void;
  81906. /**
  81907. * Set the fragment shader to use in order to render the texture.
  81908. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81909. */
  81910. setFragment(fragment: any): void;
  81911. /**
  81912. * Define the refresh rate of the texture or the rendering frequency.
  81913. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81914. */
  81915. refreshRate: number;
  81916. /** @hidden */
  81917. _shouldRender(): boolean;
  81918. /**
  81919. * Get the size the texture is rendering at.
  81920. * @returns the size (texture is always squared)
  81921. */
  81922. getRenderSize(): number;
  81923. /**
  81924. * Resize the texture to new value.
  81925. * @param size Define the new size the texture should have
  81926. * @param generateMipMaps Define whether the new texture should create mip maps
  81927. */
  81928. resize(size: number, generateMipMaps: boolean): void;
  81929. private _checkUniform;
  81930. /**
  81931. * Set a texture in the shader program used to render.
  81932. * @param name Define the name of the uniform samplers as defined in the shader
  81933. * @param texture Define the texture to bind to this sampler
  81934. * @return the texture itself allowing "fluent" like uniform updates
  81935. */
  81936. setTexture(name: string, texture: Texture): ProceduralTexture;
  81937. /**
  81938. * Set a float in the shader.
  81939. * @param name Define the name of the uniform as defined in the shader
  81940. * @param value Define the value to give to the uniform
  81941. * @return the texture itself allowing "fluent" like uniform updates
  81942. */
  81943. setFloat(name: string, value: number): ProceduralTexture;
  81944. /**
  81945. * Set a int in the shader.
  81946. * @param name Define the name of the uniform as defined in the shader
  81947. * @param value Define the value to give to the uniform
  81948. * @return the texture itself allowing "fluent" like uniform updates
  81949. */
  81950. setInt(name: string, value: number): ProceduralTexture;
  81951. /**
  81952. * Set an array of floats in the shader.
  81953. * @param name Define the name of the uniform as defined in the shader
  81954. * @param value Define the value to give to the uniform
  81955. * @return the texture itself allowing "fluent" like uniform updates
  81956. */
  81957. setFloats(name: string, value: number[]): ProceduralTexture;
  81958. /**
  81959. * Set a vec3 in the shader from a Color3.
  81960. * @param name Define the name of the uniform as defined in the shader
  81961. * @param value Define the value to give to the uniform
  81962. * @return the texture itself allowing "fluent" like uniform updates
  81963. */
  81964. setColor3(name: string, value: Color3): ProceduralTexture;
  81965. /**
  81966. * Set a vec4 in the shader from a Color4.
  81967. * @param name Define the name of the uniform as defined in the shader
  81968. * @param value Define the value to give to the uniform
  81969. * @return the texture itself allowing "fluent" like uniform updates
  81970. */
  81971. setColor4(name: string, value: Color4): ProceduralTexture;
  81972. /**
  81973. * Set a vec2 in the shader from a Vector2.
  81974. * @param name Define the name of the uniform as defined in the shader
  81975. * @param value Define the value to give to the uniform
  81976. * @return the texture itself allowing "fluent" like uniform updates
  81977. */
  81978. setVector2(name: string, value: Vector2): ProceduralTexture;
  81979. /**
  81980. * Set a vec3 in the shader from a Vector3.
  81981. * @param name Define the name of the uniform as defined in the shader
  81982. * @param value Define the value to give to the uniform
  81983. * @return the texture itself allowing "fluent" like uniform updates
  81984. */
  81985. setVector3(name: string, value: Vector3): ProceduralTexture;
  81986. /**
  81987. * Set a mat4 in the shader from a MAtrix.
  81988. * @param name Define the name of the uniform as defined in the shader
  81989. * @param value Define the value to give to the uniform
  81990. * @return the texture itself allowing "fluent" like uniform updates
  81991. */
  81992. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81993. /**
  81994. * Render the texture to its associated render target.
  81995. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81996. */
  81997. render(useCameraPostProcess?: boolean): void;
  81998. /**
  81999. * Clone the texture.
  82000. * @returns the cloned texture
  82001. */
  82002. clone(): ProceduralTexture;
  82003. /**
  82004. * Dispose the texture and release its asoociated resources.
  82005. */
  82006. dispose(): void;
  82007. }
  82008. }
  82009. declare module BABYLON {
  82010. /**
  82011. * This represents the base class for particle system in Babylon.
  82012. * 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.
  82013. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82014. * @example https://doc.babylonjs.com/babylon101/particles
  82015. */
  82016. export class BaseParticleSystem {
  82017. /**
  82018. * Source color is added to the destination color without alpha affecting the result
  82019. */
  82020. static BLENDMODE_ONEONE: number;
  82021. /**
  82022. * Blend current color and particle color using particle’s alpha
  82023. */
  82024. static BLENDMODE_STANDARD: number;
  82025. /**
  82026. * Add current color and particle color multiplied by particle’s alpha
  82027. */
  82028. static BLENDMODE_ADD: number;
  82029. /**
  82030. * Multiply current color with particle color
  82031. */
  82032. static BLENDMODE_MULTIPLY: number;
  82033. /**
  82034. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  82035. */
  82036. static BLENDMODE_MULTIPLYADD: number;
  82037. /**
  82038. * List of animations used by the particle system.
  82039. */
  82040. animations: Animation[];
  82041. /**
  82042. * The id of the Particle system.
  82043. */
  82044. id: string;
  82045. /**
  82046. * The friendly name of the Particle system.
  82047. */
  82048. name: string;
  82049. /**
  82050. * The rendering group used by the Particle system to chose when to render.
  82051. */
  82052. renderingGroupId: number;
  82053. /**
  82054. * The emitter represents the Mesh or position we are attaching the particle system to.
  82055. */
  82056. emitter: Nullable<AbstractMesh | Vector3>;
  82057. /**
  82058. * The maximum number of particles to emit per frame
  82059. */
  82060. emitRate: number;
  82061. /**
  82062. * If you want to launch only a few particles at once, that can be done, as well.
  82063. */
  82064. manualEmitCount: number;
  82065. /**
  82066. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82067. */
  82068. updateSpeed: number;
  82069. /**
  82070. * The amount of time the particle system is running (depends of the overall update speed).
  82071. */
  82072. targetStopDuration: number;
  82073. /**
  82074. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82075. */
  82076. disposeOnStop: boolean;
  82077. /**
  82078. * Minimum power of emitting particles.
  82079. */
  82080. minEmitPower: number;
  82081. /**
  82082. * Maximum power of emitting particles.
  82083. */
  82084. maxEmitPower: number;
  82085. /**
  82086. * Minimum life time of emitting particles.
  82087. */
  82088. minLifeTime: number;
  82089. /**
  82090. * Maximum life time of emitting particles.
  82091. */
  82092. maxLifeTime: number;
  82093. /**
  82094. * Minimum Size of emitting particles.
  82095. */
  82096. minSize: number;
  82097. /**
  82098. * Maximum Size of emitting particles.
  82099. */
  82100. maxSize: number;
  82101. /**
  82102. * Minimum scale of emitting particles on X axis.
  82103. */
  82104. minScaleX: number;
  82105. /**
  82106. * Maximum scale of emitting particles on X axis.
  82107. */
  82108. maxScaleX: number;
  82109. /**
  82110. * Minimum scale of emitting particles on Y axis.
  82111. */
  82112. minScaleY: number;
  82113. /**
  82114. * Maximum scale of emitting particles on Y axis.
  82115. */
  82116. maxScaleY: number;
  82117. /**
  82118. * Gets or sets the minimal initial rotation in radians.
  82119. */
  82120. minInitialRotation: number;
  82121. /**
  82122. * Gets or sets the maximal initial rotation in radians.
  82123. */
  82124. maxInitialRotation: number;
  82125. /**
  82126. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82127. */
  82128. minAngularSpeed: number;
  82129. /**
  82130. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82131. */
  82132. maxAngularSpeed: number;
  82133. /**
  82134. * The texture used to render each particle. (this can be a spritesheet)
  82135. */
  82136. particleTexture: Nullable<Texture>;
  82137. /**
  82138. * The layer mask we are rendering the particles through.
  82139. */
  82140. layerMask: number;
  82141. /**
  82142. * This can help using your own shader to render the particle system.
  82143. * The according effect will be created
  82144. */
  82145. customShader: any;
  82146. /**
  82147. * By default particle system starts as soon as they are created. This prevents the
  82148. * automatic start to happen and let you decide when to start emitting particles.
  82149. */
  82150. preventAutoStart: boolean;
  82151. private _noiseTexture;
  82152. /**
  82153. * Gets or sets a texture used to add random noise to particle positions
  82154. */
  82155. noiseTexture: Nullable<ProceduralTexture>;
  82156. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82157. noiseStrength: Vector3;
  82158. /**
  82159. * Callback triggered when the particle animation is ending.
  82160. */
  82161. onAnimationEnd: Nullable<() => void>;
  82162. /**
  82163. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82164. */
  82165. blendMode: number;
  82166. /**
  82167. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82168. * to override the particles.
  82169. */
  82170. forceDepthWrite: boolean;
  82171. /** 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 */
  82172. preWarmCycles: number;
  82173. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82174. preWarmStepOffset: number;
  82175. /**
  82176. * 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)
  82177. */
  82178. spriteCellChangeSpeed: number;
  82179. /**
  82180. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82181. */
  82182. startSpriteCellID: number;
  82183. /**
  82184. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82185. */
  82186. endSpriteCellID: number;
  82187. /**
  82188. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82189. */
  82190. spriteCellWidth: number;
  82191. /**
  82192. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82193. */
  82194. spriteCellHeight: number;
  82195. /**
  82196. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82197. */
  82198. spriteRandomStartCell: boolean;
  82199. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82200. translationPivot: Vector2;
  82201. /** @hidden */
  82202. protected _isAnimationSheetEnabled: boolean;
  82203. /**
  82204. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82205. */
  82206. beginAnimationOnStart: boolean;
  82207. /**
  82208. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82209. */
  82210. beginAnimationFrom: number;
  82211. /**
  82212. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82213. */
  82214. beginAnimationTo: number;
  82215. /**
  82216. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82217. */
  82218. beginAnimationLoop: boolean;
  82219. /**
  82220. * Gets or sets a world offset applied to all particles
  82221. */
  82222. worldOffset: Vector3;
  82223. /**
  82224. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82225. */
  82226. isAnimationSheetEnabled: boolean;
  82227. /**
  82228. * Get hosting scene
  82229. * @returns the scene
  82230. */
  82231. getScene(): Scene;
  82232. /**
  82233. * You can use gravity if you want to give an orientation to your particles.
  82234. */
  82235. gravity: Vector3;
  82236. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82237. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82238. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82239. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82240. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82241. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82242. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82243. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82244. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82245. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82246. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82247. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82248. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82249. /**
  82250. * Defines the delay in milliseconds before starting the system (0 by default)
  82251. */
  82252. startDelay: number;
  82253. /**
  82254. * Gets the current list of drag gradients.
  82255. * You must use addDragGradient and removeDragGradient to udpate this list
  82256. * @returns the list of drag gradients
  82257. */
  82258. getDragGradients(): Nullable<Array<FactorGradient>>;
  82259. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82260. limitVelocityDamping: number;
  82261. /**
  82262. * Gets the current list of limit velocity gradients.
  82263. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82264. * @returns the list of limit velocity gradients
  82265. */
  82266. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82267. /**
  82268. * Gets the current list of color gradients.
  82269. * You must use addColorGradient and removeColorGradient to udpate this list
  82270. * @returns the list of color gradients
  82271. */
  82272. getColorGradients(): Nullable<Array<ColorGradient>>;
  82273. /**
  82274. * Gets the current list of size gradients.
  82275. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82276. * @returns the list of size gradients
  82277. */
  82278. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82279. /**
  82280. * Gets the current list of color remap gradients.
  82281. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82282. * @returns the list of color remap gradients
  82283. */
  82284. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82285. /**
  82286. * Gets the current list of alpha remap gradients.
  82287. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82288. * @returns the list of alpha remap gradients
  82289. */
  82290. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82291. /**
  82292. * Gets the current list of life time gradients.
  82293. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82294. * @returns the list of life time gradients
  82295. */
  82296. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82297. /**
  82298. * Gets the current list of angular speed gradients.
  82299. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82300. * @returns the list of angular speed gradients
  82301. */
  82302. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82303. /**
  82304. * Gets the current list of velocity gradients.
  82305. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82306. * @returns the list of velocity gradients
  82307. */
  82308. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82309. /**
  82310. * Gets the current list of start size gradients.
  82311. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82312. * @returns the list of start size gradients
  82313. */
  82314. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82315. /**
  82316. * Gets the current list of emit rate gradients.
  82317. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82318. * @returns the list of emit rate gradients
  82319. */
  82320. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82321. /**
  82322. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82323. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82324. */
  82325. direction1: Vector3;
  82326. /**
  82327. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82328. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82329. */
  82330. direction2: Vector3;
  82331. /**
  82332. * 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.
  82333. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82334. */
  82335. minEmitBox: Vector3;
  82336. /**
  82337. * 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.
  82338. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82339. */
  82340. maxEmitBox: Vector3;
  82341. /**
  82342. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82343. */
  82344. color1: Color4;
  82345. /**
  82346. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82347. */
  82348. color2: Color4;
  82349. /**
  82350. * Color the particle will have at the end of its lifetime
  82351. */
  82352. colorDead: Color4;
  82353. /**
  82354. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82355. */
  82356. textureMask: Color4;
  82357. /**
  82358. * The particle emitter type defines the emitter used by the particle system.
  82359. * It can be for example box, sphere, or cone...
  82360. */
  82361. particleEmitterType: IParticleEmitterType;
  82362. /** @hidden */
  82363. _isSubEmitter: boolean;
  82364. /**
  82365. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82366. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82367. */
  82368. billboardMode: number;
  82369. protected _isBillboardBased: boolean;
  82370. /**
  82371. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82372. */
  82373. isBillboardBased: boolean;
  82374. /**
  82375. * The scene the particle system belongs to.
  82376. */
  82377. protected _scene: Scene;
  82378. /**
  82379. * Local cache of defines for image processing.
  82380. */
  82381. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82382. /**
  82383. * Default configuration related to image processing available in the standard Material.
  82384. */
  82385. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82386. /**
  82387. * Gets the image processing configuration used either in this material.
  82388. */
  82389. /**
  82390. * Sets the Default image processing configuration used either in the this material.
  82391. *
  82392. * If sets to null, the scene one is in use.
  82393. */
  82394. imageProcessingConfiguration: ImageProcessingConfiguration;
  82395. /**
  82396. * Attaches a new image processing configuration to the Standard Material.
  82397. * @param configuration
  82398. */
  82399. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82400. /** @hidden */
  82401. protected _reset(): void;
  82402. /** @hidden */
  82403. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82404. /**
  82405. * Instantiates a particle system.
  82406. * 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.
  82407. * @param name The name of the particle system
  82408. */
  82409. constructor(name: string);
  82410. /**
  82411. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82412. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82413. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82414. * @returns the emitter
  82415. */
  82416. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82417. /**
  82418. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82419. * @param radius The radius of the hemisphere to emit from
  82420. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82421. * @returns the emitter
  82422. */
  82423. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82424. /**
  82425. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82426. * @param radius The radius of the sphere to emit from
  82427. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82428. * @returns the emitter
  82429. */
  82430. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82431. /**
  82432. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82433. * @param radius The radius of the sphere to emit from
  82434. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82435. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82436. * @returns the emitter
  82437. */
  82438. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82439. /**
  82440. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82441. * @param radius The radius of the emission cylinder
  82442. * @param height The height of the emission cylinder
  82443. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82444. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82445. * @returns the emitter
  82446. */
  82447. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82448. /**
  82449. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82450. * @param radius The radius of the cylinder to emit from
  82451. * @param height The height of the emission cylinder
  82452. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82453. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82454. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82455. * @returns the emitter
  82456. */
  82457. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82458. /**
  82459. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82460. * @param radius The radius of the cone to emit from
  82461. * @param angle The base angle of the cone
  82462. * @returns the emitter
  82463. */
  82464. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82465. /**
  82466. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82467. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82468. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82469. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82470. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82471. * @returns the emitter
  82472. */
  82473. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82474. }
  82475. }
  82476. declare module BABYLON {
  82477. /**
  82478. * Type of sub emitter
  82479. */
  82480. export enum SubEmitterType {
  82481. /**
  82482. * Attached to the particle over it's lifetime
  82483. */
  82484. ATTACHED = 0,
  82485. /**
  82486. * Created when the particle dies
  82487. */
  82488. END = 1
  82489. }
  82490. /**
  82491. * Sub emitter class used to emit particles from an existing particle
  82492. */
  82493. export class SubEmitter {
  82494. /**
  82495. * the particle system to be used by the sub emitter
  82496. */
  82497. particleSystem: ParticleSystem;
  82498. /**
  82499. * Type of the submitter (Default: END)
  82500. */
  82501. type: SubEmitterType;
  82502. /**
  82503. * 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)
  82504. * Note: This only is supported when using an emitter of type Mesh
  82505. */
  82506. inheritDirection: boolean;
  82507. /**
  82508. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82509. */
  82510. inheritedVelocityAmount: number;
  82511. /**
  82512. * Creates a sub emitter
  82513. * @param particleSystem the particle system to be used by the sub emitter
  82514. */
  82515. constructor(
  82516. /**
  82517. * the particle system to be used by the sub emitter
  82518. */
  82519. particleSystem: ParticleSystem);
  82520. /**
  82521. * Clones the sub emitter
  82522. * @returns the cloned sub emitter
  82523. */
  82524. clone(): SubEmitter;
  82525. /**
  82526. * Serialize current object to a JSON object
  82527. * @returns the serialized object
  82528. */
  82529. serialize(): any;
  82530. /** @hidden */
  82531. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82532. /**
  82533. * Creates a new SubEmitter from a serialized JSON version
  82534. * @param serializationObject defines the JSON object to read from
  82535. * @param scene defines the hosting scene
  82536. * @param rootUrl defines the rootUrl for data loading
  82537. * @returns a new SubEmitter
  82538. */
  82539. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82540. /** Release associated resources */
  82541. dispose(): void;
  82542. }
  82543. }
  82544. declare module BABYLON {
  82545. /** @hidden */
  82546. export var imageProcessingDeclaration: {
  82547. name: string;
  82548. shader: string;
  82549. };
  82550. }
  82551. declare module BABYLON {
  82552. /** @hidden */
  82553. export var imageProcessingFunctions: {
  82554. name: string;
  82555. shader: string;
  82556. };
  82557. }
  82558. declare module BABYLON {
  82559. /** @hidden */
  82560. export var particlesPixelShader: {
  82561. name: string;
  82562. shader: string;
  82563. };
  82564. }
  82565. declare module BABYLON {
  82566. /** @hidden */
  82567. export var particlesVertexShader: {
  82568. name: string;
  82569. shader: string;
  82570. };
  82571. }
  82572. declare module BABYLON {
  82573. /**
  82574. * This represents a particle system in Babylon.
  82575. * 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.
  82576. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82577. * @example https://doc.babylonjs.com/babylon101/particles
  82578. */
  82579. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82580. /**
  82581. * Billboard mode will only apply to Y axis
  82582. */
  82583. static readonly BILLBOARDMODE_Y: number;
  82584. /**
  82585. * Billboard mode will apply to all axes
  82586. */
  82587. static readonly BILLBOARDMODE_ALL: number;
  82588. /**
  82589. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82590. */
  82591. static readonly BILLBOARDMODE_STRETCHED: number;
  82592. /**
  82593. * This function can be defined to provide custom update for active particles.
  82594. * This function will be called instead of regular update (age, position, color, etc.).
  82595. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82596. */
  82597. updateFunction: (particles: Particle[]) => void;
  82598. private _emitterWorldMatrix;
  82599. /**
  82600. * This function can be defined to specify initial direction for every new particle.
  82601. * It by default use the emitterType defined function
  82602. */
  82603. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82604. /**
  82605. * This function can be defined to specify initial position for every new particle.
  82606. * It by default use the emitterType defined function
  82607. */
  82608. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82609. /**
  82610. * @hidden
  82611. */
  82612. _inheritedVelocityOffset: Vector3;
  82613. /**
  82614. * An event triggered when the system is disposed
  82615. */
  82616. onDisposeObservable: Observable<ParticleSystem>;
  82617. private _onDisposeObserver;
  82618. /**
  82619. * Sets a callback that will be triggered when the system is disposed
  82620. */
  82621. onDispose: () => void;
  82622. private _particles;
  82623. private _epsilon;
  82624. private _capacity;
  82625. private _stockParticles;
  82626. private _newPartsExcess;
  82627. private _vertexData;
  82628. private _vertexBuffer;
  82629. private _vertexBuffers;
  82630. private _spriteBuffer;
  82631. private _indexBuffer;
  82632. private _effect;
  82633. private _customEffect;
  82634. private _cachedDefines;
  82635. private _scaledColorStep;
  82636. private _colorDiff;
  82637. private _scaledDirection;
  82638. private _scaledGravity;
  82639. private _currentRenderId;
  82640. private _alive;
  82641. private _useInstancing;
  82642. private _started;
  82643. private _stopped;
  82644. private _actualFrame;
  82645. private _scaledUpdateSpeed;
  82646. private _vertexBufferSize;
  82647. /** @hidden */
  82648. _currentEmitRateGradient: Nullable<FactorGradient>;
  82649. /** @hidden */
  82650. _currentEmitRate1: number;
  82651. /** @hidden */
  82652. _currentEmitRate2: number;
  82653. /** @hidden */
  82654. _currentStartSizeGradient: Nullable<FactorGradient>;
  82655. /** @hidden */
  82656. _currentStartSize1: number;
  82657. /** @hidden */
  82658. _currentStartSize2: number;
  82659. private readonly _rawTextureWidth;
  82660. private _rampGradientsTexture;
  82661. private _useRampGradients;
  82662. /** Gets or sets a boolean indicating that ramp gradients must be used
  82663. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82664. */
  82665. useRampGradients: boolean;
  82666. /**
  82667. * 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.
  82668. * 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: [])
  82669. */
  82670. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82671. private _subEmitters;
  82672. /**
  82673. * @hidden
  82674. * If the particle systems emitter should be disposed when the particle system is disposed
  82675. */
  82676. _disposeEmitterOnDispose: boolean;
  82677. /**
  82678. * The current active Sub-systems, this property is used by the root particle system only.
  82679. */
  82680. activeSubSystems: Array<ParticleSystem>;
  82681. private _rootParticleSystem;
  82682. /**
  82683. * Gets the current list of active particles
  82684. */
  82685. readonly particles: Particle[];
  82686. /**
  82687. * Returns the string "ParticleSystem"
  82688. * @returns a string containing the class name
  82689. */
  82690. getClassName(): string;
  82691. /**
  82692. * Instantiates a particle system.
  82693. * 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.
  82694. * @param name The name of the particle system
  82695. * @param capacity The max number of particles alive at the same time
  82696. * @param scene The scene the particle system belongs to
  82697. * @param customEffect a custom effect used to change the way particles are rendered by default
  82698. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82699. * @param epsilon Offset used to render the particles
  82700. */
  82701. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82702. private _addFactorGradient;
  82703. private _removeFactorGradient;
  82704. /**
  82705. * Adds a new life time gradient
  82706. * @param gradient defines the gradient to use (between 0 and 1)
  82707. * @param factor defines the life time factor to affect to the specified gradient
  82708. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82709. * @returns the current particle system
  82710. */
  82711. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82712. /**
  82713. * Remove a specific life time gradient
  82714. * @param gradient defines the gradient to remove
  82715. * @returns the current particle system
  82716. */
  82717. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82718. /**
  82719. * Adds a new size gradient
  82720. * @param gradient defines the gradient to use (between 0 and 1)
  82721. * @param factor defines the size factor to affect to the specified gradient
  82722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82723. * @returns the current particle system
  82724. */
  82725. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82726. /**
  82727. * Remove a specific size gradient
  82728. * @param gradient defines the gradient to remove
  82729. * @returns the current particle system
  82730. */
  82731. removeSizeGradient(gradient: number): IParticleSystem;
  82732. /**
  82733. * Adds a new color remap gradient
  82734. * @param gradient defines the gradient to use (between 0 and 1)
  82735. * @param min defines the color remap minimal range
  82736. * @param max defines the color remap maximal range
  82737. * @returns the current particle system
  82738. */
  82739. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82740. /**
  82741. * Remove a specific color remap gradient
  82742. * @param gradient defines the gradient to remove
  82743. * @returns the current particle system
  82744. */
  82745. removeColorRemapGradient(gradient: number): IParticleSystem;
  82746. /**
  82747. * Adds a new alpha remap gradient
  82748. * @param gradient defines the gradient to use (between 0 and 1)
  82749. * @param min defines the alpha remap minimal range
  82750. * @param max defines the alpha remap maximal range
  82751. * @returns the current particle system
  82752. */
  82753. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82754. /**
  82755. * Remove a specific alpha remap gradient
  82756. * @param gradient defines the gradient to remove
  82757. * @returns the current particle system
  82758. */
  82759. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82760. /**
  82761. * Adds a new angular speed gradient
  82762. * @param gradient defines the gradient to use (between 0 and 1)
  82763. * @param factor defines the angular speed to affect to the specified gradient
  82764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82765. * @returns the current particle system
  82766. */
  82767. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82768. /**
  82769. * Remove a specific angular speed gradient
  82770. * @param gradient defines the gradient to remove
  82771. * @returns the current particle system
  82772. */
  82773. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82774. /**
  82775. * Adds a new velocity gradient
  82776. * @param gradient defines the gradient to use (between 0 and 1)
  82777. * @param factor defines the velocity to affect to the specified gradient
  82778. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82779. * @returns the current particle system
  82780. */
  82781. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82782. /**
  82783. * Remove a specific velocity gradient
  82784. * @param gradient defines the gradient to remove
  82785. * @returns the current particle system
  82786. */
  82787. removeVelocityGradient(gradient: number): IParticleSystem;
  82788. /**
  82789. * Adds a new limit velocity gradient
  82790. * @param gradient defines the gradient to use (between 0 and 1)
  82791. * @param factor defines the limit velocity value to affect to the specified gradient
  82792. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82793. * @returns the current particle system
  82794. */
  82795. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82796. /**
  82797. * Remove a specific limit velocity gradient
  82798. * @param gradient defines the gradient to remove
  82799. * @returns the current particle system
  82800. */
  82801. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82802. /**
  82803. * Adds a new drag gradient
  82804. * @param gradient defines the gradient to use (between 0 and 1)
  82805. * @param factor defines the drag value to affect to the specified gradient
  82806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82807. * @returns the current particle system
  82808. */
  82809. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82810. /**
  82811. * Remove a specific drag gradient
  82812. * @param gradient defines the gradient to remove
  82813. * @returns the current particle system
  82814. */
  82815. removeDragGradient(gradient: number): IParticleSystem;
  82816. /**
  82817. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82818. * @param gradient defines the gradient to use (between 0 and 1)
  82819. * @param factor defines the emit rate value to affect to the specified gradient
  82820. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82821. * @returns the current particle system
  82822. */
  82823. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82824. /**
  82825. * Remove a specific emit rate gradient
  82826. * @param gradient defines the gradient to remove
  82827. * @returns the current particle system
  82828. */
  82829. removeEmitRateGradient(gradient: number): IParticleSystem;
  82830. /**
  82831. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82832. * @param gradient defines the gradient to use (between 0 and 1)
  82833. * @param factor defines the start size value to affect to the specified gradient
  82834. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82835. * @returns the current particle system
  82836. */
  82837. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82838. /**
  82839. * Remove a specific start size gradient
  82840. * @param gradient defines the gradient to remove
  82841. * @returns the current particle system
  82842. */
  82843. removeStartSizeGradient(gradient: number): IParticleSystem;
  82844. private _createRampGradientTexture;
  82845. /**
  82846. * Gets the current list of ramp gradients.
  82847. * You must use addRampGradient and removeRampGradient to udpate this list
  82848. * @returns the list of ramp gradients
  82849. */
  82850. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82851. /**
  82852. * Adds a new ramp gradient used to remap particle colors
  82853. * @param gradient defines the gradient to use (between 0 and 1)
  82854. * @param color defines the color to affect to the specified gradient
  82855. * @returns the current particle system
  82856. */
  82857. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82858. /**
  82859. * Remove a specific ramp gradient
  82860. * @param gradient defines the gradient to remove
  82861. * @returns the current particle system
  82862. */
  82863. removeRampGradient(gradient: number): ParticleSystem;
  82864. /**
  82865. * Adds a new color gradient
  82866. * @param gradient defines the gradient to use (between 0 and 1)
  82867. * @param color1 defines the color to affect to the specified gradient
  82868. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82869. * @returns this particle system
  82870. */
  82871. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82872. /**
  82873. * Remove a specific color gradient
  82874. * @param gradient defines the gradient to remove
  82875. * @returns this particle system
  82876. */
  82877. removeColorGradient(gradient: number): IParticleSystem;
  82878. private _fetchR;
  82879. protected _reset(): void;
  82880. private _resetEffect;
  82881. private _createVertexBuffers;
  82882. private _createIndexBuffer;
  82883. /**
  82884. * Gets the maximum number of particles active at the same time.
  82885. * @returns The max number of active particles.
  82886. */
  82887. getCapacity(): number;
  82888. /**
  82889. * Gets whether there are still active particles in the system.
  82890. * @returns True if it is alive, otherwise false.
  82891. */
  82892. isAlive(): boolean;
  82893. /**
  82894. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82895. * @returns True if it has been started, otherwise false.
  82896. */
  82897. isStarted(): boolean;
  82898. private _prepareSubEmitterInternalArray;
  82899. /**
  82900. * Starts the particle system and begins to emit
  82901. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82902. */
  82903. start(delay?: number): void;
  82904. /**
  82905. * Stops the particle system.
  82906. * @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.
  82907. */
  82908. stop(stopSubEmitters?: boolean): void;
  82909. /**
  82910. * Remove all active particles
  82911. */
  82912. reset(): void;
  82913. /**
  82914. * @hidden (for internal use only)
  82915. */
  82916. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82917. /**
  82918. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82919. * Its lifetime will start back at 0.
  82920. */
  82921. recycleParticle: (particle: Particle) => void;
  82922. private _stopSubEmitters;
  82923. private _createParticle;
  82924. private _removeFromRoot;
  82925. private _emitFromParticle;
  82926. private _update;
  82927. /** @hidden */
  82928. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82929. /** @hidden */
  82930. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82931. /** @hidden */
  82932. private _getEffect;
  82933. /**
  82934. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82935. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82936. */
  82937. animate(preWarmOnly?: boolean): void;
  82938. private _appendParticleVertices;
  82939. /**
  82940. * Rebuilds the particle system.
  82941. */
  82942. rebuild(): void;
  82943. /**
  82944. * Is this system ready to be used/rendered
  82945. * @return true if the system is ready
  82946. */
  82947. isReady(): boolean;
  82948. private _render;
  82949. /**
  82950. * Renders the particle system in its current state.
  82951. * @returns the current number of particles
  82952. */
  82953. render(): number;
  82954. /**
  82955. * Disposes the particle system and free the associated resources
  82956. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82957. */
  82958. dispose(disposeTexture?: boolean): void;
  82959. /**
  82960. * Clones the particle system.
  82961. * @param name The name of the cloned object
  82962. * @param newEmitter The new emitter to use
  82963. * @returns the cloned particle system
  82964. */
  82965. clone(name: string, newEmitter: any): ParticleSystem;
  82966. /**
  82967. * Serializes the particle system to a JSON object.
  82968. * @returns the JSON object
  82969. */
  82970. serialize(): any;
  82971. /** @hidden */
  82972. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82973. /** @hidden */
  82974. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82975. /**
  82976. * Parses a JSON object to create a particle system.
  82977. * @param parsedParticleSystem The JSON object to parse
  82978. * @param scene The scene to create the particle system in
  82979. * @param rootUrl The root url to use to load external dependencies like texture
  82980. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82981. * @returns the Parsed particle system
  82982. */
  82983. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82984. }
  82985. }
  82986. declare module BABYLON {
  82987. /**
  82988. * A particle represents one of the element emitted by a particle system.
  82989. * This is mainly define by its coordinates, direction, velocity and age.
  82990. */
  82991. export class Particle {
  82992. /**
  82993. * The particle system the particle belongs to.
  82994. */
  82995. particleSystem: ParticleSystem;
  82996. private static _Count;
  82997. /**
  82998. * Unique ID of the particle
  82999. */
  83000. id: number;
  83001. /**
  83002. * The world position of the particle in the scene.
  83003. */
  83004. position: Vector3;
  83005. /**
  83006. * The world direction of the particle in the scene.
  83007. */
  83008. direction: Vector3;
  83009. /**
  83010. * The color of the particle.
  83011. */
  83012. color: Color4;
  83013. /**
  83014. * The color change of the particle per step.
  83015. */
  83016. colorStep: Color4;
  83017. /**
  83018. * Defines how long will the life of the particle be.
  83019. */
  83020. lifeTime: number;
  83021. /**
  83022. * The current age of the particle.
  83023. */
  83024. age: number;
  83025. /**
  83026. * The current size of the particle.
  83027. */
  83028. size: number;
  83029. /**
  83030. * The current scale of the particle.
  83031. */
  83032. scale: Vector2;
  83033. /**
  83034. * The current angle of the particle.
  83035. */
  83036. angle: number;
  83037. /**
  83038. * Defines how fast is the angle changing.
  83039. */
  83040. angularSpeed: number;
  83041. /**
  83042. * Defines the cell index used by the particle to be rendered from a sprite.
  83043. */
  83044. cellIndex: number;
  83045. /**
  83046. * The information required to support color remapping
  83047. */
  83048. remapData: Vector4;
  83049. /** @hidden */
  83050. _randomCellOffset?: number;
  83051. /** @hidden */
  83052. _initialDirection: Nullable<Vector3>;
  83053. /** @hidden */
  83054. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  83055. /** @hidden */
  83056. _initialStartSpriteCellID: number;
  83057. /** @hidden */
  83058. _initialEndSpriteCellID: number;
  83059. /** @hidden */
  83060. _currentColorGradient: Nullable<ColorGradient>;
  83061. /** @hidden */
  83062. _currentColor1: Color4;
  83063. /** @hidden */
  83064. _currentColor2: Color4;
  83065. /** @hidden */
  83066. _currentSizeGradient: Nullable<FactorGradient>;
  83067. /** @hidden */
  83068. _currentSize1: number;
  83069. /** @hidden */
  83070. _currentSize2: number;
  83071. /** @hidden */
  83072. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83073. /** @hidden */
  83074. _currentAngularSpeed1: number;
  83075. /** @hidden */
  83076. _currentAngularSpeed2: number;
  83077. /** @hidden */
  83078. _currentVelocityGradient: Nullable<FactorGradient>;
  83079. /** @hidden */
  83080. _currentVelocity1: number;
  83081. /** @hidden */
  83082. _currentVelocity2: number;
  83083. /** @hidden */
  83084. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83085. /** @hidden */
  83086. _currentLimitVelocity1: number;
  83087. /** @hidden */
  83088. _currentLimitVelocity2: number;
  83089. /** @hidden */
  83090. _currentDragGradient: Nullable<FactorGradient>;
  83091. /** @hidden */
  83092. _currentDrag1: number;
  83093. /** @hidden */
  83094. _currentDrag2: number;
  83095. /** @hidden */
  83096. _randomNoiseCoordinates1: Vector3;
  83097. /** @hidden */
  83098. _randomNoiseCoordinates2: Vector3;
  83099. /**
  83100. * Creates a new instance Particle
  83101. * @param particleSystem the particle system the particle belongs to
  83102. */
  83103. constructor(
  83104. /**
  83105. * The particle system the particle belongs to.
  83106. */
  83107. particleSystem: ParticleSystem);
  83108. private updateCellInfoFromSystem;
  83109. /**
  83110. * Defines how the sprite cell index is updated for the particle
  83111. */
  83112. updateCellIndex(): void;
  83113. /** @hidden */
  83114. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83115. /** @hidden */
  83116. _inheritParticleInfoToSubEmitters(): void;
  83117. /** @hidden */
  83118. _reset(): void;
  83119. /**
  83120. * Copy the properties of particle to another one.
  83121. * @param other the particle to copy the information to.
  83122. */
  83123. copyTo(other: Particle): void;
  83124. }
  83125. }
  83126. declare module BABYLON {
  83127. /**
  83128. * Particle emitter represents a volume emitting particles.
  83129. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83130. */
  83131. export interface IParticleEmitterType {
  83132. /**
  83133. * Called by the particle System when the direction is computed for the created particle.
  83134. * @param worldMatrix is the world matrix of the particle system
  83135. * @param directionToUpdate is the direction vector to update with the result
  83136. * @param particle is the particle we are computed the direction for
  83137. */
  83138. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83139. /**
  83140. * Called by the particle System when the position is computed for the created particle.
  83141. * @param worldMatrix is the world matrix of the particle system
  83142. * @param positionToUpdate is the position vector to update with the result
  83143. * @param particle is the particle we are computed the position for
  83144. */
  83145. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83146. /**
  83147. * Clones the current emitter and returns a copy of it
  83148. * @returns the new emitter
  83149. */
  83150. clone(): IParticleEmitterType;
  83151. /**
  83152. * Called by the GPUParticleSystem to setup the update shader
  83153. * @param effect defines the update shader
  83154. */
  83155. applyToShader(effect: Effect): void;
  83156. /**
  83157. * Returns a string to use to update the GPU particles update shader
  83158. * @returns the effect defines string
  83159. */
  83160. getEffectDefines(): string;
  83161. /**
  83162. * Returns a string representing the class name
  83163. * @returns a string containing the class name
  83164. */
  83165. getClassName(): string;
  83166. /**
  83167. * Serializes the particle system to a JSON object.
  83168. * @returns the JSON object
  83169. */
  83170. serialize(): any;
  83171. /**
  83172. * Parse properties from a JSON object
  83173. * @param serializationObject defines the JSON object
  83174. */
  83175. parse(serializationObject: any): void;
  83176. }
  83177. }
  83178. declare module BABYLON {
  83179. /**
  83180. * Particle emitter emitting particles from the inside of a box.
  83181. * It emits the particles randomly between 2 given directions.
  83182. */
  83183. export class BoxParticleEmitter implements IParticleEmitterType {
  83184. /**
  83185. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83186. */
  83187. direction1: Vector3;
  83188. /**
  83189. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83190. */
  83191. direction2: Vector3;
  83192. /**
  83193. * 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.
  83194. */
  83195. minEmitBox: Vector3;
  83196. /**
  83197. * 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.
  83198. */
  83199. maxEmitBox: Vector3;
  83200. /**
  83201. * Creates a new instance BoxParticleEmitter
  83202. */
  83203. constructor();
  83204. /**
  83205. * Called by the particle System when the direction is computed for the created particle.
  83206. * @param worldMatrix is the world matrix of the particle system
  83207. * @param directionToUpdate is the direction vector to update with the result
  83208. * @param particle is the particle we are computed the direction for
  83209. */
  83210. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83211. /**
  83212. * Called by the particle System when the position is computed for the created particle.
  83213. * @param worldMatrix is the world matrix of the particle system
  83214. * @param positionToUpdate is the position vector to update with the result
  83215. * @param particle is the particle we are computed the position for
  83216. */
  83217. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83218. /**
  83219. * Clones the current emitter and returns a copy of it
  83220. * @returns the new emitter
  83221. */
  83222. clone(): BoxParticleEmitter;
  83223. /**
  83224. * Called by the GPUParticleSystem to setup the update shader
  83225. * @param effect defines the update shader
  83226. */
  83227. applyToShader(effect: Effect): void;
  83228. /**
  83229. * Returns a string to use to update the GPU particles update shader
  83230. * @returns a string containng the defines string
  83231. */
  83232. getEffectDefines(): string;
  83233. /**
  83234. * Returns the string "BoxParticleEmitter"
  83235. * @returns a string containing the class name
  83236. */
  83237. getClassName(): string;
  83238. /**
  83239. * Serializes the particle system to a JSON object.
  83240. * @returns the JSON object
  83241. */
  83242. serialize(): any;
  83243. /**
  83244. * Parse properties from a JSON object
  83245. * @param serializationObject defines the JSON object
  83246. */
  83247. parse(serializationObject: any): void;
  83248. }
  83249. }
  83250. declare module BABYLON {
  83251. /**
  83252. * Particle emitter emitting particles from the inside of a cone.
  83253. * It emits the particles alongside the cone volume from the base to the particle.
  83254. * The emission direction might be randomized.
  83255. */
  83256. export class ConeParticleEmitter implements IParticleEmitterType {
  83257. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83258. directionRandomizer: number;
  83259. private _radius;
  83260. private _angle;
  83261. private _height;
  83262. /**
  83263. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83264. */
  83265. radiusRange: number;
  83266. /**
  83267. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83268. */
  83269. heightRange: number;
  83270. /**
  83271. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83272. */
  83273. emitFromSpawnPointOnly: boolean;
  83274. /**
  83275. * Gets or sets the radius of the emission cone
  83276. */
  83277. radius: number;
  83278. /**
  83279. * Gets or sets the angle of the emission cone
  83280. */
  83281. angle: number;
  83282. private _buildHeight;
  83283. /**
  83284. * Creates a new instance ConeParticleEmitter
  83285. * @param radius the radius of the emission cone (1 by default)
  83286. * @param angle the cone base angle (PI by default)
  83287. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83288. */
  83289. constructor(radius?: number, angle?: number,
  83290. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83291. directionRandomizer?: number);
  83292. /**
  83293. * Called by the particle System when the direction is computed for the created particle.
  83294. * @param worldMatrix is the world matrix of the particle system
  83295. * @param directionToUpdate is the direction vector to update with the result
  83296. * @param particle is the particle we are computed the direction for
  83297. */
  83298. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83299. /**
  83300. * Called by the particle System when the position is computed for the created particle.
  83301. * @param worldMatrix is the world matrix of the particle system
  83302. * @param positionToUpdate is the position vector to update with the result
  83303. * @param particle is the particle we are computed the position for
  83304. */
  83305. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83306. /**
  83307. * Clones the current emitter and returns a copy of it
  83308. * @returns the new emitter
  83309. */
  83310. clone(): ConeParticleEmitter;
  83311. /**
  83312. * Called by the GPUParticleSystem to setup the update shader
  83313. * @param effect defines the update shader
  83314. */
  83315. applyToShader(effect: Effect): void;
  83316. /**
  83317. * Returns a string to use to update the GPU particles update shader
  83318. * @returns a string containng the defines string
  83319. */
  83320. getEffectDefines(): string;
  83321. /**
  83322. * Returns the string "ConeParticleEmitter"
  83323. * @returns a string containing the class name
  83324. */
  83325. getClassName(): string;
  83326. /**
  83327. * Serializes the particle system to a JSON object.
  83328. * @returns the JSON object
  83329. */
  83330. serialize(): any;
  83331. /**
  83332. * Parse properties from a JSON object
  83333. * @param serializationObject defines the JSON object
  83334. */
  83335. parse(serializationObject: any): void;
  83336. }
  83337. }
  83338. declare module BABYLON {
  83339. /**
  83340. * Particle emitter emitting particles from the inside of a cylinder.
  83341. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83342. */
  83343. export class CylinderParticleEmitter implements IParticleEmitterType {
  83344. /**
  83345. * The radius of the emission cylinder.
  83346. */
  83347. radius: number;
  83348. /**
  83349. * The height of the emission cylinder.
  83350. */
  83351. height: number;
  83352. /**
  83353. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83354. */
  83355. radiusRange: number;
  83356. /**
  83357. * How much to randomize the particle direction [0-1].
  83358. */
  83359. directionRandomizer: number;
  83360. /**
  83361. * Creates a new instance CylinderParticleEmitter
  83362. * @param radius the radius of the emission cylinder (1 by default)
  83363. * @param height the height of the emission cylinder (1 by default)
  83364. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83365. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83366. */
  83367. constructor(
  83368. /**
  83369. * The radius of the emission cylinder.
  83370. */
  83371. radius?: number,
  83372. /**
  83373. * The height of the emission cylinder.
  83374. */
  83375. height?: number,
  83376. /**
  83377. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83378. */
  83379. radiusRange?: number,
  83380. /**
  83381. * How much to randomize the particle direction [0-1].
  83382. */
  83383. directionRandomizer?: number);
  83384. /**
  83385. * Called by the particle System when the direction is computed for the created particle.
  83386. * @param worldMatrix is the world matrix of the particle system
  83387. * @param directionToUpdate is the direction vector to update with the result
  83388. * @param particle is the particle we are computed the direction for
  83389. */
  83390. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83391. /**
  83392. * Called by the particle System when the position is computed for the created particle.
  83393. * @param worldMatrix is the world matrix of the particle system
  83394. * @param positionToUpdate is the position vector to update with the result
  83395. * @param particle is the particle we are computed the position for
  83396. */
  83397. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83398. /**
  83399. * Clones the current emitter and returns a copy of it
  83400. * @returns the new emitter
  83401. */
  83402. clone(): CylinderParticleEmitter;
  83403. /**
  83404. * Called by the GPUParticleSystem to setup the update shader
  83405. * @param effect defines the update shader
  83406. */
  83407. applyToShader(effect: Effect): void;
  83408. /**
  83409. * Returns a string to use to update the GPU particles update shader
  83410. * @returns a string containng the defines string
  83411. */
  83412. getEffectDefines(): string;
  83413. /**
  83414. * Returns the string "CylinderParticleEmitter"
  83415. * @returns a string containing the class name
  83416. */
  83417. getClassName(): string;
  83418. /**
  83419. * Serializes the particle system to a JSON object.
  83420. * @returns the JSON object
  83421. */
  83422. serialize(): any;
  83423. /**
  83424. * Parse properties from a JSON object
  83425. * @param serializationObject defines the JSON object
  83426. */
  83427. parse(serializationObject: any): void;
  83428. }
  83429. /**
  83430. * Particle emitter emitting particles from the inside of a cylinder.
  83431. * It emits the particles randomly between two vectors.
  83432. */
  83433. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83434. /**
  83435. * The min limit of the emission direction.
  83436. */
  83437. direction1: Vector3;
  83438. /**
  83439. * The max limit of the emission direction.
  83440. */
  83441. direction2: Vector3;
  83442. /**
  83443. * Creates a new instance CylinderDirectedParticleEmitter
  83444. * @param radius the radius of the emission cylinder (1 by default)
  83445. * @param height the height of the emission cylinder (1 by default)
  83446. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83447. * @param direction1 the min limit of the emission direction (up vector by default)
  83448. * @param direction2 the max limit of the emission direction (up vector by default)
  83449. */
  83450. constructor(radius?: number, height?: number, radiusRange?: number,
  83451. /**
  83452. * The min limit of the emission direction.
  83453. */
  83454. direction1?: Vector3,
  83455. /**
  83456. * The max limit of the emission direction.
  83457. */
  83458. direction2?: Vector3);
  83459. /**
  83460. * Called by the particle System when the direction is computed for the created particle.
  83461. * @param worldMatrix is the world matrix of the particle system
  83462. * @param directionToUpdate is the direction vector to update with the result
  83463. * @param particle is the particle we are computed the direction for
  83464. */
  83465. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83466. /**
  83467. * Clones the current emitter and returns a copy of it
  83468. * @returns the new emitter
  83469. */
  83470. clone(): CylinderDirectedParticleEmitter;
  83471. /**
  83472. * Called by the GPUParticleSystem to setup the update shader
  83473. * @param effect defines the update shader
  83474. */
  83475. applyToShader(effect: Effect): void;
  83476. /**
  83477. * Returns a string to use to update the GPU particles update shader
  83478. * @returns a string containng the defines string
  83479. */
  83480. getEffectDefines(): string;
  83481. /**
  83482. * Returns the string "CylinderDirectedParticleEmitter"
  83483. * @returns a string containing the class name
  83484. */
  83485. getClassName(): string;
  83486. /**
  83487. * Serializes the particle system to a JSON object.
  83488. * @returns the JSON object
  83489. */
  83490. serialize(): any;
  83491. /**
  83492. * Parse properties from a JSON object
  83493. * @param serializationObject defines the JSON object
  83494. */
  83495. parse(serializationObject: any): void;
  83496. }
  83497. }
  83498. declare module BABYLON {
  83499. /**
  83500. * Particle emitter emitting particles from the inside of a hemisphere.
  83501. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83502. */
  83503. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83504. /**
  83505. * The radius of the emission hemisphere.
  83506. */
  83507. radius: number;
  83508. /**
  83509. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83510. */
  83511. radiusRange: number;
  83512. /**
  83513. * How much to randomize the particle direction [0-1].
  83514. */
  83515. directionRandomizer: number;
  83516. /**
  83517. * Creates a new instance HemisphericParticleEmitter
  83518. * @param radius the radius of the emission hemisphere (1 by default)
  83519. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83520. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83521. */
  83522. constructor(
  83523. /**
  83524. * The radius of the emission hemisphere.
  83525. */
  83526. radius?: number,
  83527. /**
  83528. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83529. */
  83530. radiusRange?: number,
  83531. /**
  83532. * How much to randomize the particle direction [0-1].
  83533. */
  83534. directionRandomizer?: number);
  83535. /**
  83536. * Called by the particle System when the direction is computed for the created particle.
  83537. * @param worldMatrix is the world matrix of the particle system
  83538. * @param directionToUpdate is the direction vector to update with the result
  83539. * @param particle is the particle we are computed the direction for
  83540. */
  83541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83542. /**
  83543. * Called by the particle System when the position is computed for the created particle.
  83544. * @param worldMatrix is the world matrix of the particle system
  83545. * @param positionToUpdate is the position vector to update with the result
  83546. * @param particle is the particle we are computed the position for
  83547. */
  83548. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83549. /**
  83550. * Clones the current emitter and returns a copy of it
  83551. * @returns the new emitter
  83552. */
  83553. clone(): HemisphericParticleEmitter;
  83554. /**
  83555. * Called by the GPUParticleSystem to setup the update shader
  83556. * @param effect defines the update shader
  83557. */
  83558. applyToShader(effect: Effect): void;
  83559. /**
  83560. * Returns a string to use to update the GPU particles update shader
  83561. * @returns a string containng the defines string
  83562. */
  83563. getEffectDefines(): string;
  83564. /**
  83565. * Returns the string "HemisphericParticleEmitter"
  83566. * @returns a string containing the class name
  83567. */
  83568. getClassName(): string;
  83569. /**
  83570. * Serializes the particle system to a JSON object.
  83571. * @returns the JSON object
  83572. */
  83573. serialize(): any;
  83574. /**
  83575. * Parse properties from a JSON object
  83576. * @param serializationObject defines the JSON object
  83577. */
  83578. parse(serializationObject: any): void;
  83579. }
  83580. }
  83581. declare module BABYLON {
  83582. /**
  83583. * Particle emitter emitting particles from a point.
  83584. * It emits the particles randomly between 2 given directions.
  83585. */
  83586. export class PointParticleEmitter implements IParticleEmitterType {
  83587. /**
  83588. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83589. */
  83590. direction1: Vector3;
  83591. /**
  83592. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83593. */
  83594. direction2: Vector3;
  83595. /**
  83596. * Creates a new instance PointParticleEmitter
  83597. */
  83598. constructor();
  83599. /**
  83600. * Called by the particle System when the direction is computed for the created particle.
  83601. * @param worldMatrix is the world matrix of the particle system
  83602. * @param directionToUpdate is the direction vector to update with the result
  83603. * @param particle is the particle we are computed the direction for
  83604. */
  83605. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83606. /**
  83607. * Called by the particle System when the position is computed for the created particle.
  83608. * @param worldMatrix is the world matrix of the particle system
  83609. * @param positionToUpdate is the position vector to update with the result
  83610. * @param particle is the particle we are computed the position for
  83611. */
  83612. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83613. /**
  83614. * Clones the current emitter and returns a copy of it
  83615. * @returns the new emitter
  83616. */
  83617. clone(): PointParticleEmitter;
  83618. /**
  83619. * Called by the GPUParticleSystem to setup the update shader
  83620. * @param effect defines the update shader
  83621. */
  83622. applyToShader(effect: Effect): void;
  83623. /**
  83624. * Returns a string to use to update the GPU particles update shader
  83625. * @returns a string containng the defines string
  83626. */
  83627. getEffectDefines(): string;
  83628. /**
  83629. * Returns the string "PointParticleEmitter"
  83630. * @returns a string containing the class name
  83631. */
  83632. getClassName(): string;
  83633. /**
  83634. * Serializes the particle system to a JSON object.
  83635. * @returns the JSON object
  83636. */
  83637. serialize(): any;
  83638. /**
  83639. * Parse properties from a JSON object
  83640. * @param serializationObject defines the JSON object
  83641. */
  83642. parse(serializationObject: any): void;
  83643. }
  83644. }
  83645. declare module BABYLON {
  83646. /**
  83647. * Particle emitter emitting particles from the inside of a sphere.
  83648. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83649. */
  83650. export class SphereParticleEmitter implements IParticleEmitterType {
  83651. /**
  83652. * The radius of the emission sphere.
  83653. */
  83654. radius: number;
  83655. /**
  83656. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83657. */
  83658. radiusRange: number;
  83659. /**
  83660. * How much to randomize the particle direction [0-1].
  83661. */
  83662. directionRandomizer: number;
  83663. /**
  83664. * Creates a new instance SphereParticleEmitter
  83665. * @param radius the radius of the emission sphere (1 by default)
  83666. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83667. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83668. */
  83669. constructor(
  83670. /**
  83671. * The radius of the emission sphere.
  83672. */
  83673. radius?: number,
  83674. /**
  83675. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83676. */
  83677. radiusRange?: number,
  83678. /**
  83679. * How much to randomize the particle direction [0-1].
  83680. */
  83681. directionRandomizer?: number);
  83682. /**
  83683. * Called by the particle System when the direction is computed for the created particle.
  83684. * @param worldMatrix is the world matrix of the particle system
  83685. * @param directionToUpdate is the direction vector to update with the result
  83686. * @param particle is the particle we are computed the direction for
  83687. */
  83688. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83689. /**
  83690. * Called by the particle System when the position is computed for the created particle.
  83691. * @param worldMatrix is the world matrix of the particle system
  83692. * @param positionToUpdate is the position vector to update with the result
  83693. * @param particle is the particle we are computed the position for
  83694. */
  83695. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83696. /**
  83697. * Clones the current emitter and returns a copy of it
  83698. * @returns the new emitter
  83699. */
  83700. clone(): SphereParticleEmitter;
  83701. /**
  83702. * Called by the GPUParticleSystem to setup the update shader
  83703. * @param effect defines the update shader
  83704. */
  83705. applyToShader(effect: Effect): void;
  83706. /**
  83707. * Returns a string to use to update the GPU particles update shader
  83708. * @returns a string containng the defines string
  83709. */
  83710. getEffectDefines(): string;
  83711. /**
  83712. * Returns the string "SphereParticleEmitter"
  83713. * @returns a string containing the class name
  83714. */
  83715. getClassName(): string;
  83716. /**
  83717. * Serializes the particle system to a JSON object.
  83718. * @returns the JSON object
  83719. */
  83720. serialize(): any;
  83721. /**
  83722. * Parse properties from a JSON object
  83723. * @param serializationObject defines the JSON object
  83724. */
  83725. parse(serializationObject: any): void;
  83726. }
  83727. /**
  83728. * Particle emitter emitting particles from the inside of a sphere.
  83729. * It emits the particles randomly between two vectors.
  83730. */
  83731. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83732. /**
  83733. * The min limit of the emission direction.
  83734. */
  83735. direction1: Vector3;
  83736. /**
  83737. * The max limit of the emission direction.
  83738. */
  83739. direction2: Vector3;
  83740. /**
  83741. * Creates a new instance SphereDirectedParticleEmitter
  83742. * @param radius the radius of the emission sphere (1 by default)
  83743. * @param direction1 the min limit of the emission direction (up vector by default)
  83744. * @param direction2 the max limit of the emission direction (up vector by default)
  83745. */
  83746. constructor(radius?: number,
  83747. /**
  83748. * The min limit of the emission direction.
  83749. */
  83750. direction1?: Vector3,
  83751. /**
  83752. * The max limit of the emission direction.
  83753. */
  83754. direction2?: Vector3);
  83755. /**
  83756. * Called by the particle System when the direction is computed for the created particle.
  83757. * @param worldMatrix is the world matrix of the particle system
  83758. * @param directionToUpdate is the direction vector to update with the result
  83759. * @param particle is the particle we are computed the direction for
  83760. */
  83761. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83762. /**
  83763. * Clones the current emitter and returns a copy of it
  83764. * @returns the new emitter
  83765. */
  83766. clone(): SphereDirectedParticleEmitter;
  83767. /**
  83768. * Called by the GPUParticleSystem to setup the update shader
  83769. * @param effect defines the update shader
  83770. */
  83771. applyToShader(effect: Effect): void;
  83772. /**
  83773. * Returns a string to use to update the GPU particles update shader
  83774. * @returns a string containng the defines string
  83775. */
  83776. getEffectDefines(): string;
  83777. /**
  83778. * Returns the string "SphereDirectedParticleEmitter"
  83779. * @returns a string containing the class name
  83780. */
  83781. getClassName(): string;
  83782. /**
  83783. * Serializes the particle system to a JSON object.
  83784. * @returns the JSON object
  83785. */
  83786. serialize(): any;
  83787. /**
  83788. * Parse properties from a JSON object
  83789. * @param serializationObject defines the JSON object
  83790. */
  83791. parse(serializationObject: any): void;
  83792. }
  83793. }
  83794. declare module BABYLON {
  83795. /**
  83796. * Interface representing a particle system in Babylon.js.
  83797. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83798. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83799. */
  83800. export interface IParticleSystem {
  83801. /**
  83802. * List of animations used by the particle system.
  83803. */
  83804. animations: Animation[];
  83805. /**
  83806. * The id of the Particle system.
  83807. */
  83808. id: string;
  83809. /**
  83810. * The name of the Particle system.
  83811. */
  83812. name: string;
  83813. /**
  83814. * The emitter represents the Mesh or position we are attaching the particle system to.
  83815. */
  83816. emitter: Nullable<AbstractMesh | Vector3>;
  83817. /**
  83818. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83819. */
  83820. isBillboardBased: boolean;
  83821. /**
  83822. * The rendering group used by the Particle system to chose when to render.
  83823. */
  83824. renderingGroupId: number;
  83825. /**
  83826. * The layer mask we are rendering the particles through.
  83827. */
  83828. layerMask: number;
  83829. /**
  83830. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83831. */
  83832. updateSpeed: number;
  83833. /**
  83834. * The amount of time the particle system is running (depends of the overall update speed).
  83835. */
  83836. targetStopDuration: number;
  83837. /**
  83838. * The texture used to render each particle. (this can be a spritesheet)
  83839. */
  83840. particleTexture: Nullable<Texture>;
  83841. /**
  83842. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83843. */
  83844. blendMode: number;
  83845. /**
  83846. * Minimum life time of emitting particles.
  83847. */
  83848. minLifeTime: number;
  83849. /**
  83850. * Maximum life time of emitting particles.
  83851. */
  83852. maxLifeTime: number;
  83853. /**
  83854. * Minimum Size of emitting particles.
  83855. */
  83856. minSize: number;
  83857. /**
  83858. * Maximum Size of emitting particles.
  83859. */
  83860. maxSize: number;
  83861. /**
  83862. * Minimum scale of emitting particles on X axis.
  83863. */
  83864. minScaleX: number;
  83865. /**
  83866. * Maximum scale of emitting particles on X axis.
  83867. */
  83868. maxScaleX: number;
  83869. /**
  83870. * Minimum scale of emitting particles on Y axis.
  83871. */
  83872. minScaleY: number;
  83873. /**
  83874. * Maximum scale of emitting particles on Y axis.
  83875. */
  83876. maxScaleY: number;
  83877. /**
  83878. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83879. */
  83880. color1: Color4;
  83881. /**
  83882. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83883. */
  83884. color2: Color4;
  83885. /**
  83886. * Color the particle will have at the end of its lifetime.
  83887. */
  83888. colorDead: Color4;
  83889. /**
  83890. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83891. */
  83892. emitRate: number;
  83893. /**
  83894. * You can use gravity if you want to give an orientation to your particles.
  83895. */
  83896. gravity: Vector3;
  83897. /**
  83898. * Minimum power of emitting particles.
  83899. */
  83900. minEmitPower: number;
  83901. /**
  83902. * Maximum power of emitting particles.
  83903. */
  83904. maxEmitPower: number;
  83905. /**
  83906. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83907. */
  83908. minAngularSpeed: number;
  83909. /**
  83910. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83911. */
  83912. maxAngularSpeed: number;
  83913. /**
  83914. * Gets or sets the minimal initial rotation in radians.
  83915. */
  83916. minInitialRotation: number;
  83917. /**
  83918. * Gets or sets the maximal initial rotation in radians.
  83919. */
  83920. maxInitialRotation: number;
  83921. /**
  83922. * The particle emitter type defines the emitter used by the particle system.
  83923. * It can be for example box, sphere, or cone...
  83924. */
  83925. particleEmitterType: Nullable<IParticleEmitterType>;
  83926. /**
  83927. * Defines the delay in milliseconds before starting the system (0 by default)
  83928. */
  83929. startDelay: number;
  83930. /**
  83931. * 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
  83932. */
  83933. preWarmCycles: number;
  83934. /**
  83935. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83936. */
  83937. preWarmStepOffset: number;
  83938. /**
  83939. * 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)
  83940. */
  83941. spriteCellChangeSpeed: number;
  83942. /**
  83943. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83944. */
  83945. startSpriteCellID: number;
  83946. /**
  83947. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83948. */
  83949. endSpriteCellID: number;
  83950. /**
  83951. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83952. */
  83953. spriteCellWidth: number;
  83954. /**
  83955. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83956. */
  83957. spriteCellHeight: number;
  83958. /**
  83959. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83960. */
  83961. spriteRandomStartCell: boolean;
  83962. /**
  83963. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83964. */
  83965. isAnimationSheetEnabled: boolean;
  83966. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83967. translationPivot: Vector2;
  83968. /**
  83969. * Gets or sets a texture used to add random noise to particle positions
  83970. */
  83971. noiseTexture: Nullable<BaseTexture>;
  83972. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83973. noiseStrength: Vector3;
  83974. /**
  83975. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83976. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83977. */
  83978. billboardMode: number;
  83979. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83980. limitVelocityDamping: number;
  83981. /**
  83982. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83983. */
  83984. beginAnimationOnStart: boolean;
  83985. /**
  83986. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83987. */
  83988. beginAnimationFrom: number;
  83989. /**
  83990. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83991. */
  83992. beginAnimationTo: number;
  83993. /**
  83994. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83995. */
  83996. beginAnimationLoop: boolean;
  83997. /**
  83998. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83999. */
  84000. disposeOnStop: boolean;
  84001. /**
  84002. * Gets the maximum number of particles active at the same time.
  84003. * @returns The max number of active particles.
  84004. */
  84005. getCapacity(): number;
  84006. /**
  84007. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84008. * @returns True if it has been started, otherwise false.
  84009. */
  84010. isStarted(): boolean;
  84011. /**
  84012. * Animates the particle system for this frame.
  84013. */
  84014. animate(): void;
  84015. /**
  84016. * Renders the particle system in its current state.
  84017. * @returns the current number of particles
  84018. */
  84019. render(): number;
  84020. /**
  84021. * Dispose the particle system and frees its associated resources.
  84022. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84023. */
  84024. dispose(disposeTexture?: boolean): void;
  84025. /**
  84026. * Clones the particle system.
  84027. * @param name The name of the cloned object
  84028. * @param newEmitter The new emitter to use
  84029. * @returns the cloned particle system
  84030. */
  84031. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  84032. /**
  84033. * Serializes the particle system to a JSON object.
  84034. * @returns the JSON object
  84035. */
  84036. serialize(): any;
  84037. /**
  84038. * Rebuild the particle system
  84039. */
  84040. rebuild(): void;
  84041. /**
  84042. * Starts the particle system and begins to emit
  84043. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  84044. */
  84045. start(delay?: number): void;
  84046. /**
  84047. * Stops the particle system.
  84048. */
  84049. stop(): void;
  84050. /**
  84051. * Remove all active particles
  84052. */
  84053. reset(): void;
  84054. /**
  84055. * Is this system ready to be used/rendered
  84056. * @return true if the system is ready
  84057. */
  84058. isReady(): boolean;
  84059. /**
  84060. * Adds a new color gradient
  84061. * @param gradient defines the gradient to use (between 0 and 1)
  84062. * @param color1 defines the color to affect to the specified gradient
  84063. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84064. * @returns the current particle system
  84065. */
  84066. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84067. /**
  84068. * Remove a specific color gradient
  84069. * @param gradient defines the gradient to remove
  84070. * @returns the current particle system
  84071. */
  84072. removeColorGradient(gradient: number): IParticleSystem;
  84073. /**
  84074. * Adds a new size gradient
  84075. * @param gradient defines the gradient to use (between 0 and 1)
  84076. * @param factor defines the size factor to affect to the specified gradient
  84077. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84078. * @returns the current particle system
  84079. */
  84080. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84081. /**
  84082. * Remove a specific size gradient
  84083. * @param gradient defines the gradient to remove
  84084. * @returns the current particle system
  84085. */
  84086. removeSizeGradient(gradient: number): IParticleSystem;
  84087. /**
  84088. * Gets the current list of color gradients.
  84089. * You must use addColorGradient and removeColorGradient to udpate this list
  84090. * @returns the list of color gradients
  84091. */
  84092. getColorGradients(): Nullable<Array<ColorGradient>>;
  84093. /**
  84094. * Gets the current list of size gradients.
  84095. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84096. * @returns the list of size gradients
  84097. */
  84098. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84099. /**
  84100. * Gets the current list of angular speed gradients.
  84101. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84102. * @returns the list of angular speed gradients
  84103. */
  84104. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84105. /**
  84106. * Adds a new angular speed gradient
  84107. * @param gradient defines the gradient to use (between 0 and 1)
  84108. * @param factor defines the angular speed to affect to the specified gradient
  84109. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84110. * @returns the current particle system
  84111. */
  84112. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84113. /**
  84114. * Remove a specific angular speed gradient
  84115. * @param gradient defines the gradient to remove
  84116. * @returns the current particle system
  84117. */
  84118. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84119. /**
  84120. * Gets the current list of velocity gradients.
  84121. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84122. * @returns the list of velocity gradients
  84123. */
  84124. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84125. /**
  84126. * Adds a new velocity gradient
  84127. * @param gradient defines the gradient to use (between 0 and 1)
  84128. * @param factor defines the velocity to affect to the specified gradient
  84129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84130. * @returns the current particle system
  84131. */
  84132. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84133. /**
  84134. * Remove a specific velocity gradient
  84135. * @param gradient defines the gradient to remove
  84136. * @returns the current particle system
  84137. */
  84138. removeVelocityGradient(gradient: number): IParticleSystem;
  84139. /**
  84140. * Gets the current list of limit velocity gradients.
  84141. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84142. * @returns the list of limit velocity gradients
  84143. */
  84144. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84145. /**
  84146. * Adds a new limit velocity gradient
  84147. * @param gradient defines the gradient to use (between 0 and 1)
  84148. * @param factor defines the limit velocity to affect to the specified gradient
  84149. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84150. * @returns the current particle system
  84151. */
  84152. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84153. /**
  84154. * Remove a specific limit velocity gradient
  84155. * @param gradient defines the gradient to remove
  84156. * @returns the current particle system
  84157. */
  84158. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84159. /**
  84160. * Adds a new drag gradient
  84161. * @param gradient defines the gradient to use (between 0 and 1)
  84162. * @param factor defines the drag to affect to the specified gradient
  84163. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84164. * @returns the current particle system
  84165. */
  84166. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84167. /**
  84168. * Remove a specific drag gradient
  84169. * @param gradient defines the gradient to remove
  84170. * @returns the current particle system
  84171. */
  84172. removeDragGradient(gradient: number): IParticleSystem;
  84173. /**
  84174. * Gets the current list of drag gradients.
  84175. * You must use addDragGradient and removeDragGradient to udpate this list
  84176. * @returns the list of drag gradients
  84177. */
  84178. getDragGradients(): Nullable<Array<FactorGradient>>;
  84179. /**
  84180. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84181. * @param gradient defines the gradient to use (between 0 and 1)
  84182. * @param factor defines the emit rate to affect to the specified gradient
  84183. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84184. * @returns the current particle system
  84185. */
  84186. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84187. /**
  84188. * Remove a specific emit rate gradient
  84189. * @param gradient defines the gradient to remove
  84190. * @returns the current particle system
  84191. */
  84192. removeEmitRateGradient(gradient: number): IParticleSystem;
  84193. /**
  84194. * Gets the current list of emit rate gradients.
  84195. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84196. * @returns the list of emit rate gradients
  84197. */
  84198. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84199. /**
  84200. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84201. * @param gradient defines the gradient to use (between 0 and 1)
  84202. * @param factor defines the start size to affect to the specified gradient
  84203. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84204. * @returns the current particle system
  84205. */
  84206. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84207. /**
  84208. * Remove a specific start size gradient
  84209. * @param gradient defines the gradient to remove
  84210. * @returns the current particle system
  84211. */
  84212. removeStartSizeGradient(gradient: number): IParticleSystem;
  84213. /**
  84214. * Gets the current list of start size gradients.
  84215. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84216. * @returns the list of start size gradients
  84217. */
  84218. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84219. /**
  84220. * Adds a new life time gradient
  84221. * @param gradient defines the gradient to use (between 0 and 1)
  84222. * @param factor defines the life time factor to affect to the specified gradient
  84223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84224. * @returns the current particle system
  84225. */
  84226. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84227. /**
  84228. * Remove a specific life time gradient
  84229. * @param gradient defines the gradient to remove
  84230. * @returns the current particle system
  84231. */
  84232. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84233. /**
  84234. * Gets the current list of life time gradients.
  84235. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84236. * @returns the list of life time gradients
  84237. */
  84238. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84239. /**
  84240. * Gets the current list of color gradients.
  84241. * You must use addColorGradient and removeColorGradient to udpate this list
  84242. * @returns the list of color gradients
  84243. */
  84244. getColorGradients(): Nullable<Array<ColorGradient>>;
  84245. /**
  84246. * Adds a new ramp gradient used to remap particle colors
  84247. * @param gradient defines the gradient to use (between 0 and 1)
  84248. * @param color defines the color to affect to the specified gradient
  84249. * @returns the current particle system
  84250. */
  84251. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84252. /**
  84253. * Gets the current list of ramp gradients.
  84254. * You must use addRampGradient and removeRampGradient to udpate this list
  84255. * @returns the list of ramp gradients
  84256. */
  84257. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84258. /** Gets or sets a boolean indicating that ramp gradients must be used
  84259. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84260. */
  84261. useRampGradients: boolean;
  84262. /**
  84263. * Adds a new color remap gradient
  84264. * @param gradient defines the gradient to use (between 0 and 1)
  84265. * @param min defines the color remap minimal range
  84266. * @param max defines the color remap maximal range
  84267. * @returns the current particle system
  84268. */
  84269. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84270. /**
  84271. * Gets the current list of color remap gradients.
  84272. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84273. * @returns the list of color remap gradients
  84274. */
  84275. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84276. /**
  84277. * Adds a new alpha remap gradient
  84278. * @param gradient defines the gradient to use (between 0 and 1)
  84279. * @param min defines the alpha remap minimal range
  84280. * @param max defines the alpha remap maximal range
  84281. * @returns the current particle system
  84282. */
  84283. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84284. /**
  84285. * Gets the current list of alpha remap gradients.
  84286. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84287. * @returns the list of alpha remap gradients
  84288. */
  84289. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84290. /**
  84291. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84292. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84293. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84294. * @returns the emitter
  84295. */
  84296. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84297. /**
  84298. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84299. * @param radius The radius of the hemisphere to emit from
  84300. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84301. * @returns the emitter
  84302. */
  84303. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84304. /**
  84305. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84306. * @param radius The radius of the sphere to emit from
  84307. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84308. * @returns the emitter
  84309. */
  84310. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84311. /**
  84312. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84313. * @param radius The radius of the sphere to emit from
  84314. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84315. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84316. * @returns the emitter
  84317. */
  84318. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84319. /**
  84320. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84321. * @param radius The radius of the emission cylinder
  84322. * @param height The height of the emission cylinder
  84323. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84324. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84325. * @returns the emitter
  84326. */
  84327. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84328. /**
  84329. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84330. * @param radius The radius of the cylinder to emit from
  84331. * @param height The height of the emission cylinder
  84332. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84333. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84334. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84335. * @returns the emitter
  84336. */
  84337. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84338. /**
  84339. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84340. * @param radius The radius of the cone to emit from
  84341. * @param angle The base angle of the cone
  84342. * @returns the emitter
  84343. */
  84344. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84345. /**
  84346. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84347. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84348. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84349. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84350. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84351. * @returns the emitter
  84352. */
  84353. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84354. /**
  84355. * Get hosting scene
  84356. * @returns the scene
  84357. */
  84358. getScene(): Scene;
  84359. }
  84360. }
  84361. declare module BABYLON {
  84362. /** @hidden */
  84363. export var linePixelShader: {
  84364. name: string;
  84365. shader: string;
  84366. };
  84367. }
  84368. declare module BABYLON {
  84369. /** @hidden */
  84370. export var lineVertexShader: {
  84371. name: string;
  84372. shader: string;
  84373. };
  84374. }
  84375. declare module BABYLON {
  84376. interface AbstractMesh {
  84377. /**
  84378. * Gets the edgesRenderer associated with the mesh
  84379. */
  84380. edgesRenderer: Nullable<EdgesRenderer>;
  84381. }
  84382. interface LinesMesh {
  84383. /**
  84384. * Enables the edge rendering mode on the mesh.
  84385. * This mode makes the mesh edges visible
  84386. * @param epsilon defines the maximal distance between two angles to detect a face
  84387. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84388. * @returns the currentAbstractMesh
  84389. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84390. */
  84391. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84392. }
  84393. interface InstancedLinesMesh {
  84394. /**
  84395. * Enables the edge rendering mode on the mesh.
  84396. * This mode makes the mesh edges visible
  84397. * @param epsilon defines the maximal distance between two angles to detect a face
  84398. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84399. * @returns the current InstancedLinesMesh
  84400. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84401. */
  84402. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84403. }
  84404. /**
  84405. * Defines the minimum contract an Edges renderer should follow.
  84406. */
  84407. export interface IEdgesRenderer extends IDisposable {
  84408. /**
  84409. * Gets or sets a boolean indicating if the edgesRenderer is active
  84410. */
  84411. isEnabled: boolean;
  84412. /**
  84413. * Renders the edges of the attached mesh,
  84414. */
  84415. render(): void;
  84416. /**
  84417. * Checks wether or not the edges renderer is ready to render.
  84418. * @return true if ready, otherwise false.
  84419. */
  84420. isReady(): boolean;
  84421. }
  84422. /**
  84423. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84424. */
  84425. export class EdgesRenderer implements IEdgesRenderer {
  84426. /**
  84427. * Define the size of the edges with an orthographic camera
  84428. */
  84429. edgesWidthScalerForOrthographic: number;
  84430. /**
  84431. * Define the size of the edges with a perspective camera
  84432. */
  84433. edgesWidthScalerForPerspective: number;
  84434. protected _source: AbstractMesh;
  84435. protected _linesPositions: number[];
  84436. protected _linesNormals: number[];
  84437. protected _linesIndices: number[];
  84438. protected _epsilon: number;
  84439. protected _indicesCount: number;
  84440. protected _lineShader: ShaderMaterial;
  84441. protected _ib: DataBuffer;
  84442. protected _buffers: {
  84443. [key: string]: Nullable<VertexBuffer>;
  84444. };
  84445. protected _checkVerticesInsteadOfIndices: boolean;
  84446. private _meshRebuildObserver;
  84447. private _meshDisposeObserver;
  84448. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84449. isEnabled: boolean;
  84450. /**
  84451. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84452. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84453. * @param source Mesh used to create edges
  84454. * @param epsilon sum of angles in adjacency to check for edge
  84455. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84456. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84457. */
  84458. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84459. protected _prepareRessources(): void;
  84460. /** @hidden */
  84461. _rebuild(): void;
  84462. /**
  84463. * Releases the required resources for the edges renderer
  84464. */
  84465. dispose(): void;
  84466. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84467. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84468. /**
  84469. * Checks if the pair of p0 and p1 is en edge
  84470. * @param faceIndex
  84471. * @param edge
  84472. * @param faceNormals
  84473. * @param p0
  84474. * @param p1
  84475. * @private
  84476. */
  84477. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84478. /**
  84479. * push line into the position, normal and index buffer
  84480. * @protected
  84481. */
  84482. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84483. /**
  84484. * Generates lines edges from adjacencjes
  84485. * @private
  84486. */
  84487. _generateEdgesLines(): void;
  84488. /**
  84489. * Checks wether or not the edges renderer is ready to render.
  84490. * @return true if ready, otherwise false.
  84491. */
  84492. isReady(): boolean;
  84493. /**
  84494. * Renders the edges of the attached mesh,
  84495. */
  84496. render(): void;
  84497. }
  84498. /**
  84499. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84500. */
  84501. export class LineEdgesRenderer extends EdgesRenderer {
  84502. /**
  84503. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84504. * @param source LineMesh used to generate edges
  84505. * @param epsilon not important (specified angle for edge detection)
  84506. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84507. */
  84508. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84509. /**
  84510. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84511. */
  84512. _generateEdgesLines(): void;
  84513. }
  84514. }
  84515. declare module BABYLON {
  84516. /**
  84517. * This represents the object necessary to create a rendering group.
  84518. * This is exclusively used and created by the rendering manager.
  84519. * To modify the behavior, you use the available helpers in your scene or meshes.
  84520. * @hidden
  84521. */
  84522. export class RenderingGroup {
  84523. index: number;
  84524. private static _zeroVector;
  84525. private _scene;
  84526. private _opaqueSubMeshes;
  84527. private _transparentSubMeshes;
  84528. private _alphaTestSubMeshes;
  84529. private _depthOnlySubMeshes;
  84530. private _particleSystems;
  84531. private _spriteManagers;
  84532. private _opaqueSortCompareFn;
  84533. private _alphaTestSortCompareFn;
  84534. private _transparentSortCompareFn;
  84535. private _renderOpaque;
  84536. private _renderAlphaTest;
  84537. private _renderTransparent;
  84538. /** @hidden */
  84539. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84540. onBeforeTransparentRendering: () => void;
  84541. /**
  84542. * Set the opaque sort comparison function.
  84543. * If null the sub meshes will be render in the order they were created
  84544. */
  84545. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84546. /**
  84547. * Set the alpha test sort comparison function.
  84548. * If null the sub meshes will be render in the order they were created
  84549. */
  84550. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84551. /**
  84552. * Set the transparent sort comparison function.
  84553. * If null the sub meshes will be render in the order they were created
  84554. */
  84555. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84556. /**
  84557. * Creates a new rendering group.
  84558. * @param index The rendering group index
  84559. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84560. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84561. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84562. */
  84563. 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>);
  84564. /**
  84565. * Render all the sub meshes contained in the group.
  84566. * @param customRenderFunction Used to override the default render behaviour of the group.
  84567. * @returns true if rendered some submeshes.
  84568. */
  84569. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84570. /**
  84571. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84572. * @param subMeshes The submeshes to render
  84573. */
  84574. private renderOpaqueSorted;
  84575. /**
  84576. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84577. * @param subMeshes The submeshes to render
  84578. */
  84579. private renderAlphaTestSorted;
  84580. /**
  84581. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84582. * @param subMeshes The submeshes to render
  84583. */
  84584. private renderTransparentSorted;
  84585. /**
  84586. * Renders the submeshes in a specified order.
  84587. * @param subMeshes The submeshes to sort before render
  84588. * @param sortCompareFn The comparison function use to sort
  84589. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84590. * @param transparent Specifies to activate blending if true
  84591. */
  84592. private static renderSorted;
  84593. /**
  84594. * Renders the submeshes in the order they were dispatched (no sort applied).
  84595. * @param subMeshes The submeshes to render
  84596. */
  84597. private static renderUnsorted;
  84598. /**
  84599. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84600. * are rendered back to front if in the same alpha index.
  84601. *
  84602. * @param a The first submesh
  84603. * @param b The second submesh
  84604. * @returns The result of the comparison
  84605. */
  84606. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84607. /**
  84608. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84609. * are rendered back to front.
  84610. *
  84611. * @param a The first submesh
  84612. * @param b The second submesh
  84613. * @returns The result of the comparison
  84614. */
  84615. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84616. /**
  84617. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84618. * are rendered front to back (prevent overdraw).
  84619. *
  84620. * @param a The first submesh
  84621. * @param b The second submesh
  84622. * @returns The result of the comparison
  84623. */
  84624. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84625. /**
  84626. * Resets the different lists of submeshes to prepare a new frame.
  84627. */
  84628. prepare(): void;
  84629. dispose(): void;
  84630. /**
  84631. * Inserts the submesh in its correct queue depending on its material.
  84632. * @param subMesh The submesh to dispatch
  84633. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84634. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84635. */
  84636. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84637. dispatchSprites(spriteManager: ISpriteManager): void;
  84638. dispatchParticles(particleSystem: IParticleSystem): void;
  84639. private _renderParticles;
  84640. private _renderSprites;
  84641. }
  84642. }
  84643. declare module BABYLON {
  84644. /**
  84645. * Interface describing the different options available in the rendering manager
  84646. * regarding Auto Clear between groups.
  84647. */
  84648. export interface IRenderingManagerAutoClearSetup {
  84649. /**
  84650. * Defines whether or not autoclear is enable.
  84651. */
  84652. autoClear: boolean;
  84653. /**
  84654. * Defines whether or not to autoclear the depth buffer.
  84655. */
  84656. depth: boolean;
  84657. /**
  84658. * Defines whether or not to autoclear the stencil buffer.
  84659. */
  84660. stencil: boolean;
  84661. }
  84662. /**
  84663. * This class is used by the onRenderingGroupObservable
  84664. */
  84665. export class RenderingGroupInfo {
  84666. /**
  84667. * The Scene that being rendered
  84668. */
  84669. scene: Scene;
  84670. /**
  84671. * The camera currently used for the rendering pass
  84672. */
  84673. camera: Nullable<Camera>;
  84674. /**
  84675. * The ID of the renderingGroup being processed
  84676. */
  84677. renderingGroupId: number;
  84678. }
  84679. /**
  84680. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84681. * It is enable to manage the different groups as well as the different necessary sort functions.
  84682. * This should not be used directly aside of the few static configurations
  84683. */
  84684. export class RenderingManager {
  84685. /**
  84686. * The max id used for rendering groups (not included)
  84687. */
  84688. static MAX_RENDERINGGROUPS: number;
  84689. /**
  84690. * The min id used for rendering groups (included)
  84691. */
  84692. static MIN_RENDERINGGROUPS: number;
  84693. /**
  84694. * Used to globally prevent autoclearing scenes.
  84695. */
  84696. static AUTOCLEAR: boolean;
  84697. /**
  84698. * @hidden
  84699. */
  84700. _useSceneAutoClearSetup: boolean;
  84701. private _scene;
  84702. private _renderingGroups;
  84703. private _depthStencilBufferAlreadyCleaned;
  84704. private _autoClearDepthStencil;
  84705. private _customOpaqueSortCompareFn;
  84706. private _customAlphaTestSortCompareFn;
  84707. private _customTransparentSortCompareFn;
  84708. private _renderingGroupInfo;
  84709. /**
  84710. * Instantiates a new rendering group for a particular scene
  84711. * @param scene Defines the scene the groups belongs to
  84712. */
  84713. constructor(scene: Scene);
  84714. private _clearDepthStencilBuffer;
  84715. /**
  84716. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84717. * @hidden
  84718. */
  84719. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84720. /**
  84721. * Resets the different information of the group to prepare a new frame
  84722. * @hidden
  84723. */
  84724. reset(): void;
  84725. /**
  84726. * Dispose and release the group and its associated resources.
  84727. * @hidden
  84728. */
  84729. dispose(): void;
  84730. /**
  84731. * Clear the info related to rendering groups preventing retention points during dispose.
  84732. */
  84733. freeRenderingGroups(): void;
  84734. private _prepareRenderingGroup;
  84735. /**
  84736. * Add a sprite manager to the rendering manager in order to render it this frame.
  84737. * @param spriteManager Define the sprite manager to render
  84738. */
  84739. dispatchSprites(spriteManager: ISpriteManager): void;
  84740. /**
  84741. * Add a particle system to the rendering manager in order to render it this frame.
  84742. * @param particleSystem Define the particle system to render
  84743. */
  84744. dispatchParticles(particleSystem: IParticleSystem): void;
  84745. /**
  84746. * Add a submesh to the manager in order to render it this frame
  84747. * @param subMesh The submesh to dispatch
  84748. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84749. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84750. */
  84751. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84752. /**
  84753. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84754. * This allowed control for front to back rendering or reversly depending of the special needs.
  84755. *
  84756. * @param renderingGroupId The rendering group id corresponding to its index
  84757. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84758. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84759. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84760. */
  84761. 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;
  84762. /**
  84763. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84764. *
  84765. * @param renderingGroupId The rendering group id corresponding to its index
  84766. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84767. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84768. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84769. */
  84770. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84771. /**
  84772. * Gets the current auto clear configuration for one rendering group of the rendering
  84773. * manager.
  84774. * @param index the rendering group index to get the information for
  84775. * @returns The auto clear setup for the requested rendering group
  84776. */
  84777. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84778. }
  84779. }
  84780. declare module BABYLON {
  84781. /**
  84782. * This Helps creating a texture that will be created from a camera in your scene.
  84783. * It is basically a dynamic texture that could be used to create special effects for instance.
  84784. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84785. */
  84786. export class RenderTargetTexture extends Texture {
  84787. isCube: boolean;
  84788. /**
  84789. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84790. */
  84791. static readonly REFRESHRATE_RENDER_ONCE: number;
  84792. /**
  84793. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84794. */
  84795. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84796. /**
  84797. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84798. * the central point of your effect and can save a lot of performances.
  84799. */
  84800. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84801. /**
  84802. * Use this predicate to dynamically define the list of mesh you want to render.
  84803. * If set, the renderList property will be overwritten.
  84804. */
  84805. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84806. private _renderList;
  84807. /**
  84808. * Use this list to define the list of mesh you want to render.
  84809. */
  84810. renderList: Nullable<Array<AbstractMesh>>;
  84811. private _hookArray;
  84812. /**
  84813. * Define if particles should be rendered in your texture.
  84814. */
  84815. renderParticles: boolean;
  84816. /**
  84817. * Define if sprites should be rendered in your texture.
  84818. */
  84819. renderSprites: boolean;
  84820. /**
  84821. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84822. */
  84823. coordinatesMode: number;
  84824. /**
  84825. * Define the camera used to render the texture.
  84826. */
  84827. activeCamera: Nullable<Camera>;
  84828. /**
  84829. * Override the render function of the texture with your own one.
  84830. */
  84831. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84832. /**
  84833. * Define if camera post processes should be use while rendering the texture.
  84834. */
  84835. useCameraPostProcesses: boolean;
  84836. /**
  84837. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84838. */
  84839. ignoreCameraViewport: boolean;
  84840. private _postProcessManager;
  84841. private _postProcesses;
  84842. private _resizeObserver;
  84843. /**
  84844. * An event triggered when the texture is unbind.
  84845. */
  84846. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84847. /**
  84848. * An event triggered when the texture is unbind.
  84849. */
  84850. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84851. private _onAfterUnbindObserver;
  84852. /**
  84853. * Set a after unbind callback in the texture.
  84854. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84855. */
  84856. onAfterUnbind: () => void;
  84857. /**
  84858. * An event triggered before rendering the texture
  84859. */
  84860. onBeforeRenderObservable: Observable<number>;
  84861. private _onBeforeRenderObserver;
  84862. /**
  84863. * Set a before render callback in the texture.
  84864. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84865. */
  84866. onBeforeRender: (faceIndex: number) => void;
  84867. /**
  84868. * An event triggered after rendering the texture
  84869. */
  84870. onAfterRenderObservable: Observable<number>;
  84871. private _onAfterRenderObserver;
  84872. /**
  84873. * Set a after render callback in the texture.
  84874. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84875. */
  84876. onAfterRender: (faceIndex: number) => void;
  84877. /**
  84878. * An event triggered after the texture clear
  84879. */
  84880. onClearObservable: Observable<Engine>;
  84881. private _onClearObserver;
  84882. /**
  84883. * Set a clear callback in the texture.
  84884. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84885. */
  84886. onClear: (Engine: Engine) => void;
  84887. /**
  84888. * Define the clear color of the Render Target if it should be different from the scene.
  84889. */
  84890. clearColor: Color4;
  84891. protected _size: number | {
  84892. width: number;
  84893. height: number;
  84894. };
  84895. protected _initialSizeParameter: number | {
  84896. width: number;
  84897. height: number;
  84898. } | {
  84899. ratio: number;
  84900. };
  84901. protected _sizeRatio: Nullable<number>;
  84902. /** @hidden */
  84903. _generateMipMaps: boolean;
  84904. protected _renderingManager: RenderingManager;
  84905. /** @hidden */
  84906. _waitingRenderList: string[];
  84907. protected _doNotChangeAspectRatio: boolean;
  84908. protected _currentRefreshId: number;
  84909. protected _refreshRate: number;
  84910. protected _textureMatrix: Matrix;
  84911. protected _samples: number;
  84912. protected _renderTargetOptions: RenderTargetCreationOptions;
  84913. /**
  84914. * Gets render target creation options that were used.
  84915. */
  84916. readonly renderTargetOptions: RenderTargetCreationOptions;
  84917. protected _engine: Engine;
  84918. protected _onRatioRescale(): void;
  84919. /**
  84920. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84921. * It must define where the camera used to render the texture is set
  84922. */
  84923. boundingBoxPosition: Vector3;
  84924. private _boundingBoxSize;
  84925. /**
  84926. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84927. * When defined, the cubemap will switch to local mode
  84928. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84929. * @example https://www.babylonjs-playground.com/#RNASML
  84930. */
  84931. boundingBoxSize: Vector3;
  84932. /**
  84933. * In case the RTT has been created with a depth texture, get the associated
  84934. * depth texture.
  84935. * Otherwise, return null.
  84936. */
  84937. depthStencilTexture: Nullable<InternalTexture>;
  84938. /**
  84939. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84940. * or used a shadow, depth texture...
  84941. * @param name The friendly name of the texture
  84942. * @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)
  84943. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84944. * @param generateMipMaps True if mip maps need to be generated after render.
  84945. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84946. * @param type The type of the buffer in the RTT (int, half float, float...)
  84947. * @param isCube True if a cube texture needs to be created
  84948. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84949. * @param generateDepthBuffer True to generate a depth buffer
  84950. * @param generateStencilBuffer True to generate a stencil buffer
  84951. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84952. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84953. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84954. */
  84955. constructor(name: string, size: number | {
  84956. width: number;
  84957. height: number;
  84958. } | {
  84959. ratio: number;
  84960. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84961. /**
  84962. * Creates a depth stencil texture.
  84963. * This is only available in WebGL 2 or with the depth texture extension available.
  84964. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84965. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84966. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84967. */
  84968. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84969. private _processSizeParameter;
  84970. /**
  84971. * Define the number of samples to use in case of MSAA.
  84972. * It defaults to one meaning no MSAA has been enabled.
  84973. */
  84974. samples: number;
  84975. /**
  84976. * Resets the refresh counter of the texture and start bak from scratch.
  84977. * Could be useful to regenerate the texture if it is setup to render only once.
  84978. */
  84979. resetRefreshCounter(): void;
  84980. /**
  84981. * Define the refresh rate of the texture or the rendering frequency.
  84982. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84983. */
  84984. refreshRate: number;
  84985. /**
  84986. * Adds a post process to the render target rendering passes.
  84987. * @param postProcess define the post process to add
  84988. */
  84989. addPostProcess(postProcess: PostProcess): void;
  84990. /**
  84991. * Clear all the post processes attached to the render target
  84992. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84993. */
  84994. clearPostProcesses(dispose?: boolean): void;
  84995. /**
  84996. * Remove one of the post process from the list of attached post processes to the texture
  84997. * @param postProcess define the post process to remove from the list
  84998. */
  84999. removePostProcess(postProcess: PostProcess): void;
  85000. /** @hidden */
  85001. _shouldRender(): boolean;
  85002. /**
  85003. * Gets the actual render size of the texture.
  85004. * @returns the width of the render size
  85005. */
  85006. getRenderSize(): number;
  85007. /**
  85008. * Gets the actual render width of the texture.
  85009. * @returns the width of the render size
  85010. */
  85011. getRenderWidth(): number;
  85012. /**
  85013. * Gets the actual render height of the texture.
  85014. * @returns the height of the render size
  85015. */
  85016. getRenderHeight(): number;
  85017. /**
  85018. * Get if the texture can be rescaled or not.
  85019. */
  85020. readonly canRescale: boolean;
  85021. /**
  85022. * Resize the texture using a ratio.
  85023. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  85024. */
  85025. scale(ratio: number): void;
  85026. /**
  85027. * Get the texture reflection matrix used to rotate/transform the reflection.
  85028. * @returns the reflection matrix
  85029. */
  85030. getReflectionTextureMatrix(): Matrix;
  85031. /**
  85032. * Resize the texture to a new desired size.
  85033. * Be carrefull as it will recreate all the data in the new texture.
  85034. * @param size Define the new size. It can be:
  85035. * - a number for squared texture,
  85036. * - an object containing { width: number, height: number }
  85037. * - or an object containing a ratio { ratio: number }
  85038. */
  85039. resize(size: number | {
  85040. width: number;
  85041. height: number;
  85042. } | {
  85043. ratio: number;
  85044. }): void;
  85045. /**
  85046. * Renders all the objects from the render list into the texture.
  85047. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  85048. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  85049. */
  85050. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  85051. private _bestReflectionRenderTargetDimension;
  85052. /**
  85053. * @hidden
  85054. * @param faceIndex face index to bind to if this is a cubetexture
  85055. */
  85056. _bindFrameBuffer(faceIndex?: number): void;
  85057. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85058. private renderToTarget;
  85059. /**
  85060. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85061. * This allowed control for front to back rendering or reversly depending of the special needs.
  85062. *
  85063. * @param renderingGroupId The rendering group id corresponding to its index
  85064. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85065. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85066. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85067. */
  85068. 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;
  85069. /**
  85070. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85071. *
  85072. * @param renderingGroupId The rendering group id corresponding to its index
  85073. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85074. */
  85075. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85076. /**
  85077. * Clones the texture.
  85078. * @returns the cloned texture
  85079. */
  85080. clone(): RenderTargetTexture;
  85081. /**
  85082. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85083. * @returns The JSON representation of the texture
  85084. */
  85085. serialize(): any;
  85086. /**
  85087. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85088. */
  85089. disposeFramebufferObjects(): void;
  85090. /**
  85091. * Dispose the texture and release its associated resources.
  85092. */
  85093. dispose(): void;
  85094. /** @hidden */
  85095. _rebuild(): void;
  85096. /**
  85097. * Clear the info related to rendering groups preventing retention point in material dispose.
  85098. */
  85099. freeRenderingGroups(): void;
  85100. /**
  85101. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85102. * @returns the view count
  85103. */
  85104. getViewCount(): number;
  85105. }
  85106. }
  85107. declare module BABYLON {
  85108. /**
  85109. * Base class for the main features of a material in Babylon.js
  85110. */
  85111. export class Material implements IAnimatable {
  85112. /**
  85113. * Returns the triangle fill mode
  85114. */
  85115. static readonly TriangleFillMode: number;
  85116. /**
  85117. * Returns the wireframe mode
  85118. */
  85119. static readonly WireFrameFillMode: number;
  85120. /**
  85121. * Returns the point fill mode
  85122. */
  85123. static readonly PointFillMode: number;
  85124. /**
  85125. * Returns the point list draw mode
  85126. */
  85127. static readonly PointListDrawMode: number;
  85128. /**
  85129. * Returns the line list draw mode
  85130. */
  85131. static readonly LineListDrawMode: number;
  85132. /**
  85133. * Returns the line loop draw mode
  85134. */
  85135. static readonly LineLoopDrawMode: number;
  85136. /**
  85137. * Returns the line strip draw mode
  85138. */
  85139. static readonly LineStripDrawMode: number;
  85140. /**
  85141. * Returns the triangle strip draw mode
  85142. */
  85143. static readonly TriangleStripDrawMode: number;
  85144. /**
  85145. * Returns the triangle fan draw mode
  85146. */
  85147. static readonly TriangleFanDrawMode: number;
  85148. /**
  85149. * Stores the clock-wise side orientation
  85150. */
  85151. static readonly ClockWiseSideOrientation: number;
  85152. /**
  85153. * Stores the counter clock-wise side orientation
  85154. */
  85155. static readonly CounterClockWiseSideOrientation: number;
  85156. /**
  85157. * The dirty texture flag value
  85158. */
  85159. static readonly TextureDirtyFlag: number;
  85160. /**
  85161. * The dirty light flag value
  85162. */
  85163. static readonly LightDirtyFlag: number;
  85164. /**
  85165. * The dirty fresnel flag value
  85166. */
  85167. static readonly FresnelDirtyFlag: number;
  85168. /**
  85169. * The dirty attribute flag value
  85170. */
  85171. static readonly AttributesDirtyFlag: number;
  85172. /**
  85173. * The dirty misc flag value
  85174. */
  85175. static readonly MiscDirtyFlag: number;
  85176. /**
  85177. * The all dirty flag value
  85178. */
  85179. static readonly AllDirtyFlag: number;
  85180. /**
  85181. * The ID of the material
  85182. */
  85183. id: string;
  85184. /**
  85185. * Gets or sets the unique id of the material
  85186. */
  85187. uniqueId: number;
  85188. /**
  85189. * The name of the material
  85190. */
  85191. name: string;
  85192. /**
  85193. * Gets or sets user defined metadata
  85194. */
  85195. metadata: any;
  85196. /**
  85197. * For internal use only. Please do not use.
  85198. */
  85199. reservedDataStore: any;
  85200. /**
  85201. * Specifies if the ready state should be checked on each call
  85202. */
  85203. checkReadyOnEveryCall: boolean;
  85204. /**
  85205. * Specifies if the ready state should be checked once
  85206. */
  85207. checkReadyOnlyOnce: boolean;
  85208. /**
  85209. * The state of the material
  85210. */
  85211. state: string;
  85212. /**
  85213. * The alpha value of the material
  85214. */
  85215. protected _alpha: number;
  85216. /**
  85217. * List of inspectable custom properties (used by the Inspector)
  85218. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85219. */
  85220. inspectableCustomProperties: IInspectable[];
  85221. /**
  85222. * Sets the alpha value of the material
  85223. */
  85224. /**
  85225. * Gets the alpha value of the material
  85226. */
  85227. alpha: number;
  85228. /**
  85229. * Specifies if back face culling is enabled
  85230. */
  85231. protected _backFaceCulling: boolean;
  85232. /**
  85233. * Sets the back-face culling state
  85234. */
  85235. /**
  85236. * Gets the back-face culling state
  85237. */
  85238. backFaceCulling: boolean;
  85239. /**
  85240. * Stores the value for side orientation
  85241. */
  85242. sideOrientation: number;
  85243. /**
  85244. * Callback triggered when the material is compiled
  85245. */
  85246. onCompiled: Nullable<(effect: Effect) => void>;
  85247. /**
  85248. * Callback triggered when an error occurs
  85249. */
  85250. onError: Nullable<(effect: Effect, errors: string) => void>;
  85251. /**
  85252. * Callback triggered to get the render target textures
  85253. */
  85254. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85255. /**
  85256. * Gets a boolean indicating that current material needs to register RTT
  85257. */
  85258. readonly hasRenderTargetTextures: boolean;
  85259. /**
  85260. * Specifies if the material should be serialized
  85261. */
  85262. doNotSerialize: boolean;
  85263. /**
  85264. * @hidden
  85265. */
  85266. _storeEffectOnSubMeshes: boolean;
  85267. /**
  85268. * Stores the animations for the material
  85269. */
  85270. animations: Nullable<Array<Animation>>;
  85271. /**
  85272. * An event triggered when the material is disposed
  85273. */
  85274. onDisposeObservable: Observable<Material>;
  85275. /**
  85276. * An observer which watches for dispose events
  85277. */
  85278. private _onDisposeObserver;
  85279. private _onUnBindObservable;
  85280. /**
  85281. * Called during a dispose event
  85282. */
  85283. onDispose: () => void;
  85284. private _onBindObservable;
  85285. /**
  85286. * An event triggered when the material is bound
  85287. */
  85288. readonly onBindObservable: Observable<AbstractMesh>;
  85289. /**
  85290. * An observer which watches for bind events
  85291. */
  85292. private _onBindObserver;
  85293. /**
  85294. * Called during a bind event
  85295. */
  85296. onBind: (Mesh: AbstractMesh) => void;
  85297. /**
  85298. * An event triggered when the material is unbound
  85299. */
  85300. readonly onUnBindObservable: Observable<Material>;
  85301. /**
  85302. * Stores the value of the alpha mode
  85303. */
  85304. private _alphaMode;
  85305. /**
  85306. * Sets the value of the alpha mode.
  85307. *
  85308. * | Value | Type | Description |
  85309. * | --- | --- | --- |
  85310. * | 0 | ALPHA_DISABLE | |
  85311. * | 1 | ALPHA_ADD | |
  85312. * | 2 | ALPHA_COMBINE | |
  85313. * | 3 | ALPHA_SUBTRACT | |
  85314. * | 4 | ALPHA_MULTIPLY | |
  85315. * | 5 | ALPHA_MAXIMIZED | |
  85316. * | 6 | ALPHA_ONEONE | |
  85317. * | 7 | ALPHA_PREMULTIPLIED | |
  85318. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85319. * | 9 | ALPHA_INTERPOLATE | |
  85320. * | 10 | ALPHA_SCREENMODE | |
  85321. *
  85322. */
  85323. /**
  85324. * Gets the value of the alpha mode
  85325. */
  85326. alphaMode: number;
  85327. /**
  85328. * Stores the state of the need depth pre-pass value
  85329. */
  85330. private _needDepthPrePass;
  85331. /**
  85332. * Sets the need depth pre-pass value
  85333. */
  85334. /**
  85335. * Gets the depth pre-pass value
  85336. */
  85337. needDepthPrePass: boolean;
  85338. /**
  85339. * Specifies if depth writing should be disabled
  85340. */
  85341. disableDepthWrite: boolean;
  85342. /**
  85343. * Specifies if depth writing should be forced
  85344. */
  85345. forceDepthWrite: boolean;
  85346. /**
  85347. * Specifies if there should be a separate pass for culling
  85348. */
  85349. separateCullingPass: boolean;
  85350. /**
  85351. * Stores the state specifing if fog should be enabled
  85352. */
  85353. private _fogEnabled;
  85354. /**
  85355. * Sets the state for enabling fog
  85356. */
  85357. /**
  85358. * Gets the value of the fog enabled state
  85359. */
  85360. fogEnabled: boolean;
  85361. /**
  85362. * Stores the size of points
  85363. */
  85364. pointSize: number;
  85365. /**
  85366. * Stores the z offset value
  85367. */
  85368. zOffset: number;
  85369. /**
  85370. * Gets a value specifying if wireframe mode is enabled
  85371. */
  85372. /**
  85373. * Sets the state of wireframe mode
  85374. */
  85375. wireframe: boolean;
  85376. /**
  85377. * Gets the value specifying if point clouds are enabled
  85378. */
  85379. /**
  85380. * Sets the state of point cloud mode
  85381. */
  85382. pointsCloud: boolean;
  85383. /**
  85384. * Gets the material fill mode
  85385. */
  85386. /**
  85387. * Sets the material fill mode
  85388. */
  85389. fillMode: number;
  85390. /**
  85391. * @hidden
  85392. * Stores the effects for the material
  85393. */
  85394. _effect: Nullable<Effect>;
  85395. /**
  85396. * @hidden
  85397. * Specifies if the material was previously ready
  85398. */
  85399. _wasPreviouslyReady: boolean;
  85400. /**
  85401. * Specifies if uniform buffers should be used
  85402. */
  85403. private _useUBO;
  85404. /**
  85405. * Stores a reference to the scene
  85406. */
  85407. private _scene;
  85408. /**
  85409. * Stores the fill mode state
  85410. */
  85411. private _fillMode;
  85412. /**
  85413. * Specifies if the depth write state should be cached
  85414. */
  85415. private _cachedDepthWriteState;
  85416. /**
  85417. * Stores the uniform buffer
  85418. */
  85419. protected _uniformBuffer: UniformBuffer;
  85420. /** @hidden */
  85421. _indexInSceneMaterialArray: number;
  85422. /** @hidden */
  85423. meshMap: Nullable<{
  85424. [id: string]: AbstractMesh | undefined;
  85425. }>;
  85426. /**
  85427. * Creates a material instance
  85428. * @param name defines the name of the material
  85429. * @param scene defines the scene to reference
  85430. * @param doNotAdd specifies if the material should be added to the scene
  85431. */
  85432. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85433. /**
  85434. * Returns a string representation of the current material
  85435. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85436. * @returns a string with material information
  85437. */
  85438. toString(fullDetails?: boolean): string;
  85439. /**
  85440. * Gets the class name of the material
  85441. * @returns a string with the class name of the material
  85442. */
  85443. getClassName(): string;
  85444. /**
  85445. * Specifies if updates for the material been locked
  85446. */
  85447. readonly isFrozen: boolean;
  85448. /**
  85449. * Locks updates for the material
  85450. */
  85451. freeze(): void;
  85452. /**
  85453. * Unlocks updates for the material
  85454. */
  85455. unfreeze(): void;
  85456. /**
  85457. * Specifies if the material is ready to be used
  85458. * @param mesh defines the mesh to check
  85459. * @param useInstances specifies if instances should be used
  85460. * @returns a boolean indicating if the material is ready to be used
  85461. */
  85462. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85463. /**
  85464. * Specifies that the submesh is ready to be used
  85465. * @param mesh defines the mesh to check
  85466. * @param subMesh defines which submesh to check
  85467. * @param useInstances specifies that instances should be used
  85468. * @returns a boolean indicating that the submesh is ready or not
  85469. */
  85470. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85471. /**
  85472. * Returns the material effect
  85473. * @returns the effect associated with the material
  85474. */
  85475. getEffect(): Nullable<Effect>;
  85476. /**
  85477. * Returns the current scene
  85478. * @returns a Scene
  85479. */
  85480. getScene(): Scene;
  85481. /**
  85482. * Specifies if the material will require alpha blending
  85483. * @returns a boolean specifying if alpha blending is needed
  85484. */
  85485. needAlphaBlending(): boolean;
  85486. /**
  85487. * Specifies if the mesh will require alpha blending
  85488. * @param mesh defines the mesh to check
  85489. * @returns a boolean specifying if alpha blending is needed for the mesh
  85490. */
  85491. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85492. /**
  85493. * Specifies if this material should be rendered in alpha test mode
  85494. * @returns a boolean specifying if an alpha test is needed.
  85495. */
  85496. needAlphaTesting(): boolean;
  85497. /**
  85498. * Gets the texture used for the alpha test
  85499. * @returns the texture to use for alpha testing
  85500. */
  85501. getAlphaTestTexture(): Nullable<BaseTexture>;
  85502. /**
  85503. * Marks the material to indicate that it needs to be re-calculated
  85504. */
  85505. markDirty(): void;
  85506. /** @hidden */
  85507. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85508. /**
  85509. * Binds the material to the mesh
  85510. * @param world defines the world transformation matrix
  85511. * @param mesh defines the mesh to bind the material to
  85512. */
  85513. bind(world: Matrix, mesh?: Mesh): void;
  85514. /**
  85515. * Binds the submesh to the material
  85516. * @param world defines the world transformation matrix
  85517. * @param mesh defines the mesh containing the submesh
  85518. * @param subMesh defines the submesh to bind the material to
  85519. */
  85520. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85521. /**
  85522. * Binds the world matrix to the material
  85523. * @param world defines the world transformation matrix
  85524. */
  85525. bindOnlyWorldMatrix(world: Matrix): void;
  85526. /**
  85527. * Binds the scene's uniform buffer to the effect.
  85528. * @param effect defines the effect to bind to the scene uniform buffer
  85529. * @param sceneUbo defines the uniform buffer storing scene data
  85530. */
  85531. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85532. /**
  85533. * Binds the view matrix to the effect
  85534. * @param effect defines the effect to bind the view matrix to
  85535. */
  85536. bindView(effect: Effect): void;
  85537. /**
  85538. * Binds the view projection matrix to the effect
  85539. * @param effect defines the effect to bind the view projection matrix to
  85540. */
  85541. bindViewProjection(effect: Effect): void;
  85542. /**
  85543. * Specifies if material alpha testing should be turned on for the mesh
  85544. * @param mesh defines the mesh to check
  85545. */
  85546. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85547. /**
  85548. * Processes to execute after binding the material to a mesh
  85549. * @param mesh defines the rendered mesh
  85550. */
  85551. protected _afterBind(mesh?: Mesh): void;
  85552. /**
  85553. * Unbinds the material from the mesh
  85554. */
  85555. unbind(): void;
  85556. /**
  85557. * Gets the active textures from the material
  85558. * @returns an array of textures
  85559. */
  85560. getActiveTextures(): BaseTexture[];
  85561. /**
  85562. * Specifies if the material uses a texture
  85563. * @param texture defines the texture to check against the material
  85564. * @returns a boolean specifying if the material uses the texture
  85565. */
  85566. hasTexture(texture: BaseTexture): boolean;
  85567. /**
  85568. * Makes a duplicate of the material, and gives it a new name
  85569. * @param name defines the new name for the duplicated material
  85570. * @returns the cloned material
  85571. */
  85572. clone(name: string): Nullable<Material>;
  85573. /**
  85574. * Gets the meshes bound to the material
  85575. * @returns an array of meshes bound to the material
  85576. */
  85577. getBindedMeshes(): AbstractMesh[];
  85578. /**
  85579. * Force shader compilation
  85580. * @param mesh defines the mesh associated with this material
  85581. * @param onCompiled defines a function to execute once the material is compiled
  85582. * @param options defines the options to configure the compilation
  85583. */
  85584. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85585. clipPlane: boolean;
  85586. }>): void;
  85587. /**
  85588. * Force shader compilation
  85589. * @param mesh defines the mesh that will use this material
  85590. * @param options defines additional options for compiling the shaders
  85591. * @returns a promise that resolves when the compilation completes
  85592. */
  85593. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85594. clipPlane: boolean;
  85595. }>): Promise<void>;
  85596. private static readonly _AllDirtyCallBack;
  85597. private static readonly _ImageProcessingDirtyCallBack;
  85598. private static readonly _TextureDirtyCallBack;
  85599. private static readonly _FresnelDirtyCallBack;
  85600. private static readonly _MiscDirtyCallBack;
  85601. private static readonly _LightsDirtyCallBack;
  85602. private static readonly _AttributeDirtyCallBack;
  85603. private static _FresnelAndMiscDirtyCallBack;
  85604. private static _TextureAndMiscDirtyCallBack;
  85605. private static readonly _DirtyCallbackArray;
  85606. private static readonly _RunDirtyCallBacks;
  85607. /**
  85608. * Marks a define in the material to indicate that it needs to be re-computed
  85609. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85610. */
  85611. markAsDirty(flag: number): void;
  85612. /**
  85613. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85614. * @param func defines a function which checks material defines against the submeshes
  85615. */
  85616. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85617. /**
  85618. * Indicates that we need to re-calculated for all submeshes
  85619. */
  85620. protected _markAllSubMeshesAsAllDirty(): void;
  85621. /**
  85622. * Indicates that image processing needs to be re-calculated for all submeshes
  85623. */
  85624. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85625. /**
  85626. * Indicates that textures need to be re-calculated for all submeshes
  85627. */
  85628. protected _markAllSubMeshesAsTexturesDirty(): void;
  85629. /**
  85630. * Indicates that fresnel needs to be re-calculated for all submeshes
  85631. */
  85632. protected _markAllSubMeshesAsFresnelDirty(): void;
  85633. /**
  85634. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85635. */
  85636. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85637. /**
  85638. * Indicates that lights need to be re-calculated for all submeshes
  85639. */
  85640. protected _markAllSubMeshesAsLightsDirty(): void;
  85641. /**
  85642. * Indicates that attributes need to be re-calculated for all submeshes
  85643. */
  85644. protected _markAllSubMeshesAsAttributesDirty(): void;
  85645. /**
  85646. * Indicates that misc needs to be re-calculated for all submeshes
  85647. */
  85648. protected _markAllSubMeshesAsMiscDirty(): void;
  85649. /**
  85650. * Indicates that textures and misc need to be re-calculated for all submeshes
  85651. */
  85652. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85653. /**
  85654. * Disposes the material
  85655. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85656. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85657. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85658. */
  85659. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85660. /** @hidden */
  85661. private releaseVertexArrayObject;
  85662. /**
  85663. * Serializes this material
  85664. * @returns the serialized material object
  85665. */
  85666. serialize(): any;
  85667. /**
  85668. * Creates a material from parsed material data
  85669. * @param parsedMaterial defines parsed material data
  85670. * @param scene defines the hosting scene
  85671. * @param rootUrl defines the root URL to use to load textures
  85672. * @returns a new material
  85673. */
  85674. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85675. }
  85676. }
  85677. declare module BABYLON {
  85678. /**
  85679. * Base class for submeshes
  85680. */
  85681. export class BaseSubMesh {
  85682. /** @hidden */
  85683. _materialDefines: Nullable<MaterialDefines>;
  85684. /** @hidden */
  85685. _materialEffect: Nullable<Effect>;
  85686. /**
  85687. * Gets associated effect
  85688. */
  85689. readonly effect: Nullable<Effect>;
  85690. /**
  85691. * Sets associated effect (effect used to render this submesh)
  85692. * @param effect defines the effect to associate with
  85693. * @param defines defines the set of defines used to compile this effect
  85694. */
  85695. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85696. }
  85697. /**
  85698. * Defines a subdivision inside a mesh
  85699. */
  85700. export class SubMesh extends BaseSubMesh implements ICullable {
  85701. /** the material index to use */
  85702. materialIndex: number;
  85703. /** vertex index start */
  85704. verticesStart: number;
  85705. /** vertices count */
  85706. verticesCount: number;
  85707. /** index start */
  85708. indexStart: number;
  85709. /** indices count */
  85710. indexCount: number;
  85711. /** @hidden */
  85712. _linesIndexCount: number;
  85713. private _mesh;
  85714. private _renderingMesh;
  85715. private _boundingInfo;
  85716. private _linesIndexBuffer;
  85717. /** @hidden */
  85718. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85719. /** @hidden */
  85720. _trianglePlanes: Plane[];
  85721. /** @hidden */
  85722. _lastColliderTransformMatrix: Nullable<Matrix>;
  85723. /** @hidden */
  85724. _renderId: number;
  85725. /** @hidden */
  85726. _alphaIndex: number;
  85727. /** @hidden */
  85728. _distanceToCamera: number;
  85729. /** @hidden */
  85730. _id: number;
  85731. private _currentMaterial;
  85732. /**
  85733. * Add a new submesh to a mesh
  85734. * @param materialIndex defines the material index to use
  85735. * @param verticesStart defines vertex index start
  85736. * @param verticesCount defines vertices count
  85737. * @param indexStart defines index start
  85738. * @param indexCount defines indices count
  85739. * @param mesh defines the parent mesh
  85740. * @param renderingMesh defines an optional rendering mesh
  85741. * @param createBoundingBox defines if bounding box should be created for this submesh
  85742. * @returns the new submesh
  85743. */
  85744. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85745. /**
  85746. * Creates a new submesh
  85747. * @param materialIndex defines the material index to use
  85748. * @param verticesStart defines vertex index start
  85749. * @param verticesCount defines vertices count
  85750. * @param indexStart defines index start
  85751. * @param indexCount defines indices count
  85752. * @param mesh defines the parent mesh
  85753. * @param renderingMesh defines an optional rendering mesh
  85754. * @param createBoundingBox defines if bounding box should be created for this submesh
  85755. */
  85756. constructor(
  85757. /** the material index to use */
  85758. materialIndex: number,
  85759. /** vertex index start */
  85760. verticesStart: number,
  85761. /** vertices count */
  85762. verticesCount: number,
  85763. /** index start */
  85764. indexStart: number,
  85765. /** indices count */
  85766. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85767. /**
  85768. * Returns true if this submesh covers the entire parent mesh
  85769. * @ignorenaming
  85770. */
  85771. readonly IsGlobal: boolean;
  85772. /**
  85773. * Returns the submesh BoudingInfo object
  85774. * @returns current bounding info (or mesh's one if the submesh is global)
  85775. */
  85776. getBoundingInfo(): BoundingInfo;
  85777. /**
  85778. * Sets the submesh BoundingInfo
  85779. * @param boundingInfo defines the new bounding info to use
  85780. * @returns the SubMesh
  85781. */
  85782. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85783. /**
  85784. * Returns the mesh of the current submesh
  85785. * @return the parent mesh
  85786. */
  85787. getMesh(): AbstractMesh;
  85788. /**
  85789. * Returns the rendering mesh of the submesh
  85790. * @returns the rendering mesh (could be different from parent mesh)
  85791. */
  85792. getRenderingMesh(): Mesh;
  85793. /**
  85794. * Returns the submesh material
  85795. * @returns null or the current material
  85796. */
  85797. getMaterial(): Nullable<Material>;
  85798. /**
  85799. * Sets a new updated BoundingInfo object to the submesh
  85800. * @param data defines an optional position array to use to determine the bounding info
  85801. * @returns the SubMesh
  85802. */
  85803. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85804. /** @hidden */
  85805. _checkCollision(collider: Collider): boolean;
  85806. /**
  85807. * Updates the submesh BoundingInfo
  85808. * @param world defines the world matrix to use to update the bounding info
  85809. * @returns the submesh
  85810. */
  85811. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85812. /**
  85813. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85814. * @param frustumPlanes defines the frustum planes
  85815. * @returns true if the submesh is intersecting with the frustum
  85816. */
  85817. isInFrustum(frustumPlanes: Plane[]): boolean;
  85818. /**
  85819. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85820. * @param frustumPlanes defines the frustum planes
  85821. * @returns true if the submesh is inside the frustum
  85822. */
  85823. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85824. /**
  85825. * Renders the submesh
  85826. * @param enableAlphaMode defines if alpha needs to be used
  85827. * @returns the submesh
  85828. */
  85829. render(enableAlphaMode: boolean): SubMesh;
  85830. /**
  85831. * @hidden
  85832. */
  85833. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85834. /**
  85835. * Checks if the submesh intersects with a ray
  85836. * @param ray defines the ray to test
  85837. * @returns true is the passed ray intersects the submesh bounding box
  85838. */
  85839. canIntersects(ray: Ray): boolean;
  85840. /**
  85841. * Intersects current submesh with a ray
  85842. * @param ray defines the ray to test
  85843. * @param positions defines mesh's positions array
  85844. * @param indices defines mesh's indices array
  85845. * @param fastCheck defines if only bounding info should be used
  85846. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85847. * @returns intersection info or null if no intersection
  85848. */
  85849. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85850. /** @hidden */
  85851. private _intersectLines;
  85852. /** @hidden */
  85853. private _intersectUnIndexedLines;
  85854. /** @hidden */
  85855. private _intersectTriangles;
  85856. /** @hidden */
  85857. private _intersectUnIndexedTriangles;
  85858. /** @hidden */
  85859. _rebuild(): void;
  85860. /**
  85861. * Creates a new submesh from the passed mesh
  85862. * @param newMesh defines the new hosting mesh
  85863. * @param newRenderingMesh defines an optional rendering mesh
  85864. * @returns the new submesh
  85865. */
  85866. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85867. /**
  85868. * Release associated resources
  85869. */
  85870. dispose(): void;
  85871. /**
  85872. * Gets the class name
  85873. * @returns the string "SubMesh".
  85874. */
  85875. getClassName(): string;
  85876. /**
  85877. * Creates a new submesh from indices data
  85878. * @param materialIndex the index of the main mesh material
  85879. * @param startIndex the index where to start the copy in the mesh indices array
  85880. * @param indexCount the number of indices to copy then from the startIndex
  85881. * @param mesh the main mesh to create the submesh from
  85882. * @param renderingMesh the optional rendering mesh
  85883. * @returns a new submesh
  85884. */
  85885. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85886. }
  85887. }
  85888. declare module BABYLON {
  85889. /**
  85890. * Class used to store geometry data (vertex buffers + index buffer)
  85891. */
  85892. export class Geometry implements IGetSetVerticesData {
  85893. /**
  85894. * Gets or sets the ID of the geometry
  85895. */
  85896. id: string;
  85897. /**
  85898. * Gets or sets the unique ID of the geometry
  85899. */
  85900. uniqueId: number;
  85901. /**
  85902. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85903. */
  85904. delayLoadState: number;
  85905. /**
  85906. * Gets the file containing the data to load when running in delay load state
  85907. */
  85908. delayLoadingFile: Nullable<string>;
  85909. /**
  85910. * Callback called when the geometry is updated
  85911. */
  85912. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85913. private _scene;
  85914. private _engine;
  85915. private _meshes;
  85916. private _totalVertices;
  85917. /** @hidden */
  85918. _indices: IndicesArray;
  85919. /** @hidden */
  85920. _vertexBuffers: {
  85921. [key: string]: VertexBuffer;
  85922. };
  85923. private _isDisposed;
  85924. private _extend;
  85925. private _boundingBias;
  85926. /** @hidden */
  85927. _delayInfo: Array<string>;
  85928. private _indexBuffer;
  85929. private _indexBufferIsUpdatable;
  85930. /** @hidden */
  85931. _boundingInfo: Nullable<BoundingInfo>;
  85932. /** @hidden */
  85933. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85934. /** @hidden */
  85935. _softwareSkinningFrameId: number;
  85936. private _vertexArrayObjects;
  85937. private _updatable;
  85938. /** @hidden */
  85939. _positions: Nullable<Vector3[]>;
  85940. /**
  85941. * 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
  85942. */
  85943. /**
  85944. * 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
  85945. */
  85946. boundingBias: Vector2;
  85947. /**
  85948. * Static function used to attach a new empty geometry to a mesh
  85949. * @param mesh defines the mesh to attach the geometry to
  85950. * @returns the new Geometry
  85951. */
  85952. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85953. /**
  85954. * Creates a new geometry
  85955. * @param id defines the unique ID
  85956. * @param scene defines the hosting scene
  85957. * @param vertexData defines the VertexData used to get geometry data
  85958. * @param updatable defines if geometry must be updatable (false by default)
  85959. * @param mesh defines the mesh that will be associated with the geometry
  85960. */
  85961. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85962. /**
  85963. * Gets the current extend of the geometry
  85964. */
  85965. readonly extend: {
  85966. minimum: Vector3;
  85967. maximum: Vector3;
  85968. };
  85969. /**
  85970. * Gets the hosting scene
  85971. * @returns the hosting Scene
  85972. */
  85973. getScene(): Scene;
  85974. /**
  85975. * Gets the hosting engine
  85976. * @returns the hosting Engine
  85977. */
  85978. getEngine(): Engine;
  85979. /**
  85980. * Defines if the geometry is ready to use
  85981. * @returns true if the geometry is ready to be used
  85982. */
  85983. isReady(): boolean;
  85984. /**
  85985. * Gets a value indicating that the geometry should not be serialized
  85986. */
  85987. readonly doNotSerialize: boolean;
  85988. /** @hidden */
  85989. _rebuild(): void;
  85990. /**
  85991. * Affects all geometry data in one call
  85992. * @param vertexData defines the geometry data
  85993. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85994. */
  85995. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85996. /**
  85997. * Set specific vertex data
  85998. * @param kind defines the data kind (Position, normal, etc...)
  85999. * @param data defines the vertex data to use
  86000. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86001. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86002. */
  86003. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  86004. /**
  86005. * Removes a specific vertex data
  86006. * @param kind defines the data kind (Position, normal, etc...)
  86007. */
  86008. removeVerticesData(kind: string): void;
  86009. /**
  86010. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  86011. * @param buffer defines the vertex buffer to use
  86012. * @param totalVertices defines the total number of vertices for position kind (could be null)
  86013. */
  86014. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  86015. /**
  86016. * Update a specific vertex buffer
  86017. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86018. * It will do nothing if the buffer is not updatable
  86019. * @param kind defines the data kind (Position, normal, etc...)
  86020. * @param data defines the data to use
  86021. * @param offset defines the offset in the target buffer where to store the data
  86022. * @param useBytes set to true if the offset is in bytes
  86023. */
  86024. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86025. /**
  86026. * Update a specific vertex buffer
  86027. * This function will create a new buffer if the current one is not updatable
  86028. * @param kind defines the data kind (Position, normal, etc...)
  86029. * @param data defines the data to use
  86030. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86031. */
  86032. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86033. private _updateBoundingInfo;
  86034. /** @hidden */
  86035. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86036. /**
  86037. * Gets total number of vertices
  86038. * @returns the total number of vertices
  86039. */
  86040. getTotalVertices(): number;
  86041. /**
  86042. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86043. * @param kind defines the data kind (Position, normal, etc...)
  86044. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86045. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86046. * @returns a float array containing vertex data
  86047. */
  86048. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86049. /**
  86050. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  86051. * @param kind defines the data kind (Position, normal, etc...)
  86052. * @returns true if the vertex buffer with the specified kind is updatable
  86053. */
  86054. isVertexBufferUpdatable(kind: string): boolean;
  86055. /**
  86056. * Gets a specific vertex buffer
  86057. * @param kind defines the data kind (Position, normal, etc...)
  86058. * @returns a VertexBuffer
  86059. */
  86060. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  86061. /**
  86062. * Returns all vertex buffers
  86063. * @return an object holding all vertex buffers indexed by kind
  86064. */
  86065. getVertexBuffers(): Nullable<{
  86066. [key: string]: VertexBuffer;
  86067. }>;
  86068. /**
  86069. * Gets a boolean indicating if specific vertex buffer is present
  86070. * @param kind defines the data kind (Position, normal, etc...)
  86071. * @returns true if data is present
  86072. */
  86073. isVerticesDataPresent(kind: string): boolean;
  86074. /**
  86075. * Gets a list of all attached data kinds (Position, normal, etc...)
  86076. * @returns a list of string containing all kinds
  86077. */
  86078. getVerticesDataKinds(): string[];
  86079. /**
  86080. * Update index buffer
  86081. * @param indices defines the indices to store in the index buffer
  86082. * @param offset defines the offset in the target buffer where to store the data
  86083. * @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)
  86084. */
  86085. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86086. /**
  86087. * Creates a new index buffer
  86088. * @param indices defines the indices to store in the index buffer
  86089. * @param totalVertices defines the total number of vertices (could be null)
  86090. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86091. */
  86092. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86093. /**
  86094. * Return the total number of indices
  86095. * @returns the total number of indices
  86096. */
  86097. getTotalIndices(): number;
  86098. /**
  86099. * Gets the index buffer array
  86100. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86101. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86102. * @returns the index buffer array
  86103. */
  86104. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86105. /**
  86106. * Gets the index buffer
  86107. * @return the index buffer
  86108. */
  86109. getIndexBuffer(): Nullable<DataBuffer>;
  86110. /** @hidden */
  86111. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86112. /**
  86113. * Release the associated resources for a specific mesh
  86114. * @param mesh defines the source mesh
  86115. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86116. */
  86117. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86118. /**
  86119. * Apply current geometry to a given mesh
  86120. * @param mesh defines the mesh to apply geometry to
  86121. */
  86122. applyToMesh(mesh: Mesh): void;
  86123. private _updateExtend;
  86124. private _applyToMesh;
  86125. private notifyUpdate;
  86126. /**
  86127. * Load the geometry if it was flagged as delay loaded
  86128. * @param scene defines the hosting scene
  86129. * @param onLoaded defines a callback called when the geometry is loaded
  86130. */
  86131. load(scene: Scene, onLoaded?: () => void): void;
  86132. private _queueLoad;
  86133. /**
  86134. * Invert the geometry to move from a right handed system to a left handed one.
  86135. */
  86136. toLeftHanded(): void;
  86137. /** @hidden */
  86138. _resetPointsArrayCache(): void;
  86139. /** @hidden */
  86140. _generatePointsArray(): boolean;
  86141. /**
  86142. * Gets a value indicating if the geometry is disposed
  86143. * @returns true if the geometry was disposed
  86144. */
  86145. isDisposed(): boolean;
  86146. private _disposeVertexArrayObjects;
  86147. /**
  86148. * Free all associated resources
  86149. */
  86150. dispose(): void;
  86151. /**
  86152. * Clone the current geometry into a new geometry
  86153. * @param id defines the unique ID of the new geometry
  86154. * @returns a new geometry object
  86155. */
  86156. copy(id: string): Geometry;
  86157. /**
  86158. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86159. * @return a JSON representation of the current geometry data (without the vertices data)
  86160. */
  86161. serialize(): any;
  86162. private toNumberArray;
  86163. /**
  86164. * Serialize all vertices data into a JSON oject
  86165. * @returns a JSON representation of the current geometry data
  86166. */
  86167. serializeVerticeData(): any;
  86168. /**
  86169. * Extracts a clone of a mesh geometry
  86170. * @param mesh defines the source mesh
  86171. * @param id defines the unique ID of the new geometry object
  86172. * @returns the new geometry object
  86173. */
  86174. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86175. /**
  86176. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86177. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86178. * Be aware Math.random() could cause collisions, but:
  86179. * "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"
  86180. * @returns a string containing a new GUID
  86181. */
  86182. static RandomId(): string;
  86183. /** @hidden */
  86184. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86185. private static _CleanMatricesWeights;
  86186. /**
  86187. * Create a new geometry from persisted data (Using .babylon file format)
  86188. * @param parsedVertexData defines the persisted data
  86189. * @param scene defines the hosting scene
  86190. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86191. * @returns the new geometry object
  86192. */
  86193. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  86194. }
  86195. }
  86196. declare module BABYLON {
  86197. /**
  86198. * Define an interface for all classes that will get and set the data on vertices
  86199. */
  86200. export interface IGetSetVerticesData {
  86201. /**
  86202. * Gets a boolean indicating if specific vertex data is present
  86203. * @param kind defines the vertex data kind to use
  86204. * @returns true is data kind is present
  86205. */
  86206. isVerticesDataPresent(kind: string): boolean;
  86207. /**
  86208. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86209. * @param kind defines the data kind (Position, normal, etc...)
  86210. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86211. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86212. * @returns a float array containing vertex data
  86213. */
  86214. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86215. /**
  86216. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86217. * @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.
  86218. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86219. * @returns the indices array or an empty array if the mesh has no geometry
  86220. */
  86221. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86222. /**
  86223. * Set specific vertex data
  86224. * @param kind defines the data kind (Position, normal, etc...)
  86225. * @param data defines the vertex data to use
  86226. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86227. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86228. */
  86229. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  86230. /**
  86231. * Update a specific associated vertex buffer
  86232. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86233. * - VertexBuffer.PositionKind
  86234. * - VertexBuffer.UVKind
  86235. * - VertexBuffer.UV2Kind
  86236. * - VertexBuffer.UV3Kind
  86237. * - VertexBuffer.UV4Kind
  86238. * - VertexBuffer.UV5Kind
  86239. * - VertexBuffer.UV6Kind
  86240. * - VertexBuffer.ColorKind
  86241. * - VertexBuffer.MatricesIndicesKind
  86242. * - VertexBuffer.MatricesIndicesExtraKind
  86243. * - VertexBuffer.MatricesWeightsKind
  86244. * - VertexBuffer.MatricesWeightsExtraKind
  86245. * @param data defines the data source
  86246. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86247. * @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)
  86248. */
  86249. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  86250. /**
  86251. * Creates a new index buffer
  86252. * @param indices defines the indices to store in the index buffer
  86253. * @param totalVertices defines the total number of vertices (could be null)
  86254. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86255. */
  86256. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  86257. }
  86258. /**
  86259. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86260. */
  86261. export class VertexData {
  86262. /**
  86263. * Mesh side orientation : usually the external or front surface
  86264. */
  86265. static readonly FRONTSIDE: number;
  86266. /**
  86267. * Mesh side orientation : usually the internal or back surface
  86268. */
  86269. static readonly BACKSIDE: number;
  86270. /**
  86271. * Mesh side orientation : both internal and external or front and back surfaces
  86272. */
  86273. static readonly DOUBLESIDE: number;
  86274. /**
  86275. * Mesh side orientation : by default, `FRONTSIDE`
  86276. */
  86277. static readonly DEFAULTSIDE: number;
  86278. /**
  86279. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  86280. */
  86281. positions: Nullable<FloatArray>;
  86282. /**
  86283. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  86284. */
  86285. normals: Nullable<FloatArray>;
  86286. /**
  86287. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  86288. */
  86289. tangents: Nullable<FloatArray>;
  86290. /**
  86291. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86292. */
  86293. uvs: Nullable<FloatArray>;
  86294. /**
  86295. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86296. */
  86297. uvs2: Nullable<FloatArray>;
  86298. /**
  86299. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86300. */
  86301. uvs3: Nullable<FloatArray>;
  86302. /**
  86303. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86304. */
  86305. uvs4: Nullable<FloatArray>;
  86306. /**
  86307. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86308. */
  86309. uvs5: Nullable<FloatArray>;
  86310. /**
  86311. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86312. */
  86313. uvs6: Nullable<FloatArray>;
  86314. /**
  86315. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  86316. */
  86317. colors: Nullable<FloatArray>;
  86318. /**
  86319. * 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).
  86320. */
  86321. matricesIndices: Nullable<FloatArray>;
  86322. /**
  86323. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  86324. */
  86325. matricesWeights: Nullable<FloatArray>;
  86326. /**
  86327. * An array extending the number of possible indices
  86328. */
  86329. matricesIndicesExtra: Nullable<FloatArray>;
  86330. /**
  86331. * An array extending the number of possible weights when the number of indices is extended
  86332. */
  86333. matricesWeightsExtra: Nullable<FloatArray>;
  86334. /**
  86335. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  86336. */
  86337. indices: Nullable<IndicesArray>;
  86338. /**
  86339. * Uses the passed data array to set the set the values for the specified kind of data
  86340. * @param data a linear array of floating numbers
  86341. * @param kind the type of data that is being set, eg positions, colors etc
  86342. */
  86343. set(data: FloatArray, kind: string): void;
  86344. /**
  86345. * Associates the vertexData to the passed Mesh.
  86346. * Sets it as updatable or not (default `false`)
  86347. * @param mesh the mesh the vertexData is applied to
  86348. * @param updatable when used and having the value true allows new data to update the vertexData
  86349. * @returns the VertexData
  86350. */
  86351. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  86352. /**
  86353. * Associates the vertexData to the passed Geometry.
  86354. * Sets it as updatable or not (default `false`)
  86355. * @param geometry the geometry the vertexData is applied to
  86356. * @param updatable when used and having the value true allows new data to update the vertexData
  86357. * @returns VertexData
  86358. */
  86359. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  86360. /**
  86361. * Updates the associated mesh
  86362. * @param mesh the mesh to be updated
  86363. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86364. * @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
  86365. * @returns VertexData
  86366. */
  86367. updateMesh(mesh: Mesh): VertexData;
  86368. /**
  86369. * Updates the associated geometry
  86370. * @param geometry the geometry to be updated
  86371. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86372. * @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
  86373. * @returns VertexData.
  86374. */
  86375. updateGeometry(geometry: Geometry): VertexData;
  86376. private _applyTo;
  86377. private _update;
  86378. /**
  86379. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86380. * @param matrix the transforming matrix
  86381. * @returns the VertexData
  86382. */
  86383. transform(matrix: Matrix): VertexData;
  86384. /**
  86385. * Merges the passed VertexData into the current one
  86386. * @param other the VertexData to be merged into the current one
  86387. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86388. * @returns the modified VertexData
  86389. */
  86390. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  86391. private _mergeElement;
  86392. private _validate;
  86393. /**
  86394. * Serializes the VertexData
  86395. * @returns a serialized object
  86396. */
  86397. serialize(): any;
  86398. /**
  86399. * Extracts the vertexData from a mesh
  86400. * @param mesh the mesh from which to extract the VertexData
  86401. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86402. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86403. * @returns the object VertexData associated to the passed mesh
  86404. */
  86405. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86406. /**
  86407. * Extracts the vertexData from the geometry
  86408. * @param geometry the geometry from which to extract the VertexData
  86409. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86410. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86411. * @returns the object VertexData associated to the passed mesh
  86412. */
  86413. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86414. private static _ExtractFrom;
  86415. /**
  86416. * Creates the VertexData for a Ribbon
  86417. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86418. * * pathArray array of paths, each of which an array of successive Vector3
  86419. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86420. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86421. * * 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
  86422. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86423. * * 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)
  86424. * * 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)
  86425. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86426. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86427. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86428. * @returns the VertexData of the ribbon
  86429. */
  86430. static CreateRibbon(options: {
  86431. pathArray: Vector3[][];
  86432. closeArray?: boolean;
  86433. closePath?: boolean;
  86434. offset?: number;
  86435. sideOrientation?: number;
  86436. frontUVs?: Vector4;
  86437. backUVs?: Vector4;
  86438. invertUV?: boolean;
  86439. uvs?: Vector2[];
  86440. colors?: Color4[];
  86441. }): VertexData;
  86442. /**
  86443. * Creates the VertexData for a box
  86444. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86445. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86446. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86447. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86448. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86449. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86450. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86451. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86452. * * 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)
  86453. * * 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)
  86454. * @returns the VertexData of the box
  86455. */
  86456. static CreateBox(options: {
  86457. size?: number;
  86458. width?: number;
  86459. height?: number;
  86460. depth?: number;
  86461. faceUV?: Vector4[];
  86462. faceColors?: Color4[];
  86463. sideOrientation?: number;
  86464. frontUVs?: Vector4;
  86465. backUVs?: Vector4;
  86466. }): VertexData;
  86467. /**
  86468. * Creates the VertexData for a tiled box
  86469. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86470. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86471. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86472. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86473. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86474. * @returns the VertexData of the box
  86475. */
  86476. static CreateTiledBox(options: {
  86477. pattern?: number;
  86478. width?: number;
  86479. height?: number;
  86480. depth?: number;
  86481. tileSize?: number;
  86482. tileWidth?: number;
  86483. tileHeight?: number;
  86484. alignHorizontal?: number;
  86485. alignVertical?: number;
  86486. faceUV?: Vector4[];
  86487. faceColors?: Color4[];
  86488. sideOrientation?: number;
  86489. }): VertexData;
  86490. /**
  86491. * Creates the VertexData for a tiled plane
  86492. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86493. * * pattern a limited pattern arrangement depending on the number
  86494. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86495. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86496. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86498. * * 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)
  86499. * * 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)
  86500. * @returns the VertexData of the tiled plane
  86501. */
  86502. static CreateTiledPlane(options: {
  86503. pattern?: number;
  86504. tileSize?: number;
  86505. tileWidth?: number;
  86506. tileHeight?: number;
  86507. size?: number;
  86508. width?: number;
  86509. height?: number;
  86510. alignHorizontal?: number;
  86511. alignVertical?: number;
  86512. sideOrientation?: number;
  86513. frontUVs?: Vector4;
  86514. backUVs?: Vector4;
  86515. }): VertexData;
  86516. /**
  86517. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86518. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86519. * * segments sets the number of horizontal strips optional, default 32
  86520. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86521. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86522. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86523. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86524. * * 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
  86525. * * 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
  86526. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86527. * * 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)
  86528. * * 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)
  86529. * @returns the VertexData of the ellipsoid
  86530. */
  86531. static CreateSphere(options: {
  86532. segments?: number;
  86533. diameter?: number;
  86534. diameterX?: number;
  86535. diameterY?: number;
  86536. diameterZ?: number;
  86537. arc?: number;
  86538. slice?: number;
  86539. sideOrientation?: number;
  86540. frontUVs?: Vector4;
  86541. backUVs?: Vector4;
  86542. }): VertexData;
  86543. /**
  86544. * Creates the VertexData for a cylinder, cone or prism
  86545. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86546. * * height sets the height (y direction) of the cylinder, optional, default 2
  86547. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86548. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86549. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86550. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86551. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86552. * * 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
  86553. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86554. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86555. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86556. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86557. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86558. * * 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)
  86559. * * 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)
  86560. * @returns the VertexData of the cylinder, cone or prism
  86561. */
  86562. static CreateCylinder(options: {
  86563. height?: number;
  86564. diameterTop?: number;
  86565. diameterBottom?: number;
  86566. diameter?: number;
  86567. tessellation?: number;
  86568. subdivisions?: number;
  86569. arc?: number;
  86570. faceColors?: Color4[];
  86571. faceUV?: Vector4[];
  86572. hasRings?: boolean;
  86573. enclose?: boolean;
  86574. sideOrientation?: number;
  86575. frontUVs?: Vector4;
  86576. backUVs?: Vector4;
  86577. }): VertexData;
  86578. /**
  86579. * Creates the VertexData for a torus
  86580. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86581. * * diameter the diameter of the torus, optional default 1
  86582. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86583. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86584. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86585. * * 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)
  86586. * * 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)
  86587. * @returns the VertexData of the torus
  86588. */
  86589. static CreateTorus(options: {
  86590. diameter?: number;
  86591. thickness?: number;
  86592. tessellation?: number;
  86593. sideOrientation?: number;
  86594. frontUVs?: Vector4;
  86595. backUVs?: Vector4;
  86596. }): VertexData;
  86597. /**
  86598. * Creates the VertexData of the LineSystem
  86599. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86600. * - lines an array of lines, each line being an array of successive Vector3
  86601. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86602. * @returns the VertexData of the LineSystem
  86603. */
  86604. static CreateLineSystem(options: {
  86605. lines: Vector3[][];
  86606. colors?: Nullable<Color4[][]>;
  86607. }): VertexData;
  86608. /**
  86609. * Create the VertexData for a DashedLines
  86610. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86611. * - points an array successive Vector3
  86612. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86613. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86614. * - dashNb the intended total number of dashes, optional, default 200
  86615. * @returns the VertexData for the DashedLines
  86616. */
  86617. static CreateDashedLines(options: {
  86618. points: Vector3[];
  86619. dashSize?: number;
  86620. gapSize?: number;
  86621. dashNb?: number;
  86622. }): VertexData;
  86623. /**
  86624. * Creates the VertexData for a Ground
  86625. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86626. * - width the width (x direction) of the ground, optional, default 1
  86627. * - height the height (z direction) of the ground, optional, default 1
  86628. * - subdivisions the number of subdivisions per side, optional, default 1
  86629. * @returns the VertexData of the Ground
  86630. */
  86631. static CreateGround(options: {
  86632. width?: number;
  86633. height?: number;
  86634. subdivisions?: number;
  86635. subdivisionsX?: number;
  86636. subdivisionsY?: number;
  86637. }): VertexData;
  86638. /**
  86639. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86640. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86641. * * xmin the ground minimum X coordinate, optional, default -1
  86642. * * zmin the ground minimum Z coordinate, optional, default -1
  86643. * * xmax the ground maximum X coordinate, optional, default 1
  86644. * * zmax the ground maximum Z coordinate, optional, default 1
  86645. * * 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}
  86646. * * 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}
  86647. * @returns the VertexData of the TiledGround
  86648. */
  86649. static CreateTiledGround(options: {
  86650. xmin: number;
  86651. zmin: number;
  86652. xmax: number;
  86653. zmax: number;
  86654. subdivisions?: {
  86655. w: number;
  86656. h: number;
  86657. };
  86658. precision?: {
  86659. w: number;
  86660. h: number;
  86661. };
  86662. }): VertexData;
  86663. /**
  86664. * Creates the VertexData of the Ground designed from a heightmap
  86665. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86666. * * width the width (x direction) of the ground
  86667. * * height the height (z direction) of the ground
  86668. * * subdivisions the number of subdivisions per side
  86669. * * minHeight the minimum altitude on the ground, optional, default 0
  86670. * * maxHeight the maximum altitude on the ground, optional default 1
  86671. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86672. * * buffer the array holding the image color data
  86673. * * bufferWidth the width of image
  86674. * * bufferHeight the height of image
  86675. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86676. * @returns the VertexData of the Ground designed from a heightmap
  86677. */
  86678. static CreateGroundFromHeightMap(options: {
  86679. width: number;
  86680. height: number;
  86681. subdivisions: number;
  86682. minHeight: number;
  86683. maxHeight: number;
  86684. colorFilter: Color3;
  86685. buffer: Uint8Array;
  86686. bufferWidth: number;
  86687. bufferHeight: number;
  86688. alphaFilter: number;
  86689. }): VertexData;
  86690. /**
  86691. * Creates the VertexData for a Plane
  86692. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86693. * * size sets the width and height of the plane to the value of size, optional default 1
  86694. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86695. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86696. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86697. * * 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)
  86698. * * 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)
  86699. * @returns the VertexData of the box
  86700. */
  86701. static CreatePlane(options: {
  86702. size?: number;
  86703. width?: number;
  86704. height?: number;
  86705. sideOrientation?: number;
  86706. frontUVs?: Vector4;
  86707. backUVs?: Vector4;
  86708. }): VertexData;
  86709. /**
  86710. * Creates the VertexData of the Disc or regular Polygon
  86711. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86712. * * radius the radius of the disc, optional default 0.5
  86713. * * tessellation the number of polygon sides, optional, default 64
  86714. * * 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
  86715. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86716. * * 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)
  86717. * * 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)
  86718. * @returns the VertexData of the box
  86719. */
  86720. static CreateDisc(options: {
  86721. radius?: number;
  86722. tessellation?: number;
  86723. arc?: number;
  86724. sideOrientation?: number;
  86725. frontUVs?: Vector4;
  86726. backUVs?: Vector4;
  86727. }): VertexData;
  86728. /**
  86729. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86730. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86731. * @param polygon a mesh built from polygonTriangulation.build()
  86732. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86733. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86734. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86735. * @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)
  86736. * @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)
  86737. * @returns the VertexData of the Polygon
  86738. */
  86739. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86740. /**
  86741. * Creates the VertexData of the IcoSphere
  86742. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86743. * * radius the radius of the IcoSphere, optional default 1
  86744. * * radiusX allows stretching in the x direction, optional, default radius
  86745. * * radiusY allows stretching in the y direction, optional, default radius
  86746. * * radiusZ allows stretching in the z direction, optional, default radius
  86747. * * flat when true creates a flat shaded mesh, optional, default true
  86748. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86749. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86750. * * 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)
  86751. * * 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)
  86752. * @returns the VertexData of the IcoSphere
  86753. */
  86754. static CreateIcoSphere(options: {
  86755. radius?: number;
  86756. radiusX?: number;
  86757. radiusY?: number;
  86758. radiusZ?: number;
  86759. flat?: boolean;
  86760. subdivisions?: number;
  86761. sideOrientation?: number;
  86762. frontUVs?: Vector4;
  86763. backUVs?: Vector4;
  86764. }): VertexData;
  86765. /**
  86766. * Creates the VertexData for a Polyhedron
  86767. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86768. * * type provided types are:
  86769. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86770. * * 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)
  86771. * * size the size of the IcoSphere, optional default 1
  86772. * * sizeX allows stretching in the x direction, optional, default size
  86773. * * sizeY allows stretching in the y direction, optional, default size
  86774. * * sizeZ allows stretching in the z direction, optional, default size
  86775. * * 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
  86776. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86777. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86778. * * flat when true creates a flat shaded mesh, optional, default true
  86779. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86780. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86781. * * 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)
  86782. * * 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)
  86783. * @returns the VertexData of the Polyhedron
  86784. */
  86785. static CreatePolyhedron(options: {
  86786. type?: number;
  86787. size?: number;
  86788. sizeX?: number;
  86789. sizeY?: number;
  86790. sizeZ?: number;
  86791. custom?: any;
  86792. faceUV?: Vector4[];
  86793. faceColors?: Color4[];
  86794. flat?: boolean;
  86795. sideOrientation?: number;
  86796. frontUVs?: Vector4;
  86797. backUVs?: Vector4;
  86798. }): VertexData;
  86799. /**
  86800. * Creates the VertexData for a TorusKnot
  86801. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86802. * * radius the radius of the torus knot, optional, default 2
  86803. * * tube the thickness of the tube, optional, default 0.5
  86804. * * radialSegments the number of sides on each tube segments, optional, default 32
  86805. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86806. * * p the number of windings around the z axis, optional, default 2
  86807. * * q the number of windings around the x axis, optional, default 3
  86808. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86809. * * 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)
  86810. * * 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)
  86811. * @returns the VertexData of the Torus Knot
  86812. */
  86813. static CreateTorusKnot(options: {
  86814. radius?: number;
  86815. tube?: number;
  86816. radialSegments?: number;
  86817. tubularSegments?: number;
  86818. p?: number;
  86819. q?: number;
  86820. sideOrientation?: number;
  86821. frontUVs?: Vector4;
  86822. backUVs?: Vector4;
  86823. }): VertexData;
  86824. /**
  86825. * Compute normals for given positions and indices
  86826. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86827. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86828. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86829. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86830. * * facetNormals : optional array of facet normals (vector3)
  86831. * * facetPositions : optional array of facet positions (vector3)
  86832. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86833. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86834. * * bInfo : optional bounding info, required for facetPartitioning computation
  86835. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86836. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86837. * * useRightHandedSystem: optional boolean to for right handed system computation
  86838. * * depthSort : optional boolean to enable the facet depth sort computation
  86839. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86840. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86841. */
  86842. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86843. facetNormals?: any;
  86844. facetPositions?: any;
  86845. facetPartitioning?: any;
  86846. ratio?: number;
  86847. bInfo?: any;
  86848. bbSize?: Vector3;
  86849. subDiv?: any;
  86850. useRightHandedSystem?: boolean;
  86851. depthSort?: boolean;
  86852. distanceTo?: Vector3;
  86853. depthSortedFacets?: any;
  86854. }): void;
  86855. /** @hidden */
  86856. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86857. /**
  86858. * Applies VertexData created from the imported parameters to the geometry
  86859. * @param parsedVertexData the parsed data from an imported file
  86860. * @param geometry the geometry to apply the VertexData to
  86861. */
  86862. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86863. }
  86864. }
  86865. declare module BABYLON {
  86866. /**
  86867. * Class containing static functions to help procedurally build meshes
  86868. */
  86869. export class DiscBuilder {
  86870. /**
  86871. * Creates a plane polygonal mesh. By default, this is a disc
  86872. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86873. * * 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
  86874. * * 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
  86875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86878. * @param name defines the name of the mesh
  86879. * @param options defines the options used to create the mesh
  86880. * @param scene defines the hosting scene
  86881. * @returns the plane polygonal mesh
  86882. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86883. */
  86884. static CreateDisc(name: string, options: {
  86885. radius?: number;
  86886. tessellation?: number;
  86887. arc?: number;
  86888. updatable?: boolean;
  86889. sideOrientation?: number;
  86890. frontUVs?: Vector4;
  86891. backUVs?: Vector4;
  86892. }, scene?: Nullable<Scene>): Mesh;
  86893. }
  86894. }
  86895. declare module BABYLON {
  86896. /**
  86897. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86898. *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.
  86899. * The SPS is also a particle system. It provides some methods to manage the particles.
  86900. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86901. *
  86902. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86903. */
  86904. export class SolidParticleSystem implements IDisposable {
  86905. /**
  86906. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86907. * Example : var p = SPS.particles[i];
  86908. */
  86909. particles: SolidParticle[];
  86910. /**
  86911. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86912. */
  86913. nbParticles: number;
  86914. /**
  86915. * If the particles must ever face the camera (default false). Useful for planar particles.
  86916. */
  86917. billboard: boolean;
  86918. /**
  86919. * Recompute normals when adding a shape
  86920. */
  86921. recomputeNormals: boolean;
  86922. /**
  86923. * This a counter ofr your own usage. It's not set by any SPS functions.
  86924. */
  86925. counter: number;
  86926. /**
  86927. * The SPS name. This name is also given to the underlying mesh.
  86928. */
  86929. name: string;
  86930. /**
  86931. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86932. */
  86933. mesh: Mesh;
  86934. /**
  86935. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86936. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86937. */
  86938. vars: any;
  86939. /**
  86940. * This array is populated when the SPS is set as 'pickable'.
  86941. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86942. * Each element of this array is an object `{idx: int, faceId: int}`.
  86943. * `idx` is the picked particle index in the `SPS.particles` array
  86944. * `faceId` is the picked face index counted within this particle.
  86945. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86946. */
  86947. pickedParticles: {
  86948. idx: number;
  86949. faceId: number;
  86950. }[];
  86951. /**
  86952. * This array is populated when `enableDepthSort` is set to true.
  86953. * Each element of this array is an instance of the class DepthSortedParticle.
  86954. */
  86955. depthSortedParticles: DepthSortedParticle[];
  86956. /**
  86957. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86958. * @hidden
  86959. */
  86960. _bSphereOnly: boolean;
  86961. /**
  86962. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86963. * @hidden
  86964. */
  86965. _bSphereRadiusFactor: number;
  86966. private _scene;
  86967. private _positions;
  86968. private _indices;
  86969. private _normals;
  86970. private _colors;
  86971. private _uvs;
  86972. private _indices32;
  86973. private _positions32;
  86974. private _normals32;
  86975. private _fixedNormal32;
  86976. private _colors32;
  86977. private _uvs32;
  86978. private _index;
  86979. private _updatable;
  86980. private _pickable;
  86981. private _isVisibilityBoxLocked;
  86982. private _alwaysVisible;
  86983. private _depthSort;
  86984. private _shapeCounter;
  86985. private _copy;
  86986. private _color;
  86987. private _computeParticleColor;
  86988. private _computeParticleTexture;
  86989. private _computeParticleRotation;
  86990. private _computeParticleVertex;
  86991. private _computeBoundingBox;
  86992. private _depthSortParticles;
  86993. private _camera;
  86994. private _mustUnrotateFixedNormals;
  86995. private _particlesIntersect;
  86996. private _needs32Bits;
  86997. /**
  86998. * Creates a SPS (Solid Particle System) object.
  86999. * @param name (String) is the SPS name, this will be the underlying mesh name.
  87000. * @param scene (Scene) is the scene in which the SPS is added.
  87001. * @param options defines the options of the sps e.g.
  87002. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  87003. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  87004. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  87005. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  87006. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  87007. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  87008. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  87009. */
  87010. constructor(name: string, scene: Scene, options?: {
  87011. updatable?: boolean;
  87012. isPickable?: boolean;
  87013. enableDepthSort?: boolean;
  87014. particleIntersection?: boolean;
  87015. boundingSphereOnly?: boolean;
  87016. bSphereRadiusFactor?: number;
  87017. });
  87018. /**
  87019. * Builds the SPS underlying mesh. Returns a standard Mesh.
  87020. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  87021. * @returns the created mesh
  87022. */
  87023. buildMesh(): Mesh;
  87024. /**
  87025. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  87026. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  87027. * Thus the particles generated from `digest()` have their property `position` set yet.
  87028. * @param mesh ( Mesh ) is the mesh to be digested
  87029. * @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
  87030. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  87031. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  87032. * @returns the current SPS
  87033. */
  87034. digest(mesh: Mesh, options?: {
  87035. facetNb?: number;
  87036. number?: number;
  87037. delta?: number;
  87038. }): SolidParticleSystem;
  87039. private _unrotateFixedNormals;
  87040. private _resetCopy;
  87041. private _meshBuilder;
  87042. private _posToShape;
  87043. private _uvsToShapeUV;
  87044. private _addParticle;
  87045. /**
  87046. * Adds some particles to the SPS from the model shape. Returns the shape id.
  87047. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  87048. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  87049. * @param nb (positive integer) the number of particles to be created from this model
  87050. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  87051. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  87052. * @returns the number of shapes in the system
  87053. */
  87054. addShape(mesh: Mesh, nb: number, options?: {
  87055. positionFunction?: any;
  87056. vertexFunction?: any;
  87057. }): number;
  87058. private _rebuildParticle;
  87059. /**
  87060. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  87061. * @returns the SPS.
  87062. */
  87063. rebuildMesh(): SolidParticleSystem;
  87064. /**
  87065. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  87066. * This method calls `updateParticle()` for each particle of the SPS.
  87067. * For an animated SPS, it is usually called within the render loop.
  87068. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  87069. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  87070. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  87071. * @returns the SPS.
  87072. */
  87073. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  87074. /**
  87075. * Disposes the SPS.
  87076. */
  87077. dispose(): void;
  87078. /**
  87079. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  87080. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87081. * @returns the SPS.
  87082. */
  87083. refreshVisibleSize(): SolidParticleSystem;
  87084. /**
  87085. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  87086. * @param size the size (float) of the visibility box
  87087. * note : this doesn't lock the SPS mesh bounding box.
  87088. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87089. */
  87090. setVisibilityBox(size: number): void;
  87091. /**
  87092. * Gets whether the SPS as always visible or not
  87093. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87094. */
  87095. /**
  87096. * Sets the SPS as always visible or not
  87097. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87098. */
  87099. isAlwaysVisible: boolean;
  87100. /**
  87101. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  87102. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87103. */
  87104. /**
  87105. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  87106. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87107. */
  87108. isVisibilityBoxLocked: boolean;
  87109. /**
  87110. * Tells to `setParticles()` to compute the particle rotations or not.
  87111. * Default value : true. The SPS is faster when it's set to false.
  87112. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  87113. */
  87114. /**
  87115. * Gets if `setParticles()` computes the particle rotations or not.
  87116. * Default value : true. The SPS is faster when it's set to false.
  87117. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  87118. */
  87119. computeParticleRotation: boolean;
  87120. /**
  87121. * Tells to `setParticles()` to compute the particle colors or not.
  87122. * Default value : true. The SPS is faster when it's set to false.
  87123. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  87124. */
  87125. /**
  87126. * Gets if `setParticles()` computes the particle colors or not.
  87127. * Default value : true. The SPS is faster when it's set to false.
  87128. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  87129. */
  87130. computeParticleColor: boolean;
  87131. /**
  87132. * Gets if `setParticles()` computes the particle textures or not.
  87133. * Default value : true. The SPS is faster when it's set to false.
  87134. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  87135. */
  87136. computeParticleTexture: boolean;
  87137. /**
  87138. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  87139. * Default value : false. The SPS is faster when it's set to false.
  87140. * Note : the particle custom vertex positions aren't stored values.
  87141. */
  87142. /**
  87143. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  87144. * Default value : false. The SPS is faster when it's set to false.
  87145. * Note : the particle custom vertex positions aren't stored values.
  87146. */
  87147. computeParticleVertex: boolean;
  87148. /**
  87149. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  87150. */
  87151. /**
  87152. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  87153. */
  87154. computeBoundingBox: boolean;
  87155. /**
  87156. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  87157. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  87158. * Default : `true`
  87159. */
  87160. /**
  87161. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  87162. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  87163. * Default : `true`
  87164. */
  87165. depthSortParticles: boolean;
  87166. /**
  87167. * This function does nothing. It may be overwritten to set all the particle first values.
  87168. * The SPS doesn't call this function, you may have to call it by your own.
  87169. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87170. */
  87171. initParticles(): void;
  87172. /**
  87173. * This function does nothing. It may be overwritten to recycle a particle.
  87174. * The SPS doesn't call this function, you may have to call it by your own.
  87175. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87176. * @param particle The particle to recycle
  87177. * @returns the recycled particle
  87178. */
  87179. recycleParticle(particle: SolidParticle): SolidParticle;
  87180. /**
  87181. * Updates a particle : this function should be overwritten by the user.
  87182. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  87183. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87184. * @example : just set a particle position or velocity and recycle conditions
  87185. * @param particle The particle to update
  87186. * @returns the updated particle
  87187. */
  87188. updateParticle(particle: SolidParticle): SolidParticle;
  87189. /**
  87190. * Updates a vertex of a particle : it can be overwritten by the user.
  87191. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  87192. * @param particle the current particle
  87193. * @param vertex the current index of the current particle
  87194. * @param pt the index of the current vertex in the particle shape
  87195. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  87196. * @example : just set a vertex particle position
  87197. * @returns the updated vertex
  87198. */
  87199. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  87200. /**
  87201. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  87202. * This does nothing and may be overwritten by the user.
  87203. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87204. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87205. * @param update the boolean update value actually passed to setParticles()
  87206. */
  87207. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  87208. /**
  87209. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  87210. * This will be passed three parameters.
  87211. * This does nothing and may be overwritten by the user.
  87212. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87213. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87214. * @param update the boolean update value actually passed to setParticles()
  87215. */
  87216. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  87217. }
  87218. }
  87219. declare module BABYLON {
  87220. /**
  87221. * Represents one particle of a solid particle system.
  87222. */
  87223. export class SolidParticle {
  87224. /**
  87225. * particle global index
  87226. */
  87227. idx: number;
  87228. /**
  87229. * The color of the particle
  87230. */
  87231. color: Nullable<Color4>;
  87232. /**
  87233. * The world space position of the particle.
  87234. */
  87235. position: Vector3;
  87236. /**
  87237. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  87238. */
  87239. rotation: Vector3;
  87240. /**
  87241. * The world space rotation quaternion of the particle.
  87242. */
  87243. rotationQuaternion: Nullable<Quaternion>;
  87244. /**
  87245. * The scaling of the particle.
  87246. */
  87247. scaling: Vector3;
  87248. /**
  87249. * The uvs of the particle.
  87250. */
  87251. uvs: Vector4;
  87252. /**
  87253. * The current speed of the particle.
  87254. */
  87255. velocity: Vector3;
  87256. /**
  87257. * The pivot point in the particle local space.
  87258. */
  87259. pivot: Vector3;
  87260. /**
  87261. * Must the particle be translated from its pivot point in its local space ?
  87262. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  87263. * Default : false
  87264. */
  87265. translateFromPivot: boolean;
  87266. /**
  87267. * Is the particle active or not ?
  87268. */
  87269. alive: boolean;
  87270. /**
  87271. * Is the particle visible or not ?
  87272. */
  87273. isVisible: boolean;
  87274. /**
  87275. * Index of this particle in the global "positions" array (Internal use)
  87276. * @hidden
  87277. */
  87278. _pos: number;
  87279. /**
  87280. * @hidden Index of this particle in the global "indices" array (Internal use)
  87281. */
  87282. _ind: number;
  87283. /**
  87284. * @hidden ModelShape of this particle (Internal use)
  87285. */
  87286. _model: ModelShape;
  87287. /**
  87288. * ModelShape id of this particle
  87289. */
  87290. shapeId: number;
  87291. /**
  87292. * Index of the particle in its shape id (Internal use)
  87293. */
  87294. idxInShape: number;
  87295. /**
  87296. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  87297. */
  87298. _modelBoundingInfo: BoundingInfo;
  87299. /**
  87300. * @hidden Particle BoundingInfo object (Internal use)
  87301. */
  87302. _boundingInfo: BoundingInfo;
  87303. /**
  87304. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  87305. */
  87306. _sps: SolidParticleSystem;
  87307. /**
  87308. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  87309. */
  87310. _stillInvisible: boolean;
  87311. /**
  87312. * @hidden Last computed particle rotation matrix
  87313. */
  87314. _rotationMatrix: number[];
  87315. /**
  87316. * Parent particle Id, if any.
  87317. * Default null.
  87318. */
  87319. parentId: Nullable<number>;
  87320. /**
  87321. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  87322. * The possible values are :
  87323. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87324. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87325. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87326. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87327. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87328. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  87329. * */
  87330. cullingStrategy: number;
  87331. /**
  87332. * @hidden Internal global position in the SPS.
  87333. */
  87334. _globalPosition: Vector3;
  87335. /**
  87336. * Creates a Solid Particle object.
  87337. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  87338. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  87339. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  87340. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  87341. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  87342. * @param shapeId (integer) is the model shape identifier in the SPS.
  87343. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  87344. * @param sps defines the sps it is associated to
  87345. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  87346. */
  87347. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  87348. /**
  87349. * Legacy support, changed scale to scaling
  87350. */
  87351. /**
  87352. * Legacy support, changed scale to scaling
  87353. */
  87354. scale: Vector3;
  87355. /**
  87356. * Legacy support, changed quaternion to rotationQuaternion
  87357. */
  87358. /**
  87359. * Legacy support, changed quaternion to rotationQuaternion
  87360. */
  87361. quaternion: Nullable<Quaternion>;
  87362. /**
  87363. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  87364. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  87365. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  87366. * @returns true if it intersects
  87367. */
  87368. intersectsMesh(target: Mesh | SolidParticle): boolean;
  87369. /**
  87370. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  87371. * A particle is in the frustum if its bounding box intersects the frustum
  87372. * @param frustumPlanes defines the frustum to test
  87373. * @returns true if the particle is in the frustum planes
  87374. */
  87375. isInFrustum(frustumPlanes: Plane[]): boolean;
  87376. /**
  87377. * get the rotation matrix of the particle
  87378. * @hidden
  87379. */
  87380. getRotationMatrix(m: Matrix): void;
  87381. }
  87382. /**
  87383. * Represents the shape of the model used by one particle of a solid particle system.
  87384. * SPS internal tool, don't use it manually.
  87385. */
  87386. export class ModelShape {
  87387. /**
  87388. * The shape id
  87389. * @hidden
  87390. */
  87391. shapeID: number;
  87392. /**
  87393. * flat array of model positions (internal use)
  87394. * @hidden
  87395. */
  87396. _shape: Vector3[];
  87397. /**
  87398. * flat array of model UVs (internal use)
  87399. * @hidden
  87400. */
  87401. _shapeUV: number[];
  87402. /**
  87403. * length of the shape in the model indices array (internal use)
  87404. * @hidden
  87405. */
  87406. _indicesLength: number;
  87407. /**
  87408. * Custom position function (internal use)
  87409. * @hidden
  87410. */
  87411. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  87412. /**
  87413. * Custom vertex function (internal use)
  87414. * @hidden
  87415. */
  87416. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  87417. /**
  87418. * 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.
  87419. * SPS internal tool, don't use it manually.
  87420. * @hidden
  87421. */
  87422. 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>);
  87423. }
  87424. /**
  87425. * Represents a Depth Sorted Particle in the solid particle system.
  87426. */
  87427. export class DepthSortedParticle {
  87428. /**
  87429. * Index of the particle in the "indices" array
  87430. */
  87431. ind: number;
  87432. /**
  87433. * Length of the particle shape in the "indices" array
  87434. */
  87435. indicesLength: number;
  87436. /**
  87437. * Squared distance from the particle to the camera
  87438. */
  87439. sqDistance: number;
  87440. }
  87441. }
  87442. declare module BABYLON {
  87443. /**
  87444. * @hidden
  87445. */
  87446. export class _MeshCollisionData {
  87447. _checkCollisions: boolean;
  87448. _collisionMask: number;
  87449. _collisionGroup: number;
  87450. _collider: Nullable<Collider>;
  87451. _oldPositionForCollisions: Vector3;
  87452. _diffPositionForCollisions: Vector3;
  87453. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  87454. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  87455. }
  87456. }
  87457. declare module BABYLON {
  87458. /** @hidden */
  87459. class _FacetDataStorage {
  87460. facetPositions: Vector3[];
  87461. facetNormals: Vector3[];
  87462. facetPartitioning: number[][];
  87463. facetNb: number;
  87464. partitioningSubdivisions: number;
  87465. partitioningBBoxRatio: number;
  87466. facetDataEnabled: boolean;
  87467. facetParameters: any;
  87468. bbSize: Vector3;
  87469. subDiv: {
  87470. max: number;
  87471. X: number;
  87472. Y: number;
  87473. Z: number;
  87474. };
  87475. facetDepthSort: boolean;
  87476. facetDepthSortEnabled: boolean;
  87477. depthSortedIndices: IndicesArray;
  87478. depthSortedFacets: {
  87479. ind: number;
  87480. sqDistance: number;
  87481. }[];
  87482. facetDepthSortFunction: (f1: {
  87483. ind: number;
  87484. sqDistance: number;
  87485. }, f2: {
  87486. ind: number;
  87487. sqDistance: number;
  87488. }) => number;
  87489. facetDepthSortFrom: Vector3;
  87490. facetDepthSortOrigin: Vector3;
  87491. invertedMatrix: Matrix;
  87492. }
  87493. /**
  87494. * @hidden
  87495. **/
  87496. class _InternalAbstractMeshDataInfo {
  87497. _hasVertexAlpha: boolean;
  87498. _useVertexColors: boolean;
  87499. _numBoneInfluencers: number;
  87500. _applyFog: boolean;
  87501. _receiveShadows: boolean;
  87502. _facetData: _FacetDataStorage;
  87503. _visibility: number;
  87504. _skeleton: Nullable<Skeleton>;
  87505. _layerMask: number;
  87506. _computeBonesUsingShaders: boolean;
  87507. _isActive: boolean;
  87508. _onlyForInstances: boolean;
  87509. _isActiveIntermediate: boolean;
  87510. _onlyForInstancesIntermediate: boolean;
  87511. }
  87512. /**
  87513. * Class used to store all common mesh properties
  87514. */
  87515. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  87516. /** No occlusion */
  87517. static OCCLUSION_TYPE_NONE: number;
  87518. /** Occlusion set to optimisitic */
  87519. static OCCLUSION_TYPE_OPTIMISTIC: number;
  87520. /** Occlusion set to strict */
  87521. static OCCLUSION_TYPE_STRICT: number;
  87522. /** Use an accurante occlusion algorithm */
  87523. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  87524. /** Use a conservative occlusion algorithm */
  87525. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  87526. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  87527. * Test order :
  87528. * Is the bounding sphere outside the frustum ?
  87529. * If not, are the bounding box vertices outside the frustum ?
  87530. * It not, then the cullable object is in the frustum.
  87531. */
  87532. static readonly CULLINGSTRATEGY_STANDARD: number;
  87533. /** Culling strategy : Bounding Sphere Only.
  87534. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  87535. * It's also less accurate than the standard because some not visible objects can still be selected.
  87536. * Test : is the bounding sphere outside the frustum ?
  87537. * If not, then the cullable object is in the frustum.
  87538. */
  87539. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  87540. /** Culling strategy : Optimistic Inclusion.
  87541. * This in an inclusion test first, then the standard exclusion test.
  87542. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  87543. * 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.
  87544. * Anyway, it's as accurate as the standard strategy.
  87545. * Test :
  87546. * Is the cullable object bounding sphere center in the frustum ?
  87547. * If not, apply the default culling strategy.
  87548. */
  87549. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  87550. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  87551. * This in an inclusion test first, then the bounding sphere only exclusion test.
  87552. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  87553. * 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.
  87554. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  87555. * Test :
  87556. * Is the cullable object bounding sphere center in the frustum ?
  87557. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  87558. */
  87559. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  87560. /**
  87561. * No billboard
  87562. */
  87563. static readonly BILLBOARDMODE_NONE: number;
  87564. /** Billboard on X axis */
  87565. static readonly BILLBOARDMODE_X: number;
  87566. /** Billboard on Y axis */
  87567. static readonly BILLBOARDMODE_Y: number;
  87568. /** Billboard on Z axis */
  87569. static readonly BILLBOARDMODE_Z: number;
  87570. /** Billboard on all axes */
  87571. static readonly BILLBOARDMODE_ALL: number;
  87572. /** @hidden */
  87573. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  87574. /**
  87575. * The culling strategy to use to check whether the mesh must be rendered or not.
  87576. * This value can be changed at any time and will be used on the next render mesh selection.
  87577. * The possible values are :
  87578. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87579. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87580. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87581. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87582. * Please read each static variable documentation to get details about the culling process.
  87583. * */
  87584. cullingStrategy: number;
  87585. /**
  87586. * Gets the number of facets in the mesh
  87587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87588. */
  87589. readonly facetNb: number;
  87590. /**
  87591. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  87592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87593. */
  87594. partitioningSubdivisions: number;
  87595. /**
  87596. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  87597. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  87598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87599. */
  87600. partitioningBBoxRatio: number;
  87601. /**
  87602. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  87603. * Works only for updatable meshes.
  87604. * Doesn't work with multi-materials
  87605. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87606. */
  87607. mustDepthSortFacets: boolean;
  87608. /**
  87609. * The location (Vector3) where the facet depth sort must be computed from.
  87610. * By default, the active camera position.
  87611. * Used only when facet depth sort is enabled
  87612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87613. */
  87614. facetDepthSortFrom: Vector3;
  87615. /**
  87616. * gets a boolean indicating if facetData is enabled
  87617. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87618. */
  87619. readonly isFacetDataEnabled: boolean;
  87620. /** @hidden */
  87621. _updateNonUniformScalingState(value: boolean): boolean;
  87622. /**
  87623. * An event triggered when this mesh collides with another one
  87624. */
  87625. onCollideObservable: Observable<AbstractMesh>;
  87626. /** Set a function to call when this mesh collides with another one */
  87627. onCollide: () => void;
  87628. /**
  87629. * An event triggered when the collision's position changes
  87630. */
  87631. onCollisionPositionChangeObservable: Observable<Vector3>;
  87632. /** Set a function to call when the collision's position changes */
  87633. onCollisionPositionChange: () => void;
  87634. /**
  87635. * An event triggered when material is changed
  87636. */
  87637. onMaterialChangedObservable: Observable<AbstractMesh>;
  87638. /**
  87639. * Gets or sets the orientation for POV movement & rotation
  87640. */
  87641. definedFacingForward: boolean;
  87642. /** @hidden */
  87643. _occlusionQuery: Nullable<WebGLQuery>;
  87644. /** @hidden */
  87645. _renderingGroup: Nullable<RenderingGroup>;
  87646. /**
  87647. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87648. */
  87649. /**
  87650. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87651. */
  87652. visibility: number;
  87653. /** Gets or sets the alpha index used to sort transparent meshes
  87654. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  87655. */
  87656. alphaIndex: number;
  87657. /**
  87658. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  87659. */
  87660. isVisible: boolean;
  87661. /**
  87662. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87663. */
  87664. isPickable: boolean;
  87665. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  87666. showSubMeshesBoundingBox: boolean;
  87667. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  87668. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  87669. */
  87670. isBlocker: boolean;
  87671. /**
  87672. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  87673. */
  87674. enablePointerMoveEvents: boolean;
  87675. /**
  87676. * Specifies the rendering group id for this mesh (0 by default)
  87677. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87678. */
  87679. renderingGroupId: number;
  87680. private _material;
  87681. /** Gets or sets current material */
  87682. material: Nullable<Material>;
  87683. /**
  87684. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  87685. * @see http://doc.babylonjs.com/babylon101/shadows
  87686. */
  87687. receiveShadows: boolean;
  87688. /** Defines color to use when rendering outline */
  87689. outlineColor: Color3;
  87690. /** Define width to use when rendering outline */
  87691. outlineWidth: number;
  87692. /** Defines color to use when rendering overlay */
  87693. overlayColor: Color3;
  87694. /** Defines alpha to use when rendering overlay */
  87695. overlayAlpha: number;
  87696. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  87697. hasVertexAlpha: boolean;
  87698. /** 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) */
  87699. useVertexColors: boolean;
  87700. /**
  87701. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  87702. */
  87703. computeBonesUsingShaders: boolean;
  87704. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  87705. numBoneInfluencers: number;
  87706. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  87707. applyFog: boolean;
  87708. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  87709. useOctreeForRenderingSelection: boolean;
  87710. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  87711. useOctreeForPicking: boolean;
  87712. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  87713. useOctreeForCollisions: boolean;
  87714. /**
  87715. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  87716. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  87717. */
  87718. layerMask: number;
  87719. /**
  87720. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  87721. */
  87722. alwaysSelectAsActiveMesh: boolean;
  87723. /**
  87724. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  87725. */
  87726. doNotSyncBoundingInfo: boolean;
  87727. /**
  87728. * Gets or sets the current action manager
  87729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87730. */
  87731. actionManager: Nullable<AbstractActionManager>;
  87732. private _meshCollisionData;
  87733. /**
  87734. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  87735. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87736. */
  87737. ellipsoid: Vector3;
  87738. /**
  87739. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  87740. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87741. */
  87742. ellipsoidOffset: Vector3;
  87743. /**
  87744. * Gets or sets a collision mask used to mask collisions (default is -1).
  87745. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87746. */
  87747. collisionMask: number;
  87748. /**
  87749. * Gets or sets the current collision group mask (-1 by default).
  87750. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87751. */
  87752. collisionGroup: number;
  87753. /**
  87754. * Defines edge width used when edgesRenderer is enabled
  87755. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87756. */
  87757. edgesWidth: number;
  87758. /**
  87759. * Defines edge color used when edgesRenderer is enabled
  87760. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87761. */
  87762. edgesColor: Color4;
  87763. /** @hidden */
  87764. _edgesRenderer: Nullable<IEdgesRenderer>;
  87765. /** @hidden */
  87766. _masterMesh: Nullable<AbstractMesh>;
  87767. /** @hidden */
  87768. _boundingInfo: Nullable<BoundingInfo>;
  87769. /** @hidden */
  87770. _renderId: number;
  87771. /**
  87772. * Gets or sets the list of subMeshes
  87773. * @see http://doc.babylonjs.com/how_to/multi_materials
  87774. */
  87775. subMeshes: SubMesh[];
  87776. /** @hidden */
  87777. _intersectionsInProgress: AbstractMesh[];
  87778. /** @hidden */
  87779. _unIndexed: boolean;
  87780. /** @hidden */
  87781. _lightSources: Light[];
  87782. /** Gets the list of lights affecting that mesh */
  87783. readonly lightSources: Light[];
  87784. /** @hidden */
  87785. readonly _positions: Nullable<Vector3[]>;
  87786. /** @hidden */
  87787. _waitingData: {
  87788. lods: Nullable<any>;
  87789. actions: Nullable<any>;
  87790. freezeWorldMatrix: Nullable<boolean>;
  87791. };
  87792. /** @hidden */
  87793. _bonesTransformMatrices: Nullable<Float32Array>;
  87794. /** @hidden */
  87795. _transformMatrixTexture: Nullable<RawTexture>;
  87796. /**
  87797. * Gets or sets a skeleton to apply skining transformations
  87798. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87799. */
  87800. skeleton: Nullable<Skeleton>;
  87801. /**
  87802. * An event triggered when the mesh is rebuilt.
  87803. */
  87804. onRebuildObservable: Observable<AbstractMesh>;
  87805. /**
  87806. * Creates a new AbstractMesh
  87807. * @param name defines the name of the mesh
  87808. * @param scene defines the hosting scene
  87809. */
  87810. constructor(name: string, scene?: Nullable<Scene>);
  87811. /**
  87812. * Returns the string "AbstractMesh"
  87813. * @returns "AbstractMesh"
  87814. */
  87815. getClassName(): string;
  87816. /**
  87817. * Gets a string representation of the current mesh
  87818. * @param fullDetails defines a boolean indicating if full details must be included
  87819. * @returns a string representation of the current mesh
  87820. */
  87821. toString(fullDetails?: boolean): string;
  87822. /**
  87823. * @hidden
  87824. */
  87825. protected _getEffectiveParent(): Nullable<Node>;
  87826. /** @hidden */
  87827. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87828. /** @hidden */
  87829. _rebuild(): void;
  87830. /** @hidden */
  87831. _resyncLightSources(): void;
  87832. /** @hidden */
  87833. _resyncLighSource(light: Light): void;
  87834. /** @hidden */
  87835. _unBindEffect(): void;
  87836. /** @hidden */
  87837. _removeLightSource(light: Light): void;
  87838. private _markSubMeshesAsDirty;
  87839. /** @hidden */
  87840. _markSubMeshesAsLightDirty(): void;
  87841. /** @hidden */
  87842. _markSubMeshesAsAttributesDirty(): void;
  87843. /** @hidden */
  87844. _markSubMeshesAsMiscDirty(): void;
  87845. /**
  87846. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87847. */
  87848. scaling: Vector3;
  87849. /**
  87850. * Returns true if the mesh is blocked. Implemented by child classes
  87851. */
  87852. readonly isBlocked: boolean;
  87853. /**
  87854. * Returns the mesh itself by default. Implemented by child classes
  87855. * @param camera defines the camera to use to pick the right LOD level
  87856. * @returns the currentAbstractMesh
  87857. */
  87858. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87859. /**
  87860. * Returns 0 by default. Implemented by child classes
  87861. * @returns an integer
  87862. */
  87863. getTotalVertices(): number;
  87864. /**
  87865. * Returns a positive integer : the total number of indices in this mesh geometry.
  87866. * @returns the numner of indices or zero if the mesh has no geometry.
  87867. */
  87868. getTotalIndices(): number;
  87869. /**
  87870. * Returns null by default. Implemented by child classes
  87871. * @returns null
  87872. */
  87873. getIndices(): Nullable<IndicesArray>;
  87874. /**
  87875. * Returns the array of the requested vertex data kind. Implemented by child classes
  87876. * @param kind defines the vertex data kind to use
  87877. * @returns null
  87878. */
  87879. getVerticesData(kind: string): Nullable<FloatArray>;
  87880. /**
  87881. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87882. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87883. * Note that a new underlying VertexBuffer object is created each call.
  87884. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87885. * @param kind defines vertex data kind:
  87886. * * VertexBuffer.PositionKind
  87887. * * VertexBuffer.UVKind
  87888. * * VertexBuffer.UV2Kind
  87889. * * VertexBuffer.UV3Kind
  87890. * * VertexBuffer.UV4Kind
  87891. * * VertexBuffer.UV5Kind
  87892. * * VertexBuffer.UV6Kind
  87893. * * VertexBuffer.ColorKind
  87894. * * VertexBuffer.MatricesIndicesKind
  87895. * * VertexBuffer.MatricesIndicesExtraKind
  87896. * * VertexBuffer.MatricesWeightsKind
  87897. * * VertexBuffer.MatricesWeightsExtraKind
  87898. * @param data defines the data source
  87899. * @param updatable defines if the data must be flagged as updatable (or static)
  87900. * @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
  87901. * @returns the current mesh
  87902. */
  87903. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87904. /**
  87905. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87906. * If the mesh has no geometry, it is simply returned as it is.
  87907. * @param kind defines vertex data kind:
  87908. * * VertexBuffer.PositionKind
  87909. * * VertexBuffer.UVKind
  87910. * * VertexBuffer.UV2Kind
  87911. * * VertexBuffer.UV3Kind
  87912. * * VertexBuffer.UV4Kind
  87913. * * VertexBuffer.UV5Kind
  87914. * * VertexBuffer.UV6Kind
  87915. * * VertexBuffer.ColorKind
  87916. * * VertexBuffer.MatricesIndicesKind
  87917. * * VertexBuffer.MatricesIndicesExtraKind
  87918. * * VertexBuffer.MatricesWeightsKind
  87919. * * VertexBuffer.MatricesWeightsExtraKind
  87920. * @param data defines the data source
  87921. * @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
  87922. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87923. * @returns the current mesh
  87924. */
  87925. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87926. /**
  87927. * Sets the mesh indices,
  87928. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87929. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87930. * @param totalVertices Defines the total number of vertices
  87931. * @returns the current mesh
  87932. */
  87933. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87934. /**
  87935. * Gets a boolean indicating if specific vertex data is present
  87936. * @param kind defines the vertex data kind to use
  87937. * @returns true is data kind is present
  87938. */
  87939. isVerticesDataPresent(kind: string): boolean;
  87940. /**
  87941. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  87942. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  87943. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  87944. * @returns a BoundingInfo
  87945. */
  87946. getBoundingInfo(): BoundingInfo;
  87947. /**
  87948. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87949. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87950. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87951. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87952. * @returns the current mesh
  87953. */
  87954. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  87955. /**
  87956. * Overwrite the current bounding info
  87957. * @param boundingInfo defines the new bounding info
  87958. * @returns the current mesh
  87959. */
  87960. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87961. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87962. readonly useBones: boolean;
  87963. /** @hidden */
  87964. _preActivate(): void;
  87965. /** @hidden */
  87966. _preActivateForIntermediateRendering(renderId: number): void;
  87967. /** @hidden */
  87968. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87969. /** @hidden */
  87970. _postActivate(): void;
  87971. /** @hidden */
  87972. _freeze(): void;
  87973. /** @hidden */
  87974. _unFreeze(): void;
  87975. /**
  87976. * Gets the current world matrix
  87977. * @returns a Matrix
  87978. */
  87979. getWorldMatrix(): Matrix;
  87980. /** @hidden */
  87981. _getWorldMatrixDeterminant(): number;
  87982. /**
  87983. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87984. */
  87985. readonly isAnInstance: boolean;
  87986. /**
  87987. * Perform relative position change from the point of view of behind the front of the mesh.
  87988. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87989. * Supports definition of mesh facing forward or backward
  87990. * @param amountRight defines the distance on the right axis
  87991. * @param amountUp defines the distance on the up axis
  87992. * @param amountForward defines the distance on the forward axis
  87993. * @returns the current mesh
  87994. */
  87995. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87996. /**
  87997. * Calculate relative position change from the point of view of behind the front of the mesh.
  87998. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87999. * Supports definition of mesh facing forward or backward
  88000. * @param amountRight defines the distance on the right axis
  88001. * @param amountUp defines the distance on the up axis
  88002. * @param amountForward defines the distance on the forward axis
  88003. * @returns the new displacement vector
  88004. */
  88005. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  88006. /**
  88007. * Perform relative rotation change from the point of view of behind the front of the mesh.
  88008. * Supports definition of mesh facing forward or backward
  88009. * @param flipBack defines the flip
  88010. * @param twirlClockwise defines the twirl
  88011. * @param tiltRight defines the tilt
  88012. * @returns the current mesh
  88013. */
  88014. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  88015. /**
  88016. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  88017. * Supports definition of mesh facing forward or backward.
  88018. * @param flipBack defines the flip
  88019. * @param twirlClockwise defines the twirl
  88020. * @param tiltRight defines the tilt
  88021. * @returns the new rotation vector
  88022. */
  88023. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  88024. /**
  88025. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88026. * This means the mesh underlying bounding box and sphere are recomputed.
  88027. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88028. * @returns the current mesh
  88029. */
  88030. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  88031. /** @hidden */
  88032. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  88033. /** @hidden */
  88034. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  88035. /** @hidden */
  88036. _updateBoundingInfo(): AbstractMesh;
  88037. /** @hidden */
  88038. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  88039. /** @hidden */
  88040. protected _afterComputeWorldMatrix(): void;
  88041. /** @hidden */
  88042. readonly _effectiveMesh: AbstractMesh;
  88043. /**
  88044. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  88045. * A mesh is in the frustum if its bounding box intersects the frustum
  88046. * @param frustumPlanes defines the frustum to test
  88047. * @returns true if the mesh is in the frustum planes
  88048. */
  88049. isInFrustum(frustumPlanes: Plane[]): boolean;
  88050. /**
  88051. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  88052. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  88053. * @param frustumPlanes defines the frustum to test
  88054. * @returns true if the mesh is completely in the frustum planes
  88055. */
  88056. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88057. /**
  88058. * True if the mesh intersects another mesh or a SolidParticle object
  88059. * @param mesh defines a target mesh or SolidParticle to test
  88060. * @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)
  88061. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  88062. * @returns true if there is an intersection
  88063. */
  88064. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  88065. /**
  88066. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  88067. * @param point defines the point to test
  88068. * @returns true if there is an intersection
  88069. */
  88070. intersectsPoint(point: Vector3): boolean;
  88071. /**
  88072. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  88073. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88074. */
  88075. checkCollisions: boolean;
  88076. /**
  88077. * Gets Collider object used to compute collisions (not physics)
  88078. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88079. */
  88080. readonly collider: Nullable<Collider>;
  88081. /**
  88082. * Move the mesh using collision engine
  88083. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88084. * @param displacement defines the requested displacement vector
  88085. * @returns the current mesh
  88086. */
  88087. moveWithCollisions(displacement: Vector3): AbstractMesh;
  88088. private _onCollisionPositionChange;
  88089. /** @hidden */
  88090. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  88091. /** @hidden */
  88092. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  88093. /** @hidden */
  88094. _checkCollision(collider: Collider): AbstractMesh;
  88095. /** @hidden */
  88096. _generatePointsArray(): boolean;
  88097. /**
  88098. * Checks if the passed Ray intersects with the mesh
  88099. * @param ray defines the ray to use
  88100. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  88101. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  88102. * @returns the picking info
  88103. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88104. */
  88105. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  88106. /**
  88107. * Clones the current mesh
  88108. * @param name defines the mesh name
  88109. * @param newParent defines the new mesh parent
  88110. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  88111. * @returns the new mesh
  88112. */
  88113. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88114. /**
  88115. * Disposes all the submeshes of the current meshnp
  88116. * @returns the current mesh
  88117. */
  88118. releaseSubMeshes(): AbstractMesh;
  88119. /**
  88120. * Releases resources associated with this abstract mesh.
  88121. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88122. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88123. */
  88124. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88125. /**
  88126. * Adds the passed mesh as a child to the current mesh
  88127. * @param mesh defines the child mesh
  88128. * @returns the current mesh
  88129. */
  88130. addChild(mesh: AbstractMesh): AbstractMesh;
  88131. /**
  88132. * Removes the passed mesh from the current mesh children list
  88133. * @param mesh defines the child mesh
  88134. * @returns the current mesh
  88135. */
  88136. removeChild(mesh: AbstractMesh): AbstractMesh;
  88137. /** @hidden */
  88138. private _initFacetData;
  88139. /**
  88140. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  88141. * This method can be called within the render loop.
  88142. * 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
  88143. * @returns the current mesh
  88144. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88145. */
  88146. updateFacetData(): AbstractMesh;
  88147. /**
  88148. * Returns the facetLocalNormals array.
  88149. * The normals are expressed in the mesh local spac
  88150. * @returns an array of Vector3
  88151. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88152. */
  88153. getFacetLocalNormals(): Vector3[];
  88154. /**
  88155. * Returns the facetLocalPositions array.
  88156. * The facet positions are expressed in the mesh local space
  88157. * @returns an array of Vector3
  88158. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88159. */
  88160. getFacetLocalPositions(): Vector3[];
  88161. /**
  88162. * Returns the facetLocalPartioning array
  88163. * @returns an array of array of numbers
  88164. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88165. */
  88166. getFacetLocalPartitioning(): number[][];
  88167. /**
  88168. * Returns the i-th facet position in the world system.
  88169. * This method allocates a new Vector3 per call
  88170. * @param i defines the facet index
  88171. * @returns a new Vector3
  88172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88173. */
  88174. getFacetPosition(i: number): Vector3;
  88175. /**
  88176. * Sets the reference Vector3 with the i-th facet position in the world system
  88177. * @param i defines the facet index
  88178. * @param ref defines the target vector
  88179. * @returns the current mesh
  88180. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88181. */
  88182. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  88183. /**
  88184. * Returns the i-th facet normal in the world system.
  88185. * This method allocates a new Vector3 per call
  88186. * @param i defines the facet index
  88187. * @returns a new Vector3
  88188. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88189. */
  88190. getFacetNormal(i: number): Vector3;
  88191. /**
  88192. * Sets the reference Vector3 with the i-th facet normal in the world system
  88193. * @param i defines the facet index
  88194. * @param ref defines the target vector
  88195. * @returns the current mesh
  88196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88197. */
  88198. getFacetNormalToRef(i: number, ref: Vector3): this;
  88199. /**
  88200. * 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)
  88201. * @param x defines x coordinate
  88202. * @param y defines y coordinate
  88203. * @param z defines z coordinate
  88204. * @returns the array of facet indexes
  88205. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88206. */
  88207. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  88208. /**
  88209. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  88210. * @param projected sets as the (x,y,z) world projection on the facet
  88211. * @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
  88212. * @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
  88213. * @param x defines x coordinate
  88214. * @param y defines y coordinate
  88215. * @param z defines z coordinate
  88216. * @returns the face index if found (or null instead)
  88217. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88218. */
  88219. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  88220. /**
  88221. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  88222. * @param projected sets as the (x,y,z) local projection on the facet
  88223. * @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
  88224. * @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
  88225. * @param x defines x coordinate
  88226. * @param y defines y coordinate
  88227. * @param z defines z coordinate
  88228. * @returns the face index if found (or null instead)
  88229. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88230. */
  88231. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  88232. /**
  88233. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  88234. * @returns the parameters
  88235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88236. */
  88237. getFacetDataParameters(): any;
  88238. /**
  88239. * Disables the feature FacetData and frees the related memory
  88240. * @returns the current mesh
  88241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88242. */
  88243. disableFacetData(): AbstractMesh;
  88244. /**
  88245. * Updates the AbstractMesh indices array
  88246. * @param indices defines the data source
  88247. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88248. * @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)
  88249. * @returns the current mesh
  88250. */
  88251. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  88252. /**
  88253. * Creates new normals data for the mesh
  88254. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  88255. * @returns the current mesh
  88256. */
  88257. createNormals(updatable: boolean): AbstractMesh;
  88258. /**
  88259. * Align the mesh with a normal
  88260. * @param normal defines the normal to use
  88261. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  88262. * @returns the current mesh
  88263. */
  88264. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  88265. /** @hidden */
  88266. _checkOcclusionQuery(): boolean;
  88267. /**
  88268. * Disables the mesh edge rendering mode
  88269. * @returns the currentAbstractMesh
  88270. */
  88271. disableEdgesRendering(): AbstractMesh;
  88272. /**
  88273. * Enables the edge rendering mode on the mesh.
  88274. * This mode makes the mesh edges visible
  88275. * @param epsilon defines the maximal distance between two angles to detect a face
  88276. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88277. * @returns the currentAbstractMesh
  88278. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88279. */
  88280. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88281. }
  88282. }
  88283. declare module BABYLON {
  88284. /**
  88285. * Interface used to define ActionEvent
  88286. */
  88287. export interface IActionEvent {
  88288. /** The mesh or sprite that triggered the action */
  88289. source: any;
  88290. /** The X mouse cursor position at the time of the event */
  88291. pointerX: number;
  88292. /** The Y mouse cursor position at the time of the event */
  88293. pointerY: number;
  88294. /** The mesh that is currently pointed at (can be null) */
  88295. meshUnderPointer: Nullable<AbstractMesh>;
  88296. /** the original (browser) event that triggered the ActionEvent */
  88297. sourceEvent?: any;
  88298. /** additional data for the event */
  88299. additionalData?: any;
  88300. }
  88301. /**
  88302. * ActionEvent is the event being sent when an action is triggered.
  88303. */
  88304. export class ActionEvent implements IActionEvent {
  88305. /** The mesh or sprite that triggered the action */
  88306. source: any;
  88307. /** The X mouse cursor position at the time of the event */
  88308. pointerX: number;
  88309. /** The Y mouse cursor position at the time of the event */
  88310. pointerY: number;
  88311. /** The mesh that is currently pointed at (can be null) */
  88312. meshUnderPointer: Nullable<AbstractMesh>;
  88313. /** the original (browser) event that triggered the ActionEvent */
  88314. sourceEvent?: any;
  88315. /** additional data for the event */
  88316. additionalData?: any;
  88317. /**
  88318. * Creates a new ActionEvent
  88319. * @param source The mesh or sprite that triggered the action
  88320. * @param pointerX The X mouse cursor position at the time of the event
  88321. * @param pointerY The Y mouse cursor position at the time of the event
  88322. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  88323. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  88324. * @param additionalData additional data for the event
  88325. */
  88326. constructor(
  88327. /** The mesh or sprite that triggered the action */
  88328. source: any,
  88329. /** The X mouse cursor position at the time of the event */
  88330. pointerX: number,
  88331. /** The Y mouse cursor position at the time of the event */
  88332. pointerY: number,
  88333. /** The mesh that is currently pointed at (can be null) */
  88334. meshUnderPointer: Nullable<AbstractMesh>,
  88335. /** the original (browser) event that triggered the ActionEvent */
  88336. sourceEvent?: any,
  88337. /** additional data for the event */
  88338. additionalData?: any);
  88339. /**
  88340. * Helper function to auto-create an ActionEvent from a source mesh.
  88341. * @param source The source mesh that triggered the event
  88342. * @param evt The original (browser) event
  88343. * @param additionalData additional data for the event
  88344. * @returns the new ActionEvent
  88345. */
  88346. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  88347. /**
  88348. * Helper function to auto-create an ActionEvent from a source sprite
  88349. * @param source The source sprite that triggered the event
  88350. * @param scene Scene associated with the sprite
  88351. * @param evt The original (browser) event
  88352. * @param additionalData additional data for the event
  88353. * @returns the new ActionEvent
  88354. */
  88355. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  88356. /**
  88357. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  88358. * @param scene the scene where the event occurred
  88359. * @param evt The original (browser) event
  88360. * @returns the new ActionEvent
  88361. */
  88362. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  88363. /**
  88364. * Helper function to auto-create an ActionEvent from a primitive
  88365. * @param prim defines the target primitive
  88366. * @param pointerPos defines the pointer position
  88367. * @param evt The original (browser) event
  88368. * @param additionalData additional data for the event
  88369. * @returns the new ActionEvent
  88370. */
  88371. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  88372. }
  88373. }
  88374. declare module BABYLON {
  88375. /**
  88376. * Abstract class used to decouple action Manager from scene and meshes.
  88377. * Do not instantiate.
  88378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88379. */
  88380. export abstract class AbstractActionManager implements IDisposable {
  88381. /** Gets the list of active triggers */
  88382. static Triggers: {
  88383. [key: string]: number;
  88384. };
  88385. /** Gets the cursor to use when hovering items */
  88386. hoverCursor: string;
  88387. /** Gets the list of actions */
  88388. actions: IAction[];
  88389. /**
  88390. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  88391. */
  88392. isRecursive: boolean;
  88393. /**
  88394. * Releases all associated resources
  88395. */
  88396. abstract dispose(): void;
  88397. /**
  88398. * Does this action manager has pointer triggers
  88399. */
  88400. abstract readonly hasPointerTriggers: boolean;
  88401. /**
  88402. * Does this action manager has pick triggers
  88403. */
  88404. abstract readonly hasPickTriggers: boolean;
  88405. /**
  88406. * Process a specific trigger
  88407. * @param trigger defines the trigger to process
  88408. * @param evt defines the event details to be processed
  88409. */
  88410. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  88411. /**
  88412. * Does this action manager handles actions of any of the given triggers
  88413. * @param triggers defines the triggers to be tested
  88414. * @return a boolean indicating whether one (or more) of the triggers is handled
  88415. */
  88416. abstract hasSpecificTriggers(triggers: number[]): boolean;
  88417. /**
  88418. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88419. * speed.
  88420. * @param triggerA defines the trigger to be tested
  88421. * @param triggerB defines the trigger to be tested
  88422. * @return a boolean indicating whether one (or more) of the triggers is handled
  88423. */
  88424. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88425. /**
  88426. * Does this action manager handles actions of a given trigger
  88427. * @param trigger defines the trigger to be tested
  88428. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88429. * @return whether the trigger is handled
  88430. */
  88431. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88432. /**
  88433. * Serialize this manager to a JSON object
  88434. * @param name defines the property name to store this manager
  88435. * @returns a JSON representation of this manager
  88436. */
  88437. abstract serialize(name: string): any;
  88438. /**
  88439. * Registers an action to this action manager
  88440. * @param action defines the action to be registered
  88441. * @return the action amended (prepared) after registration
  88442. */
  88443. abstract registerAction(action: IAction): Nullable<IAction>;
  88444. /**
  88445. * Unregisters an action to this action manager
  88446. * @param action defines the action to be unregistered
  88447. * @return a boolean indicating whether the action has been unregistered
  88448. */
  88449. abstract unregisterAction(action: IAction): Boolean;
  88450. /**
  88451. * Does exist one action manager with at least one trigger
  88452. **/
  88453. static readonly HasTriggers: boolean;
  88454. /**
  88455. * Does exist one action manager with at least one pick trigger
  88456. **/
  88457. static readonly HasPickTriggers: boolean;
  88458. /**
  88459. * Does exist one action manager that handles actions of a given trigger
  88460. * @param trigger defines the trigger to be tested
  88461. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  88462. **/
  88463. static HasSpecificTrigger(trigger: number): boolean;
  88464. }
  88465. }
  88466. declare module BABYLON {
  88467. /**
  88468. * Defines how a node can be built from a string name.
  88469. */
  88470. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  88471. /**
  88472. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  88473. */
  88474. export class Node implements IBehaviorAware<Node> {
  88475. /** @hidden */
  88476. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  88477. private static _NodeConstructors;
  88478. /**
  88479. * Add a new node constructor
  88480. * @param type defines the type name of the node to construct
  88481. * @param constructorFunc defines the constructor function
  88482. */
  88483. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  88484. /**
  88485. * Returns a node constructor based on type name
  88486. * @param type defines the type name
  88487. * @param name defines the new node name
  88488. * @param scene defines the hosting scene
  88489. * @param options defines optional options to transmit to constructors
  88490. * @returns the new constructor or null
  88491. */
  88492. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  88493. /**
  88494. * Gets or sets the name of the node
  88495. */
  88496. name: string;
  88497. /**
  88498. * Gets or sets the id of the node
  88499. */
  88500. id: string;
  88501. /**
  88502. * Gets or sets the unique id of the node
  88503. */
  88504. uniqueId: number;
  88505. /**
  88506. * Gets or sets a string used to store user defined state for the node
  88507. */
  88508. state: string;
  88509. /**
  88510. * Gets or sets an object used to store user defined information for the node
  88511. */
  88512. metadata: any;
  88513. /**
  88514. * For internal use only. Please do not use.
  88515. */
  88516. reservedDataStore: any;
  88517. /**
  88518. * List of inspectable custom properties (used by the Inspector)
  88519. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88520. */
  88521. inspectableCustomProperties: IInspectable[];
  88522. /**
  88523. * Gets or sets a boolean used to define if the node must be serialized
  88524. */
  88525. doNotSerialize: boolean;
  88526. /** @hidden */
  88527. _isDisposed: boolean;
  88528. /**
  88529. * Gets a list of Animations associated with the node
  88530. */
  88531. animations: Animation[];
  88532. protected _ranges: {
  88533. [name: string]: Nullable<AnimationRange>;
  88534. };
  88535. /**
  88536. * Callback raised when the node is ready to be used
  88537. */
  88538. onReady: Nullable<(node: Node) => void>;
  88539. private _isEnabled;
  88540. private _isParentEnabled;
  88541. private _isReady;
  88542. /** @hidden */
  88543. _currentRenderId: number;
  88544. private _parentUpdateId;
  88545. /** @hidden */
  88546. _childUpdateId: number;
  88547. /** @hidden */
  88548. _waitingParentId: Nullable<string>;
  88549. /** @hidden */
  88550. _scene: Scene;
  88551. /** @hidden */
  88552. _cache: any;
  88553. private _parentNode;
  88554. private _children;
  88555. /** @hidden */
  88556. _worldMatrix: Matrix;
  88557. /** @hidden */
  88558. _worldMatrixDeterminant: number;
  88559. /** @hidden */
  88560. _worldMatrixDeterminantIsDirty: boolean;
  88561. /** @hidden */
  88562. private _sceneRootNodesIndex;
  88563. /**
  88564. * Gets a boolean indicating if the node has been disposed
  88565. * @returns true if the node was disposed
  88566. */
  88567. isDisposed(): boolean;
  88568. /**
  88569. * Gets or sets the parent of the node (without keeping the current position in the scene)
  88570. * @see https://doc.babylonjs.com/how_to/parenting
  88571. */
  88572. parent: Nullable<Node>;
  88573. private addToSceneRootNodes;
  88574. private removeFromSceneRootNodes;
  88575. private _animationPropertiesOverride;
  88576. /**
  88577. * Gets or sets the animation properties override
  88578. */
  88579. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88580. /**
  88581. * Gets a string idenfifying the name of the class
  88582. * @returns "Node" string
  88583. */
  88584. getClassName(): string;
  88585. /** @hidden */
  88586. readonly _isNode: boolean;
  88587. /**
  88588. * An event triggered when the mesh is disposed
  88589. */
  88590. onDisposeObservable: Observable<Node>;
  88591. private _onDisposeObserver;
  88592. /**
  88593. * Sets a callback that will be raised when the node will be disposed
  88594. */
  88595. onDispose: () => void;
  88596. /**
  88597. * Creates a new Node
  88598. * @param name the name and id to be given to this node
  88599. * @param scene the scene this node will be added to
  88600. * @param addToRootNodes the node will be added to scene.rootNodes
  88601. */
  88602. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  88603. /**
  88604. * Gets the scene of the node
  88605. * @returns a scene
  88606. */
  88607. getScene(): Scene;
  88608. /**
  88609. * Gets the engine of the node
  88610. * @returns a Engine
  88611. */
  88612. getEngine(): Engine;
  88613. private _behaviors;
  88614. /**
  88615. * Attach a behavior to the node
  88616. * @see http://doc.babylonjs.com/features/behaviour
  88617. * @param behavior defines the behavior to attach
  88618. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  88619. * @returns the current Node
  88620. */
  88621. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  88622. /**
  88623. * Remove an attached behavior
  88624. * @see http://doc.babylonjs.com/features/behaviour
  88625. * @param behavior defines the behavior to attach
  88626. * @returns the current Node
  88627. */
  88628. removeBehavior(behavior: Behavior<Node>): Node;
  88629. /**
  88630. * Gets the list of attached behaviors
  88631. * @see http://doc.babylonjs.com/features/behaviour
  88632. */
  88633. readonly behaviors: Behavior<Node>[];
  88634. /**
  88635. * Gets an attached behavior by name
  88636. * @param name defines the name of the behavior to look for
  88637. * @see http://doc.babylonjs.com/features/behaviour
  88638. * @returns null if behavior was not found else the requested behavior
  88639. */
  88640. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  88641. /**
  88642. * Returns the latest update of the World matrix
  88643. * @returns a Matrix
  88644. */
  88645. getWorldMatrix(): Matrix;
  88646. /** @hidden */
  88647. _getWorldMatrixDeterminant(): number;
  88648. /**
  88649. * Returns directly the latest state of the mesh World matrix.
  88650. * A Matrix is returned.
  88651. */
  88652. readonly worldMatrixFromCache: Matrix;
  88653. /** @hidden */
  88654. _initCache(): void;
  88655. /** @hidden */
  88656. updateCache(force?: boolean): void;
  88657. /** @hidden */
  88658. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  88659. /** @hidden */
  88660. _updateCache(ignoreParentClass?: boolean): void;
  88661. /** @hidden */
  88662. _isSynchronized(): boolean;
  88663. /** @hidden */
  88664. _markSyncedWithParent(): void;
  88665. /** @hidden */
  88666. isSynchronizedWithParent(): boolean;
  88667. /** @hidden */
  88668. isSynchronized(): boolean;
  88669. /**
  88670. * Is this node ready to be used/rendered
  88671. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88672. * @return true if the node is ready
  88673. */
  88674. isReady(completeCheck?: boolean): boolean;
  88675. /**
  88676. * Is this node enabled?
  88677. * 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
  88678. * @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
  88679. * @return whether this node (and its parent) is enabled
  88680. */
  88681. isEnabled(checkAncestors?: boolean): boolean;
  88682. /** @hidden */
  88683. protected _syncParentEnabledState(): void;
  88684. /**
  88685. * Set the enabled state of this node
  88686. * @param value defines the new enabled state
  88687. */
  88688. setEnabled(value: boolean): void;
  88689. /**
  88690. * Is this node a descendant of the given node?
  88691. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  88692. * @param ancestor defines the parent node to inspect
  88693. * @returns a boolean indicating if this node is a descendant of the given node
  88694. */
  88695. isDescendantOf(ancestor: Node): boolean;
  88696. /** @hidden */
  88697. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  88698. /**
  88699. * Will return all nodes that have this node as ascendant
  88700. * @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
  88701. * @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
  88702. * @return all children nodes of all types
  88703. */
  88704. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  88705. /**
  88706. * Get all child-meshes of this node
  88707. * @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)
  88708. * @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
  88709. * @returns an array of AbstractMesh
  88710. */
  88711. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  88712. /**
  88713. * Get all direct children of this node
  88714. * @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
  88715. * @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)
  88716. * @returns an array of Node
  88717. */
  88718. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  88719. /** @hidden */
  88720. _setReady(state: boolean): void;
  88721. /**
  88722. * Get an animation by name
  88723. * @param name defines the name of the animation to look for
  88724. * @returns null if not found else the requested animation
  88725. */
  88726. getAnimationByName(name: string): Nullable<Animation>;
  88727. /**
  88728. * Creates an animation range for this node
  88729. * @param name defines the name of the range
  88730. * @param from defines the starting key
  88731. * @param to defines the end key
  88732. */
  88733. createAnimationRange(name: string, from: number, to: number): void;
  88734. /**
  88735. * Delete a specific animation range
  88736. * @param name defines the name of the range to delete
  88737. * @param deleteFrames defines if animation frames from the range must be deleted as well
  88738. */
  88739. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88740. /**
  88741. * Get an animation range by name
  88742. * @param name defines the name of the animation range to look for
  88743. * @returns null if not found else the requested animation range
  88744. */
  88745. getAnimationRange(name: string): Nullable<AnimationRange>;
  88746. /**
  88747. * Gets the list of all animation ranges defined on this node
  88748. * @returns an array
  88749. */
  88750. getAnimationRanges(): Nullable<AnimationRange>[];
  88751. /**
  88752. * Will start the animation sequence
  88753. * @param name defines the range frames for animation sequence
  88754. * @param loop defines if the animation should loop (false by default)
  88755. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  88756. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88757. * @returns the object created for this animation. If range does not exist, it will return null
  88758. */
  88759. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88760. /**
  88761. * Serialize animation ranges into a JSON compatible object
  88762. * @returns serialization object
  88763. */
  88764. serializeAnimationRanges(): any;
  88765. /**
  88766. * Computes the world matrix of the node
  88767. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88768. * @returns the world matrix
  88769. */
  88770. computeWorldMatrix(force?: boolean): Matrix;
  88771. /**
  88772. * Releases resources associated with this node.
  88773. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88774. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88775. */
  88776. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88777. /**
  88778. * Parse animation range data from a serialization object and store them into a given node
  88779. * @param node defines where to store the animation ranges
  88780. * @param parsedNode defines the serialization object to read data from
  88781. * @param scene defines the hosting scene
  88782. */
  88783. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88784. /**
  88785. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88786. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88787. * @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
  88788. * @returns the new bounding vectors
  88789. */
  88790. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88791. min: Vector3;
  88792. max: Vector3;
  88793. };
  88794. }
  88795. }
  88796. declare module BABYLON {
  88797. /**
  88798. * @hidden
  88799. */
  88800. export class _IAnimationState {
  88801. key: number;
  88802. repeatCount: number;
  88803. workValue?: any;
  88804. loopMode?: number;
  88805. offsetValue?: any;
  88806. highLimitValue?: any;
  88807. }
  88808. /**
  88809. * Class used to store any kind of animation
  88810. */
  88811. export class Animation {
  88812. /**Name of the animation */
  88813. name: string;
  88814. /**Property to animate */
  88815. targetProperty: string;
  88816. /**The frames per second of the animation */
  88817. framePerSecond: number;
  88818. /**The data type of the animation */
  88819. dataType: number;
  88820. /**The loop mode of the animation */
  88821. loopMode?: number | undefined;
  88822. /**Specifies if blending should be enabled */
  88823. enableBlending?: boolean | undefined;
  88824. /**
  88825. * Use matrix interpolation instead of using direct key value when animating matrices
  88826. */
  88827. static AllowMatricesInterpolation: boolean;
  88828. /**
  88829. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88830. */
  88831. static AllowMatrixDecomposeForInterpolation: boolean;
  88832. /**
  88833. * Stores the key frames of the animation
  88834. */
  88835. private _keys;
  88836. /**
  88837. * Stores the easing function of the animation
  88838. */
  88839. private _easingFunction;
  88840. /**
  88841. * @hidden Internal use only
  88842. */
  88843. _runtimeAnimations: RuntimeAnimation[];
  88844. /**
  88845. * The set of event that will be linked to this animation
  88846. */
  88847. private _events;
  88848. /**
  88849. * Stores an array of target property paths
  88850. */
  88851. targetPropertyPath: string[];
  88852. /**
  88853. * Stores the blending speed of the animation
  88854. */
  88855. blendingSpeed: number;
  88856. /**
  88857. * Stores the animation ranges for the animation
  88858. */
  88859. private _ranges;
  88860. /**
  88861. * @hidden Internal use
  88862. */
  88863. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88864. /**
  88865. * Sets up an animation
  88866. * @param property The property to animate
  88867. * @param animationType The animation type to apply
  88868. * @param framePerSecond The frames per second of the animation
  88869. * @param easingFunction The easing function used in the animation
  88870. * @returns The created animation
  88871. */
  88872. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88873. /**
  88874. * Create and start an animation on a node
  88875. * @param name defines the name of the global animation that will be run on all nodes
  88876. * @param node defines the root node where the animation will take place
  88877. * @param targetProperty defines property to animate
  88878. * @param framePerSecond defines the number of frame per second yo use
  88879. * @param totalFrame defines the number of frames in total
  88880. * @param from defines the initial value
  88881. * @param to defines the final value
  88882. * @param loopMode defines which loop mode you want to use (off by default)
  88883. * @param easingFunction defines the easing function to use (linear by default)
  88884. * @param onAnimationEnd defines the callback to call when animation end
  88885. * @returns the animatable created for this animation
  88886. */
  88887. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88888. /**
  88889. * Create and start an animation on a node and its descendants
  88890. * @param name defines the name of the global animation that will be run on all nodes
  88891. * @param node defines the root node where the animation will take place
  88892. * @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
  88893. * @param targetProperty defines property to animate
  88894. * @param framePerSecond defines the number of frame per second to use
  88895. * @param totalFrame defines the number of frames in total
  88896. * @param from defines the initial value
  88897. * @param to defines the final value
  88898. * @param loopMode defines which loop mode you want to use (off by default)
  88899. * @param easingFunction defines the easing function to use (linear by default)
  88900. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88901. * @returns the list of animatables created for all nodes
  88902. * @example https://www.babylonjs-playground.com/#MH0VLI
  88903. */
  88904. 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[]>;
  88905. /**
  88906. * Creates a new animation, merges it with the existing animations and starts it
  88907. * @param name Name of the animation
  88908. * @param node Node which contains the scene that begins the animations
  88909. * @param targetProperty Specifies which property to animate
  88910. * @param framePerSecond The frames per second of the animation
  88911. * @param totalFrame The total number of frames
  88912. * @param from The frame at the beginning of the animation
  88913. * @param to The frame at the end of the animation
  88914. * @param loopMode Specifies the loop mode of the animation
  88915. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88916. * @param onAnimationEnd Callback to run once the animation is complete
  88917. * @returns Nullable animation
  88918. */
  88919. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88920. /**
  88921. * Transition property of an host to the target Value
  88922. * @param property The property to transition
  88923. * @param targetValue The target Value of the property
  88924. * @param host The object where the property to animate belongs
  88925. * @param scene Scene used to run the animation
  88926. * @param frameRate Framerate (in frame/s) to use
  88927. * @param transition The transition type we want to use
  88928. * @param duration The duration of the animation, in milliseconds
  88929. * @param onAnimationEnd Callback trigger at the end of the animation
  88930. * @returns Nullable animation
  88931. */
  88932. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88933. /**
  88934. * Return the array of runtime animations currently using this animation
  88935. */
  88936. readonly runtimeAnimations: RuntimeAnimation[];
  88937. /**
  88938. * Specifies if any of the runtime animations are currently running
  88939. */
  88940. readonly hasRunningRuntimeAnimations: boolean;
  88941. /**
  88942. * Initializes the animation
  88943. * @param name Name of the animation
  88944. * @param targetProperty Property to animate
  88945. * @param framePerSecond The frames per second of the animation
  88946. * @param dataType The data type of the animation
  88947. * @param loopMode The loop mode of the animation
  88948. * @param enableBlending Specifies if blending should be enabled
  88949. */
  88950. constructor(
  88951. /**Name of the animation */
  88952. name: string,
  88953. /**Property to animate */
  88954. targetProperty: string,
  88955. /**The frames per second of the animation */
  88956. framePerSecond: number,
  88957. /**The data type of the animation */
  88958. dataType: number,
  88959. /**The loop mode of the animation */
  88960. loopMode?: number | undefined,
  88961. /**Specifies if blending should be enabled */
  88962. enableBlending?: boolean | undefined);
  88963. /**
  88964. * Converts the animation to a string
  88965. * @param fullDetails support for multiple levels of logging within scene loading
  88966. * @returns String form of the animation
  88967. */
  88968. toString(fullDetails?: boolean): string;
  88969. /**
  88970. * Add an event to this animation
  88971. * @param event Event to add
  88972. */
  88973. addEvent(event: AnimationEvent): void;
  88974. /**
  88975. * Remove all events found at the given frame
  88976. * @param frame The frame to remove events from
  88977. */
  88978. removeEvents(frame: number): void;
  88979. /**
  88980. * Retrieves all the events from the animation
  88981. * @returns Events from the animation
  88982. */
  88983. getEvents(): AnimationEvent[];
  88984. /**
  88985. * Creates an animation range
  88986. * @param name Name of the animation range
  88987. * @param from Starting frame of the animation range
  88988. * @param to Ending frame of the animation
  88989. */
  88990. createRange(name: string, from: number, to: number): void;
  88991. /**
  88992. * Deletes an animation range by name
  88993. * @param name Name of the animation range to delete
  88994. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88995. */
  88996. deleteRange(name: string, deleteFrames?: boolean): void;
  88997. /**
  88998. * Gets the animation range by name, or null if not defined
  88999. * @param name Name of the animation range
  89000. * @returns Nullable animation range
  89001. */
  89002. getRange(name: string): Nullable<AnimationRange>;
  89003. /**
  89004. * Gets the key frames from the animation
  89005. * @returns The key frames of the animation
  89006. */
  89007. getKeys(): Array<IAnimationKey>;
  89008. /**
  89009. * Gets the highest frame rate of the animation
  89010. * @returns Highest frame rate of the animation
  89011. */
  89012. getHighestFrame(): number;
  89013. /**
  89014. * Gets the easing function of the animation
  89015. * @returns Easing function of the animation
  89016. */
  89017. getEasingFunction(): IEasingFunction;
  89018. /**
  89019. * Sets the easing function of the animation
  89020. * @param easingFunction A custom mathematical formula for animation
  89021. */
  89022. setEasingFunction(easingFunction: EasingFunction): void;
  89023. /**
  89024. * Interpolates a scalar linearly
  89025. * @param startValue Start value of the animation curve
  89026. * @param endValue End value of the animation curve
  89027. * @param gradient Scalar amount to interpolate
  89028. * @returns Interpolated scalar value
  89029. */
  89030. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  89031. /**
  89032. * Interpolates a scalar cubically
  89033. * @param startValue Start value of the animation curve
  89034. * @param outTangent End tangent of the animation
  89035. * @param endValue End value of the animation curve
  89036. * @param inTangent Start tangent of the animation curve
  89037. * @param gradient Scalar amount to interpolate
  89038. * @returns Interpolated scalar value
  89039. */
  89040. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  89041. /**
  89042. * Interpolates a quaternion using a spherical linear interpolation
  89043. * @param startValue Start value of the animation curve
  89044. * @param endValue End value of the animation curve
  89045. * @param gradient Scalar amount to interpolate
  89046. * @returns Interpolated quaternion value
  89047. */
  89048. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  89049. /**
  89050. * Interpolates a quaternion cubically
  89051. * @param startValue Start value of the animation curve
  89052. * @param outTangent End tangent of the animation curve
  89053. * @param endValue End value of the animation curve
  89054. * @param inTangent Start tangent of the animation curve
  89055. * @param gradient Scalar amount to interpolate
  89056. * @returns Interpolated quaternion value
  89057. */
  89058. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  89059. /**
  89060. * Interpolates a Vector3 linearl
  89061. * @param startValue Start value of the animation curve
  89062. * @param endValue End value of the animation curve
  89063. * @param gradient Scalar amount to interpolate
  89064. * @returns Interpolated scalar value
  89065. */
  89066. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  89067. /**
  89068. * Interpolates a Vector3 cubically
  89069. * @param startValue Start value of the animation curve
  89070. * @param outTangent End tangent of the animation
  89071. * @param endValue End value of the animation curve
  89072. * @param inTangent Start tangent of the animation curve
  89073. * @param gradient Scalar amount to interpolate
  89074. * @returns InterpolatedVector3 value
  89075. */
  89076. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  89077. /**
  89078. * Interpolates a Vector2 linearly
  89079. * @param startValue Start value of the animation curve
  89080. * @param endValue End value of the animation curve
  89081. * @param gradient Scalar amount to interpolate
  89082. * @returns Interpolated Vector2 value
  89083. */
  89084. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  89085. /**
  89086. * Interpolates a Vector2 cubically
  89087. * @param startValue Start value of the animation curve
  89088. * @param outTangent End tangent of the animation
  89089. * @param endValue End value of the animation curve
  89090. * @param inTangent Start tangent of the animation curve
  89091. * @param gradient Scalar amount to interpolate
  89092. * @returns Interpolated Vector2 value
  89093. */
  89094. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  89095. /**
  89096. * Interpolates a size linearly
  89097. * @param startValue Start value of the animation curve
  89098. * @param endValue End value of the animation curve
  89099. * @param gradient Scalar amount to interpolate
  89100. * @returns Interpolated Size value
  89101. */
  89102. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  89103. /**
  89104. * Interpolates a Color3 linearly
  89105. * @param startValue Start value of the animation curve
  89106. * @param endValue End value of the animation curve
  89107. * @param gradient Scalar amount to interpolate
  89108. * @returns Interpolated Color3 value
  89109. */
  89110. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  89111. /**
  89112. * @hidden Internal use only
  89113. */
  89114. _getKeyValue(value: any): any;
  89115. /**
  89116. * @hidden Internal use only
  89117. */
  89118. _interpolate(currentFrame: number, state: _IAnimationState): any;
  89119. /**
  89120. * Defines the function to use to interpolate matrices
  89121. * @param startValue defines the start matrix
  89122. * @param endValue defines the end matrix
  89123. * @param gradient defines the gradient between both matrices
  89124. * @param result defines an optional target matrix where to store the interpolation
  89125. * @returns the interpolated matrix
  89126. */
  89127. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  89128. /**
  89129. * Makes a copy of the animation
  89130. * @returns Cloned animation
  89131. */
  89132. clone(): Animation;
  89133. /**
  89134. * Sets the key frames of the animation
  89135. * @param values The animation key frames to set
  89136. */
  89137. setKeys(values: Array<IAnimationKey>): void;
  89138. /**
  89139. * Serializes the animation to an object
  89140. * @returns Serialized object
  89141. */
  89142. serialize(): any;
  89143. /**
  89144. * Float animation type
  89145. */
  89146. private static _ANIMATIONTYPE_FLOAT;
  89147. /**
  89148. * Vector3 animation type
  89149. */
  89150. private static _ANIMATIONTYPE_VECTOR3;
  89151. /**
  89152. * Quaternion animation type
  89153. */
  89154. private static _ANIMATIONTYPE_QUATERNION;
  89155. /**
  89156. * Matrix animation type
  89157. */
  89158. private static _ANIMATIONTYPE_MATRIX;
  89159. /**
  89160. * Color3 animation type
  89161. */
  89162. private static _ANIMATIONTYPE_COLOR3;
  89163. /**
  89164. * Vector2 animation type
  89165. */
  89166. private static _ANIMATIONTYPE_VECTOR2;
  89167. /**
  89168. * Size animation type
  89169. */
  89170. private static _ANIMATIONTYPE_SIZE;
  89171. /**
  89172. * Relative Loop Mode
  89173. */
  89174. private static _ANIMATIONLOOPMODE_RELATIVE;
  89175. /**
  89176. * Cycle Loop Mode
  89177. */
  89178. private static _ANIMATIONLOOPMODE_CYCLE;
  89179. /**
  89180. * Constant Loop Mode
  89181. */
  89182. private static _ANIMATIONLOOPMODE_CONSTANT;
  89183. /**
  89184. * Get the float animation type
  89185. */
  89186. static readonly ANIMATIONTYPE_FLOAT: number;
  89187. /**
  89188. * Get the Vector3 animation type
  89189. */
  89190. static readonly ANIMATIONTYPE_VECTOR3: number;
  89191. /**
  89192. * Get the Vector2 animation type
  89193. */
  89194. static readonly ANIMATIONTYPE_VECTOR2: number;
  89195. /**
  89196. * Get the Size animation type
  89197. */
  89198. static readonly ANIMATIONTYPE_SIZE: number;
  89199. /**
  89200. * Get the Quaternion animation type
  89201. */
  89202. static readonly ANIMATIONTYPE_QUATERNION: number;
  89203. /**
  89204. * Get the Matrix animation type
  89205. */
  89206. static readonly ANIMATIONTYPE_MATRIX: number;
  89207. /**
  89208. * Get the Color3 animation type
  89209. */
  89210. static readonly ANIMATIONTYPE_COLOR3: number;
  89211. /**
  89212. * Get the Relative Loop Mode
  89213. */
  89214. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  89215. /**
  89216. * Get the Cycle Loop Mode
  89217. */
  89218. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  89219. /**
  89220. * Get the Constant Loop Mode
  89221. */
  89222. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  89223. /** @hidden */
  89224. static _UniversalLerp(left: any, right: any, amount: number): any;
  89225. /**
  89226. * Parses an animation object and creates an animation
  89227. * @param parsedAnimation Parsed animation object
  89228. * @returns Animation object
  89229. */
  89230. static Parse(parsedAnimation: any): Animation;
  89231. /**
  89232. * Appends the serialized animations from the source animations
  89233. * @param source Source containing the animations
  89234. * @param destination Target to store the animations
  89235. */
  89236. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89237. }
  89238. }
  89239. declare module BABYLON {
  89240. /**
  89241. * Base class of all the textures in babylon.
  89242. * It groups all the common properties the materials, post process, lights... might need
  89243. * in order to make a correct use of the texture.
  89244. */
  89245. export class BaseTexture implements IAnimatable {
  89246. /**
  89247. * Default anisotropic filtering level for the application.
  89248. * It is set to 4 as a good tradeoff between perf and quality.
  89249. */
  89250. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  89251. /**
  89252. * Gets or sets the unique id of the texture
  89253. */
  89254. uniqueId: number;
  89255. /**
  89256. * Define the name of the texture.
  89257. */
  89258. name: string;
  89259. /**
  89260. * Gets or sets an object used to store user defined information.
  89261. */
  89262. metadata: any;
  89263. /**
  89264. * For internal use only. Please do not use.
  89265. */
  89266. reservedDataStore: any;
  89267. private _hasAlpha;
  89268. /**
  89269. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  89270. */
  89271. hasAlpha: boolean;
  89272. /**
  89273. * Defines if the alpha value should be determined via the rgb values.
  89274. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  89275. */
  89276. getAlphaFromRGB: boolean;
  89277. /**
  89278. * Intensity or strength of the texture.
  89279. * It is commonly used by materials to fine tune the intensity of the texture
  89280. */
  89281. level: number;
  89282. /**
  89283. * Define the UV chanel to use starting from 0 and defaulting to 0.
  89284. * This is part of the texture as textures usually maps to one uv set.
  89285. */
  89286. coordinatesIndex: number;
  89287. private _coordinatesMode;
  89288. /**
  89289. * How a texture is mapped.
  89290. *
  89291. * | Value | Type | Description |
  89292. * | ----- | ----------------------------------- | ----------- |
  89293. * | 0 | EXPLICIT_MODE | |
  89294. * | 1 | SPHERICAL_MODE | |
  89295. * | 2 | PLANAR_MODE | |
  89296. * | 3 | CUBIC_MODE | |
  89297. * | 4 | PROJECTION_MODE | |
  89298. * | 5 | SKYBOX_MODE | |
  89299. * | 6 | INVCUBIC_MODE | |
  89300. * | 7 | EQUIRECTANGULAR_MODE | |
  89301. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  89302. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  89303. */
  89304. coordinatesMode: number;
  89305. /**
  89306. * | Value | Type | Description |
  89307. * | ----- | ------------------ | ----------- |
  89308. * | 0 | CLAMP_ADDRESSMODE | |
  89309. * | 1 | WRAP_ADDRESSMODE | |
  89310. * | 2 | MIRROR_ADDRESSMODE | |
  89311. */
  89312. wrapU: number;
  89313. /**
  89314. * | Value | Type | Description |
  89315. * | ----- | ------------------ | ----------- |
  89316. * | 0 | CLAMP_ADDRESSMODE | |
  89317. * | 1 | WRAP_ADDRESSMODE | |
  89318. * | 2 | MIRROR_ADDRESSMODE | |
  89319. */
  89320. wrapV: number;
  89321. /**
  89322. * | Value | Type | Description |
  89323. * | ----- | ------------------ | ----------- |
  89324. * | 0 | CLAMP_ADDRESSMODE | |
  89325. * | 1 | WRAP_ADDRESSMODE | |
  89326. * | 2 | MIRROR_ADDRESSMODE | |
  89327. */
  89328. wrapR: number;
  89329. /**
  89330. * With compliant hardware and browser (supporting anisotropic filtering)
  89331. * this defines the level of anisotropic filtering in the texture.
  89332. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  89333. */
  89334. anisotropicFilteringLevel: number;
  89335. /**
  89336. * Define if the texture is a cube texture or if false a 2d texture.
  89337. */
  89338. isCube: boolean;
  89339. /**
  89340. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  89341. */
  89342. is3D: boolean;
  89343. /**
  89344. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  89345. * HDR texture are usually stored in linear space.
  89346. * This only impacts the PBR and Background materials
  89347. */
  89348. gammaSpace: boolean;
  89349. /**
  89350. * Gets whether or not the texture contains RGBD data.
  89351. */
  89352. readonly isRGBD: boolean;
  89353. /**
  89354. * Is Z inverted in the texture (useful in a cube texture).
  89355. */
  89356. invertZ: boolean;
  89357. /**
  89358. * Are mip maps generated for this texture or not.
  89359. */
  89360. readonly noMipmap: boolean;
  89361. /**
  89362. * @hidden
  89363. */
  89364. lodLevelInAlpha: boolean;
  89365. /**
  89366. * With prefiltered texture, defined the offset used during the prefiltering steps.
  89367. */
  89368. lodGenerationOffset: number;
  89369. /**
  89370. * With prefiltered texture, defined the scale used during the prefiltering steps.
  89371. */
  89372. lodGenerationScale: number;
  89373. /**
  89374. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  89375. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  89376. * average roughness values.
  89377. */
  89378. linearSpecularLOD: boolean;
  89379. /**
  89380. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  89381. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  89382. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  89383. */
  89384. irradianceTexture: Nullable<BaseTexture>;
  89385. /**
  89386. * Define if the texture is a render target.
  89387. */
  89388. isRenderTarget: boolean;
  89389. /**
  89390. * Define the unique id of the texture in the scene.
  89391. */
  89392. readonly uid: string;
  89393. /**
  89394. * Return a string representation of the texture.
  89395. * @returns the texture as a string
  89396. */
  89397. toString(): string;
  89398. /**
  89399. * Get the class name of the texture.
  89400. * @returns "BaseTexture"
  89401. */
  89402. getClassName(): string;
  89403. /**
  89404. * Define the list of animation attached to the texture.
  89405. */
  89406. animations: Animation[];
  89407. /**
  89408. * An event triggered when the texture is disposed.
  89409. */
  89410. onDisposeObservable: Observable<BaseTexture>;
  89411. private _onDisposeObserver;
  89412. /**
  89413. * Callback triggered when the texture has been disposed.
  89414. * Kept for back compatibility, you can use the onDisposeObservable instead.
  89415. */
  89416. onDispose: () => void;
  89417. /**
  89418. * Define the current state of the loading sequence when in delayed load mode.
  89419. */
  89420. delayLoadState: number;
  89421. private _scene;
  89422. /** @hidden */
  89423. _texture: Nullable<InternalTexture>;
  89424. private _uid;
  89425. /**
  89426. * Define if the texture is preventinga material to render or not.
  89427. * If not and the texture is not ready, the engine will use a default black texture instead.
  89428. */
  89429. readonly isBlocking: boolean;
  89430. /**
  89431. * Instantiates a new BaseTexture.
  89432. * Base class of all the textures in babylon.
  89433. * It groups all the common properties the materials, post process, lights... might need
  89434. * in order to make a correct use of the texture.
  89435. * @param scene Define the scene the texture blongs to
  89436. */
  89437. constructor(scene: Nullable<Scene>);
  89438. /**
  89439. * Get the scene the texture belongs to.
  89440. * @returns the scene or null if undefined
  89441. */
  89442. getScene(): Nullable<Scene>;
  89443. /**
  89444. * Get the texture transform matrix used to offset tile the texture for istance.
  89445. * @returns the transformation matrix
  89446. */
  89447. getTextureMatrix(): Matrix;
  89448. /**
  89449. * Get the texture reflection matrix used to rotate/transform the reflection.
  89450. * @returns the reflection matrix
  89451. */
  89452. getReflectionTextureMatrix(): Matrix;
  89453. /**
  89454. * Get the underlying lower level texture from Babylon.
  89455. * @returns the insternal texture
  89456. */
  89457. getInternalTexture(): Nullable<InternalTexture>;
  89458. /**
  89459. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89460. * @returns true if ready or not blocking
  89461. */
  89462. isReadyOrNotBlocking(): boolean;
  89463. /**
  89464. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  89465. * @returns true if fully ready
  89466. */
  89467. isReady(): boolean;
  89468. private _cachedSize;
  89469. /**
  89470. * Get the size of the texture.
  89471. * @returns the texture size.
  89472. */
  89473. getSize(): ISize;
  89474. /**
  89475. * Get the base size of the texture.
  89476. * It can be different from the size if the texture has been resized for POT for instance
  89477. * @returns the base size
  89478. */
  89479. getBaseSize(): ISize;
  89480. /**
  89481. * Update the sampling mode of the texture.
  89482. * Default is Trilinear mode.
  89483. *
  89484. * | Value | Type | Description |
  89485. * | ----- | ------------------ | ----------- |
  89486. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  89487. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  89488. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  89489. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  89490. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  89491. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  89492. * | 7 | NEAREST_LINEAR | |
  89493. * | 8 | NEAREST_NEAREST | |
  89494. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  89495. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  89496. * | 11 | LINEAR_LINEAR | |
  89497. * | 12 | LINEAR_NEAREST | |
  89498. *
  89499. * > _mag_: magnification filter (close to the viewer)
  89500. * > _min_: minification filter (far from the viewer)
  89501. * > _mip_: filter used between mip map levels
  89502. *@param samplingMode Define the new sampling mode of the texture
  89503. */
  89504. updateSamplingMode(samplingMode: number): void;
  89505. /**
  89506. * Scales the texture if is `canRescale()`
  89507. * @param ratio the resize factor we want to use to rescale
  89508. */
  89509. scale(ratio: number): void;
  89510. /**
  89511. * Get if the texture can rescale.
  89512. */
  89513. readonly canRescale: boolean;
  89514. /** @hidden */
  89515. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89516. /** @hidden */
  89517. _rebuild(): void;
  89518. /**
  89519. * Triggers the load sequence in delayed load mode.
  89520. */
  89521. delayLoad(): void;
  89522. /**
  89523. * Clones the texture.
  89524. * @returns the cloned texture
  89525. */
  89526. clone(): Nullable<BaseTexture>;
  89527. /**
  89528. * Get the texture underlying type (INT, FLOAT...)
  89529. */
  89530. readonly textureType: number;
  89531. /**
  89532. * Get the texture underlying format (RGB, RGBA...)
  89533. */
  89534. readonly textureFormat: number;
  89535. /**
  89536. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89537. * This will returns an RGBA array buffer containing either in values (0-255) or
  89538. * float values (0-1) depending of the underlying buffer type.
  89539. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89540. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89541. * @param buffer defines a user defined buffer to fill with data (can be null)
  89542. * @returns The Array buffer containing the pixels data.
  89543. */
  89544. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89545. /**
  89546. * Release and destroy the underlying lower level texture aka internalTexture.
  89547. */
  89548. releaseInternalTexture(): void;
  89549. /**
  89550. * Get the polynomial representation of the texture data.
  89551. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  89552. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  89553. */
  89554. sphericalPolynomial: Nullable<SphericalPolynomial>;
  89555. /** @hidden */
  89556. readonly _lodTextureHigh: Nullable<BaseTexture>;
  89557. /** @hidden */
  89558. readonly _lodTextureMid: Nullable<BaseTexture>;
  89559. /** @hidden */
  89560. readonly _lodTextureLow: Nullable<BaseTexture>;
  89561. /**
  89562. * Dispose the texture and release its associated resources.
  89563. */
  89564. dispose(): void;
  89565. /**
  89566. * Serialize the texture into a JSON representation that can be parsed later on.
  89567. * @returns the JSON representation of the texture
  89568. */
  89569. serialize(): any;
  89570. /**
  89571. * Helper function to be called back once a list of texture contains only ready textures.
  89572. * @param textures Define the list of textures to wait for
  89573. * @param callback Define the callback triggered once the entire list will be ready
  89574. */
  89575. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89576. }
  89577. }
  89578. declare module BABYLON {
  89579. /**
  89580. * Uniform buffer objects.
  89581. *
  89582. * Handles blocks of uniform on the GPU.
  89583. *
  89584. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89585. *
  89586. * For more information, please refer to :
  89587. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89588. */
  89589. export class UniformBuffer {
  89590. private _engine;
  89591. private _buffer;
  89592. private _data;
  89593. private _bufferData;
  89594. private _dynamic?;
  89595. private _uniformLocations;
  89596. private _uniformSizes;
  89597. private _uniformLocationPointer;
  89598. private _needSync;
  89599. private _noUBO;
  89600. private _currentEffect;
  89601. private static _MAX_UNIFORM_SIZE;
  89602. private static _tempBuffer;
  89603. /**
  89604. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89605. * This is dynamic to allow compat with webgl 1 and 2.
  89606. * You will need to pass the name of the uniform as well as the value.
  89607. */
  89608. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89609. /**
  89610. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89611. * This is dynamic to allow compat with webgl 1 and 2.
  89612. * You will need to pass the name of the uniform as well as the value.
  89613. */
  89614. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89615. /**
  89616. * Lambda to Update a single float in a uniform buffer.
  89617. * This is dynamic to allow compat with webgl 1 and 2.
  89618. * You will need to pass the name of the uniform as well as the value.
  89619. */
  89620. updateFloat: (name: string, x: number) => void;
  89621. /**
  89622. * Lambda to Update a vec2 of float in a uniform buffer.
  89623. * This is dynamic to allow compat with webgl 1 and 2.
  89624. * You will need to pass the name of the uniform as well as the value.
  89625. */
  89626. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89627. /**
  89628. * Lambda to Update a vec3 of float in a uniform buffer.
  89629. * This is dynamic to allow compat with webgl 1 and 2.
  89630. * You will need to pass the name of the uniform as well as the value.
  89631. */
  89632. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89633. /**
  89634. * Lambda to Update a vec4 of float in a uniform buffer.
  89635. * This is dynamic to allow compat with webgl 1 and 2.
  89636. * You will need to pass the name of the uniform as well as the value.
  89637. */
  89638. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89639. /**
  89640. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89641. * This is dynamic to allow compat with webgl 1 and 2.
  89642. * You will need to pass the name of the uniform as well as the value.
  89643. */
  89644. updateMatrix: (name: string, mat: Matrix) => void;
  89645. /**
  89646. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89647. * This is dynamic to allow compat with webgl 1 and 2.
  89648. * You will need to pass the name of the uniform as well as the value.
  89649. */
  89650. updateVector3: (name: string, vector: Vector3) => void;
  89651. /**
  89652. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89653. * This is dynamic to allow compat with webgl 1 and 2.
  89654. * You will need to pass the name of the uniform as well as the value.
  89655. */
  89656. updateVector4: (name: string, vector: Vector4) => void;
  89657. /**
  89658. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89659. * This is dynamic to allow compat with webgl 1 and 2.
  89660. * You will need to pass the name of the uniform as well as the value.
  89661. */
  89662. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89663. /**
  89664. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89665. * This is dynamic to allow compat with webgl 1 and 2.
  89666. * You will need to pass the name of the uniform as well as the value.
  89667. */
  89668. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89669. /**
  89670. * Instantiates a new Uniform buffer objects.
  89671. *
  89672. * Handles blocks of uniform on the GPU.
  89673. *
  89674. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89675. *
  89676. * For more information, please refer to :
  89677. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89678. * @param engine Define the engine the buffer is associated with
  89679. * @param data Define the data contained in the buffer
  89680. * @param dynamic Define if the buffer is updatable
  89681. */
  89682. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89683. /**
  89684. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89685. * or just falling back on setUniformXXX calls.
  89686. */
  89687. readonly useUbo: boolean;
  89688. /**
  89689. * Indicates if the WebGL underlying uniform buffer is in sync
  89690. * with the javascript cache data.
  89691. */
  89692. readonly isSync: boolean;
  89693. /**
  89694. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89695. * Also, a dynamic UniformBuffer will disable cache verification and always
  89696. * update the underlying WebGL uniform buffer to the GPU.
  89697. * @returns if Dynamic, otherwise false
  89698. */
  89699. isDynamic(): boolean;
  89700. /**
  89701. * The data cache on JS side.
  89702. * @returns the underlying data as a float array
  89703. */
  89704. getData(): Float32Array;
  89705. /**
  89706. * The underlying WebGL Uniform buffer.
  89707. * @returns the webgl buffer
  89708. */
  89709. getBuffer(): Nullable<DataBuffer>;
  89710. /**
  89711. * std140 layout specifies how to align data within an UBO structure.
  89712. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89713. * for specs.
  89714. */
  89715. private _fillAlignment;
  89716. /**
  89717. * Adds an uniform in the buffer.
  89718. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89719. * for the layout to be correct !
  89720. * @param name Name of the uniform, as used in the uniform block in the shader.
  89721. * @param size Data size, or data directly.
  89722. */
  89723. addUniform(name: string, size: number | number[]): void;
  89724. /**
  89725. * Adds a Matrix 4x4 to the uniform buffer.
  89726. * @param name Name of the uniform, as used in the uniform block in the shader.
  89727. * @param mat A 4x4 matrix.
  89728. */
  89729. addMatrix(name: string, mat: Matrix): void;
  89730. /**
  89731. * Adds a vec2 to the uniform buffer.
  89732. * @param name Name of the uniform, as used in the uniform block in the shader.
  89733. * @param x Define the x component value of the vec2
  89734. * @param y Define the y component value of the vec2
  89735. */
  89736. addFloat2(name: string, x: number, y: number): void;
  89737. /**
  89738. * Adds a vec3 to the uniform buffer.
  89739. * @param name Name of the uniform, as used in the uniform block in the shader.
  89740. * @param x Define the x component value of the vec3
  89741. * @param y Define the y component value of the vec3
  89742. * @param z Define the z component value of the vec3
  89743. */
  89744. addFloat3(name: string, x: number, y: number, z: number): void;
  89745. /**
  89746. * Adds a vec3 to the uniform buffer.
  89747. * @param name Name of the uniform, as used in the uniform block in the shader.
  89748. * @param color Define the vec3 from a Color
  89749. */
  89750. addColor3(name: string, color: Color3): void;
  89751. /**
  89752. * Adds a vec4 to the uniform buffer.
  89753. * @param name Name of the uniform, as used in the uniform block in the shader.
  89754. * @param color Define the rgb components from a Color
  89755. * @param alpha Define the a component of the vec4
  89756. */
  89757. addColor4(name: string, color: Color3, alpha: number): void;
  89758. /**
  89759. * Adds a vec3 to the uniform buffer.
  89760. * @param name Name of the uniform, as used in the uniform block in the shader.
  89761. * @param vector Define the vec3 components from a Vector
  89762. */
  89763. addVector3(name: string, vector: Vector3): void;
  89764. /**
  89765. * Adds a Matrix 3x3 to the uniform buffer.
  89766. * @param name Name of the uniform, as used in the uniform block in the shader.
  89767. */
  89768. addMatrix3x3(name: string): void;
  89769. /**
  89770. * Adds a Matrix 2x2 to the uniform buffer.
  89771. * @param name Name of the uniform, as used in the uniform block in the shader.
  89772. */
  89773. addMatrix2x2(name: string): void;
  89774. /**
  89775. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89776. */
  89777. create(): void;
  89778. /** @hidden */
  89779. _rebuild(): void;
  89780. /**
  89781. * Updates the WebGL Uniform Buffer on the GPU.
  89782. * If the `dynamic` flag is set to true, no cache comparison is done.
  89783. * Otherwise, the buffer will be updated only if the cache differs.
  89784. */
  89785. update(): void;
  89786. /**
  89787. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89788. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89789. * @param data Define the flattened data
  89790. * @param size Define the size of the data.
  89791. */
  89792. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89793. private _updateMatrix3x3ForUniform;
  89794. private _updateMatrix3x3ForEffect;
  89795. private _updateMatrix2x2ForEffect;
  89796. private _updateMatrix2x2ForUniform;
  89797. private _updateFloatForEffect;
  89798. private _updateFloatForUniform;
  89799. private _updateFloat2ForEffect;
  89800. private _updateFloat2ForUniform;
  89801. private _updateFloat3ForEffect;
  89802. private _updateFloat3ForUniform;
  89803. private _updateFloat4ForEffect;
  89804. private _updateFloat4ForUniform;
  89805. private _updateMatrixForEffect;
  89806. private _updateMatrixForUniform;
  89807. private _updateVector3ForEffect;
  89808. private _updateVector3ForUniform;
  89809. private _updateVector4ForEffect;
  89810. private _updateVector4ForUniform;
  89811. private _updateColor3ForEffect;
  89812. private _updateColor3ForUniform;
  89813. private _updateColor4ForEffect;
  89814. private _updateColor4ForUniform;
  89815. /**
  89816. * Sets a sampler uniform on the effect.
  89817. * @param name Define the name of the sampler.
  89818. * @param texture Define the texture to set in the sampler
  89819. */
  89820. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89821. /**
  89822. * Directly updates the value of the uniform in the cache AND on the GPU.
  89823. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89824. * @param data Define the flattened data
  89825. */
  89826. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89827. /**
  89828. * Binds this uniform buffer to an effect.
  89829. * @param effect Define the effect to bind the buffer to
  89830. * @param name Name of the uniform block in the shader.
  89831. */
  89832. bindToEffect(effect: Effect, name: string): void;
  89833. /**
  89834. * Disposes the uniform buffer.
  89835. */
  89836. dispose(): void;
  89837. }
  89838. }
  89839. declare module BABYLON {
  89840. /**
  89841. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89843. */
  89844. export class Analyser {
  89845. /**
  89846. * Gets or sets the smoothing
  89847. * @ignorenaming
  89848. */
  89849. SMOOTHING: number;
  89850. /**
  89851. * Gets or sets the FFT table size
  89852. * @ignorenaming
  89853. */
  89854. FFT_SIZE: number;
  89855. /**
  89856. * Gets or sets the bar graph amplitude
  89857. * @ignorenaming
  89858. */
  89859. BARGRAPHAMPLITUDE: number;
  89860. /**
  89861. * Gets or sets the position of the debug canvas
  89862. * @ignorenaming
  89863. */
  89864. DEBUGCANVASPOS: {
  89865. x: number;
  89866. y: number;
  89867. };
  89868. /**
  89869. * Gets or sets the debug canvas size
  89870. * @ignorenaming
  89871. */
  89872. DEBUGCANVASSIZE: {
  89873. width: number;
  89874. height: number;
  89875. };
  89876. private _byteFreqs;
  89877. private _byteTime;
  89878. private _floatFreqs;
  89879. private _webAudioAnalyser;
  89880. private _debugCanvas;
  89881. private _debugCanvasContext;
  89882. private _scene;
  89883. private _registerFunc;
  89884. private _audioEngine;
  89885. /**
  89886. * Creates a new analyser
  89887. * @param scene defines hosting scene
  89888. */
  89889. constructor(scene: Scene);
  89890. /**
  89891. * Get the number of data values you will have to play with for the visualization
  89892. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89893. * @returns a number
  89894. */
  89895. getFrequencyBinCount(): number;
  89896. /**
  89897. * Gets the current frequency data as a byte array
  89898. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89899. * @returns a Uint8Array
  89900. */
  89901. getByteFrequencyData(): Uint8Array;
  89902. /**
  89903. * Gets the current waveform as a byte array
  89904. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89905. * @returns a Uint8Array
  89906. */
  89907. getByteTimeDomainData(): Uint8Array;
  89908. /**
  89909. * Gets the current frequency data as a float array
  89910. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89911. * @returns a Float32Array
  89912. */
  89913. getFloatFrequencyData(): Float32Array;
  89914. /**
  89915. * Renders the debug canvas
  89916. */
  89917. drawDebugCanvas(): void;
  89918. /**
  89919. * Stops rendering the debug canvas and removes it
  89920. */
  89921. stopDebugCanvas(): void;
  89922. /**
  89923. * Connects two audio nodes
  89924. * @param inputAudioNode defines first node to connect
  89925. * @param outputAudioNode defines second node to connect
  89926. */
  89927. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89928. /**
  89929. * Releases all associated resources
  89930. */
  89931. dispose(): void;
  89932. }
  89933. }
  89934. declare module BABYLON {
  89935. /**
  89936. * This represents an audio engine and it is responsible
  89937. * to play, synchronize and analyse sounds throughout the application.
  89938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89939. */
  89940. export interface IAudioEngine extends IDisposable {
  89941. /**
  89942. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89943. */
  89944. readonly canUseWebAudio: boolean;
  89945. /**
  89946. * Gets the current AudioContext if available.
  89947. */
  89948. readonly audioContext: Nullable<AudioContext>;
  89949. /**
  89950. * The master gain node defines the global audio volume of your audio engine.
  89951. */
  89952. readonly masterGain: GainNode;
  89953. /**
  89954. * Gets whether or not mp3 are supported by your browser.
  89955. */
  89956. readonly isMP3supported: boolean;
  89957. /**
  89958. * Gets whether or not ogg are supported by your browser.
  89959. */
  89960. readonly isOGGsupported: boolean;
  89961. /**
  89962. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89963. * @ignoreNaming
  89964. */
  89965. WarnedWebAudioUnsupported: boolean;
  89966. /**
  89967. * Defines if the audio engine relies on a custom unlocked button.
  89968. * In this case, the embedded button will not be displayed.
  89969. */
  89970. useCustomUnlockedButton: boolean;
  89971. /**
  89972. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89973. */
  89974. readonly unlocked: boolean;
  89975. /**
  89976. * Event raised when audio has been unlocked on the browser.
  89977. */
  89978. onAudioUnlockedObservable: Observable<AudioEngine>;
  89979. /**
  89980. * Event raised when audio has been locked on the browser.
  89981. */
  89982. onAudioLockedObservable: Observable<AudioEngine>;
  89983. /**
  89984. * Flags the audio engine in Locked state.
  89985. * This happens due to new browser policies preventing audio to autoplay.
  89986. */
  89987. lock(): void;
  89988. /**
  89989. * Unlocks the audio engine once a user action has been done on the dom.
  89990. * This is helpful to resume play once browser policies have been satisfied.
  89991. */
  89992. unlock(): void;
  89993. }
  89994. /**
  89995. * This represents the default audio engine used in babylon.
  89996. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89998. */
  89999. export class AudioEngine implements IAudioEngine {
  90000. private _audioContext;
  90001. private _audioContextInitialized;
  90002. private _muteButton;
  90003. private _hostElement;
  90004. /**
  90005. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  90006. */
  90007. canUseWebAudio: boolean;
  90008. /**
  90009. * The master gain node defines the global audio volume of your audio engine.
  90010. */
  90011. masterGain: GainNode;
  90012. /**
  90013. * Defines if Babylon should emit a warning if WebAudio is not supported.
  90014. * @ignoreNaming
  90015. */
  90016. WarnedWebAudioUnsupported: boolean;
  90017. /**
  90018. * Gets whether or not mp3 are supported by your browser.
  90019. */
  90020. isMP3supported: boolean;
  90021. /**
  90022. * Gets whether or not ogg are supported by your browser.
  90023. */
  90024. isOGGsupported: boolean;
  90025. /**
  90026. * Gets whether audio has been unlocked on the device.
  90027. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  90028. * a user interaction has happened.
  90029. */
  90030. unlocked: boolean;
  90031. /**
  90032. * Defines if the audio engine relies on a custom unlocked button.
  90033. * In this case, the embedded button will not be displayed.
  90034. */
  90035. useCustomUnlockedButton: boolean;
  90036. /**
  90037. * Event raised when audio has been unlocked on the browser.
  90038. */
  90039. onAudioUnlockedObservable: Observable<AudioEngine>;
  90040. /**
  90041. * Event raised when audio has been locked on the browser.
  90042. */
  90043. onAudioLockedObservable: Observable<AudioEngine>;
  90044. /**
  90045. * Gets the current AudioContext if available.
  90046. */
  90047. readonly audioContext: Nullable<AudioContext>;
  90048. private _connectedAnalyser;
  90049. /**
  90050. * Instantiates a new audio engine.
  90051. *
  90052. * There should be only one per page as some browsers restrict the number
  90053. * of audio contexts you can create.
  90054. * @param hostElement defines the host element where to display the mute icon if necessary
  90055. */
  90056. constructor(hostElement?: Nullable<HTMLElement>);
  90057. /**
  90058. * Flags the audio engine in Locked state.
  90059. * This happens due to new browser policies preventing audio to autoplay.
  90060. */
  90061. lock(): void;
  90062. /**
  90063. * Unlocks the audio engine once a user action has been done on the dom.
  90064. * This is helpful to resume play once browser policies have been satisfied.
  90065. */
  90066. unlock(): void;
  90067. private _resumeAudioContext;
  90068. private _initializeAudioContext;
  90069. private _tryToRun;
  90070. private _triggerRunningState;
  90071. private _triggerSuspendedState;
  90072. private _displayMuteButton;
  90073. private _moveButtonToTopLeft;
  90074. private _onResize;
  90075. private _hideMuteButton;
  90076. /**
  90077. * Destroy and release the resources associated with the audio ccontext.
  90078. */
  90079. dispose(): void;
  90080. /**
  90081. * Gets the global volume sets on the master gain.
  90082. * @returns the global volume if set or -1 otherwise
  90083. */
  90084. getGlobalVolume(): number;
  90085. /**
  90086. * Sets the global volume of your experience (sets on the master gain).
  90087. * @param newVolume Defines the new global volume of the application
  90088. */
  90089. setGlobalVolume(newVolume: number): void;
  90090. /**
  90091. * Connect the audio engine to an audio analyser allowing some amazing
  90092. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  90093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  90094. * @param analyser The analyser to connect to the engine
  90095. */
  90096. connectToAnalyser(analyser: Analyser): void;
  90097. }
  90098. }
  90099. declare module BABYLON {
  90100. /**
  90101. * Interface used to present a loading screen while loading a scene
  90102. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90103. */
  90104. export interface ILoadingScreen {
  90105. /**
  90106. * Function called to display the loading screen
  90107. */
  90108. displayLoadingUI: () => void;
  90109. /**
  90110. * Function called to hide the loading screen
  90111. */
  90112. hideLoadingUI: () => void;
  90113. /**
  90114. * Gets or sets the color to use for the background
  90115. */
  90116. loadingUIBackgroundColor: string;
  90117. /**
  90118. * Gets or sets the text to display while loading
  90119. */
  90120. loadingUIText: string;
  90121. }
  90122. /**
  90123. * Class used for the default loading screen
  90124. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90125. */
  90126. export class DefaultLoadingScreen implements ILoadingScreen {
  90127. private _renderingCanvas;
  90128. private _loadingText;
  90129. private _loadingDivBackgroundColor;
  90130. private _loadingDiv;
  90131. private _loadingTextDiv;
  90132. /** Gets or sets the logo url to use for the default loading screen */
  90133. static DefaultLogoUrl: string;
  90134. /** Gets or sets the spinner url to use for the default loading screen */
  90135. static DefaultSpinnerUrl: string;
  90136. /**
  90137. * Creates a new default loading screen
  90138. * @param _renderingCanvas defines the canvas used to render the scene
  90139. * @param _loadingText defines the default text to display
  90140. * @param _loadingDivBackgroundColor defines the default background color
  90141. */
  90142. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  90143. /**
  90144. * Function called to display the loading screen
  90145. */
  90146. displayLoadingUI(): void;
  90147. /**
  90148. * Function called to hide the loading screen
  90149. */
  90150. hideLoadingUI(): void;
  90151. /**
  90152. * Gets or sets the text to display while loading
  90153. */
  90154. loadingUIText: string;
  90155. /**
  90156. * Gets or sets the color to use for the background
  90157. */
  90158. loadingUIBackgroundColor: string;
  90159. private _resizeLoadingUI;
  90160. }
  90161. }
  90162. declare module BABYLON {
  90163. /** @hidden */
  90164. export class WebGLPipelineContext implements IPipelineContext {
  90165. engine: Engine;
  90166. program: Nullable<WebGLProgram>;
  90167. context?: WebGLRenderingContext;
  90168. vertexShader?: WebGLShader;
  90169. fragmentShader?: WebGLShader;
  90170. isParallelCompiled: boolean;
  90171. onCompiled?: () => void;
  90172. transformFeedback?: WebGLTransformFeedback | null;
  90173. readonly isAsync: boolean;
  90174. readonly isReady: boolean;
  90175. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  90176. }
  90177. }
  90178. declare module BABYLON {
  90179. /** @hidden */
  90180. export class WebGLDataBuffer extends DataBuffer {
  90181. private _buffer;
  90182. constructor(resource: WebGLBuffer);
  90183. readonly underlyingResource: any;
  90184. }
  90185. }
  90186. declare module BABYLON {
  90187. /** @hidden */
  90188. export class WebGL2ShaderProcessor implements IShaderProcessor {
  90189. attributeProcessor(attribute: string): string;
  90190. varyingProcessor(varying: string, isFragment: boolean): string;
  90191. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  90192. }
  90193. }
  90194. declare module BABYLON {
  90195. /**
  90196. * Settings for finer control over video usage
  90197. */
  90198. export interface VideoTextureSettings {
  90199. /**
  90200. * Applies `autoplay` to video, if specified
  90201. */
  90202. autoPlay?: boolean;
  90203. /**
  90204. * Applies `loop` to video, if specified
  90205. */
  90206. loop?: boolean;
  90207. /**
  90208. * Automatically updates internal texture from video at every frame in the render loop
  90209. */
  90210. autoUpdateTexture: boolean;
  90211. /**
  90212. * Image src displayed during the video loading or until the user interacts with the video.
  90213. */
  90214. poster?: string;
  90215. }
  90216. /**
  90217. * If you want to display a video in your scene, this is the special texture for that.
  90218. * This special texture works similar to other textures, with the exception of a few parameters.
  90219. * @see https://doc.babylonjs.com/how_to/video_texture
  90220. */
  90221. export class VideoTexture extends Texture {
  90222. /**
  90223. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  90224. */
  90225. readonly autoUpdateTexture: boolean;
  90226. /**
  90227. * The video instance used by the texture internally
  90228. */
  90229. readonly video: HTMLVideoElement;
  90230. private _onUserActionRequestedObservable;
  90231. /**
  90232. * Event triggerd when a dom action is required by the user to play the video.
  90233. * This happens due to recent changes in browser policies preventing video to auto start.
  90234. */
  90235. readonly onUserActionRequestedObservable: Observable<Texture>;
  90236. private _generateMipMaps;
  90237. private _engine;
  90238. private _stillImageCaptured;
  90239. private _displayingPosterTexture;
  90240. private _settings;
  90241. private _createInternalTextureOnEvent;
  90242. /**
  90243. * Creates a video texture.
  90244. * If you want to display a video in your scene, this is the special texture for that.
  90245. * This special texture works similar to other textures, with the exception of a few parameters.
  90246. * @see https://doc.babylonjs.com/how_to/video_texture
  90247. * @param name optional name, will detect from video source, if not defined
  90248. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  90249. * @param scene is obviously the current scene.
  90250. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  90251. * @param invertY is false by default but can be used to invert video on Y axis
  90252. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  90253. * @param settings allows finer control over video usage
  90254. */
  90255. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  90256. private _getName;
  90257. private _getVideo;
  90258. private _createInternalTexture;
  90259. private reset;
  90260. /**
  90261. * @hidden Internal method to initiate `update`.
  90262. */
  90263. _rebuild(): void;
  90264. /**
  90265. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  90266. */
  90267. update(): void;
  90268. /**
  90269. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  90270. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  90271. */
  90272. updateTexture(isVisible: boolean): void;
  90273. protected _updateInternalTexture: () => void;
  90274. /**
  90275. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  90276. * @param url New url.
  90277. */
  90278. updateURL(url: string): void;
  90279. /**
  90280. * Dispose the texture and release its associated resources.
  90281. */
  90282. dispose(): void;
  90283. /**
  90284. * Creates a video texture straight from a stream.
  90285. * @param scene Define the scene the texture should be created in
  90286. * @param stream Define the stream the texture should be created from
  90287. * @returns The created video texture as a promise
  90288. */
  90289. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  90290. /**
  90291. * Creates a video texture straight from your WebCam video feed.
  90292. * @param scene Define the scene the texture should be created in
  90293. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  90294. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  90295. * @returns The created video texture as a promise
  90296. */
  90297. static CreateFromWebCamAsync(scene: Scene, constraints: {
  90298. minWidth: number;
  90299. maxWidth: number;
  90300. minHeight: number;
  90301. maxHeight: number;
  90302. deviceId: string;
  90303. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  90304. /**
  90305. * Creates a video texture straight from your WebCam video feed.
  90306. * @param scene Define the scene the texture should be created in
  90307. * @param onReady Define a callback to triggered once the texture will be ready
  90308. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  90309. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  90310. */
  90311. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  90312. minWidth: number;
  90313. maxWidth: number;
  90314. minHeight: number;
  90315. maxHeight: number;
  90316. deviceId: string;
  90317. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  90318. }
  90319. }
  90320. declare module BABYLON {
  90321. /**
  90322. * Interface for attribute information associated with buffer instanciation
  90323. */
  90324. export class InstancingAttributeInfo {
  90325. /**
  90326. * Index/offset of the attribute in the vertex shader
  90327. */
  90328. index: number;
  90329. /**
  90330. * size of the attribute, 1, 2, 3 or 4
  90331. */
  90332. attributeSize: number;
  90333. /**
  90334. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  90335. * default is FLOAT
  90336. */
  90337. attribyteType: number;
  90338. /**
  90339. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  90340. */
  90341. normalized: boolean;
  90342. /**
  90343. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  90344. */
  90345. offset: number;
  90346. /**
  90347. * Name of the GLSL attribute, for debugging purpose only
  90348. */
  90349. attributeName: string;
  90350. }
  90351. /**
  90352. * Define options used to create a depth texture
  90353. */
  90354. export class DepthTextureCreationOptions {
  90355. /** Specifies whether or not a stencil should be allocated in the texture */
  90356. generateStencil?: boolean;
  90357. /** Specifies whether or not bilinear filtering is enable on the texture */
  90358. bilinearFiltering?: boolean;
  90359. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  90360. comparisonFunction?: number;
  90361. /** Specifies if the created texture is a cube texture */
  90362. isCube?: boolean;
  90363. }
  90364. /**
  90365. * Class used to describe the capabilities of the engine relatively to the current browser
  90366. */
  90367. export class EngineCapabilities {
  90368. /** Maximum textures units per fragment shader */
  90369. maxTexturesImageUnits: number;
  90370. /** Maximum texture units per vertex shader */
  90371. maxVertexTextureImageUnits: number;
  90372. /** Maximum textures units in the entire pipeline */
  90373. maxCombinedTexturesImageUnits: number;
  90374. /** Maximum texture size */
  90375. maxTextureSize: number;
  90376. /** Maximum cube texture size */
  90377. maxCubemapTextureSize: number;
  90378. /** Maximum render texture size */
  90379. maxRenderTextureSize: number;
  90380. /** Maximum number of vertex attributes */
  90381. maxVertexAttribs: number;
  90382. /** Maximum number of varyings */
  90383. maxVaryingVectors: number;
  90384. /** Maximum number of uniforms per vertex shader */
  90385. maxVertexUniformVectors: number;
  90386. /** Maximum number of uniforms per fragment shader */
  90387. maxFragmentUniformVectors: number;
  90388. /** Defines if standard derivates (dx/dy) are supported */
  90389. standardDerivatives: boolean;
  90390. /** Defines if s3tc texture compression is supported */
  90391. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  90392. /** Defines if pvrtc texture compression is supported */
  90393. pvrtc: any;
  90394. /** Defines if etc1 texture compression is supported */
  90395. etc1: any;
  90396. /** Defines if etc2 texture compression is supported */
  90397. etc2: any;
  90398. /** Defines if astc texture compression is supported */
  90399. astc: any;
  90400. /** Defines if float textures are supported */
  90401. textureFloat: boolean;
  90402. /** Defines if vertex array objects are supported */
  90403. vertexArrayObject: boolean;
  90404. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  90405. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  90406. /** Gets the maximum level of anisotropy supported */
  90407. maxAnisotropy: number;
  90408. /** Defines if instancing is supported */
  90409. instancedArrays: boolean;
  90410. /** Defines if 32 bits indices are supported */
  90411. uintIndices: boolean;
  90412. /** Defines if high precision shaders are supported */
  90413. highPrecisionShaderSupported: boolean;
  90414. /** Defines if depth reading in the fragment shader is supported */
  90415. fragmentDepthSupported: boolean;
  90416. /** Defines if float texture linear filtering is supported*/
  90417. textureFloatLinearFiltering: boolean;
  90418. /** Defines if rendering to float textures is supported */
  90419. textureFloatRender: boolean;
  90420. /** Defines if half float textures are supported*/
  90421. textureHalfFloat: boolean;
  90422. /** Defines if half float texture linear filtering is supported*/
  90423. textureHalfFloatLinearFiltering: boolean;
  90424. /** Defines if rendering to half float textures is supported */
  90425. textureHalfFloatRender: boolean;
  90426. /** Defines if textureLOD shader command is supported */
  90427. textureLOD: boolean;
  90428. /** Defines if draw buffers extension is supported */
  90429. drawBuffersExtension: boolean;
  90430. /** Defines if depth textures are supported */
  90431. depthTextureExtension: boolean;
  90432. /** Defines if float color buffer are supported */
  90433. colorBufferFloat: boolean;
  90434. /** Gets disjoint timer query extension (null if not supported) */
  90435. timerQuery: EXT_disjoint_timer_query;
  90436. /** Defines if timestamp can be used with timer query */
  90437. canUseTimestampForTimerQuery: boolean;
  90438. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  90439. multiview: any;
  90440. /** Function used to let the system compiles shaders in background */
  90441. parallelShaderCompile: {
  90442. COMPLETION_STATUS_KHR: number;
  90443. };
  90444. }
  90445. /** Interface defining initialization parameters for Engine class */
  90446. export interface EngineOptions extends WebGLContextAttributes {
  90447. /**
  90448. * Defines if the engine should no exceed a specified device ratio
  90449. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  90450. */
  90451. limitDeviceRatio?: number;
  90452. /**
  90453. * Defines if webvr should be enabled automatically
  90454. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90455. */
  90456. autoEnableWebVR?: boolean;
  90457. /**
  90458. * Defines if webgl2 should be turned off even if supported
  90459. * @see http://doc.babylonjs.com/features/webgl2
  90460. */
  90461. disableWebGL2Support?: boolean;
  90462. /**
  90463. * Defines if webaudio should be initialized as well
  90464. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90465. */
  90466. audioEngine?: boolean;
  90467. /**
  90468. * Defines if animations should run using a deterministic lock step
  90469. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90470. */
  90471. deterministicLockstep?: boolean;
  90472. /** Defines the maximum steps to use with deterministic lock step mode */
  90473. lockstepMaxSteps?: number;
  90474. /**
  90475. * Defines that engine should ignore context lost events
  90476. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  90477. */
  90478. doNotHandleContextLost?: boolean;
  90479. /**
  90480. * Defines that engine should ignore modifying touch action attribute and style
  90481. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  90482. */
  90483. doNotHandleTouchAction?: boolean;
  90484. /**
  90485. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  90486. */
  90487. useHighPrecisionFloats?: boolean;
  90488. }
  90489. /**
  90490. * Defines the interface used by display changed events
  90491. */
  90492. export interface IDisplayChangedEventArgs {
  90493. /** Gets the vrDisplay object (if any) */
  90494. vrDisplay: Nullable<any>;
  90495. /** Gets a boolean indicating if webVR is supported */
  90496. vrSupported: boolean;
  90497. }
  90498. /**
  90499. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  90500. */
  90501. export class Engine {
  90502. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  90503. static ExceptionList: ({
  90504. key: string;
  90505. capture: string;
  90506. captureConstraint: number;
  90507. targets: string[];
  90508. } | {
  90509. key: string;
  90510. capture: null;
  90511. captureConstraint: null;
  90512. targets: string[];
  90513. })[];
  90514. /** Gets the list of created engines */
  90515. static readonly Instances: Engine[];
  90516. /**
  90517. * Gets the latest created engine
  90518. */
  90519. static readonly LastCreatedEngine: Nullable<Engine>;
  90520. /**
  90521. * Gets the latest created scene
  90522. */
  90523. static readonly LastCreatedScene: Nullable<Scene>;
  90524. /**
  90525. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  90526. * @param flag defines which part of the materials must be marked as dirty
  90527. * @param predicate defines a predicate used to filter which materials should be affected
  90528. */
  90529. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90530. /** @hidden */
  90531. static _TextureLoaders: IInternalTextureLoader[];
  90532. /** Defines that alpha blending is disabled */
  90533. static readonly ALPHA_DISABLE: number;
  90534. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  90535. static readonly ALPHA_ADD: number;
  90536. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  90537. static readonly ALPHA_COMBINE: number;
  90538. /** Defines that alpha blending to DEST - SRC * DEST */
  90539. static readonly ALPHA_SUBTRACT: number;
  90540. /** Defines that alpha blending to SRC * DEST */
  90541. static readonly ALPHA_MULTIPLY: number;
  90542. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  90543. static readonly ALPHA_MAXIMIZED: number;
  90544. /** Defines that alpha blending to SRC + DEST */
  90545. static readonly ALPHA_ONEONE: number;
  90546. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  90547. static readonly ALPHA_PREMULTIPLIED: number;
  90548. /**
  90549. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  90550. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  90551. */
  90552. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  90553. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  90554. static readonly ALPHA_INTERPOLATE: number;
  90555. /**
  90556. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  90557. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  90558. */
  90559. static readonly ALPHA_SCREENMODE: number;
  90560. /** Defines that the ressource is not delayed*/
  90561. static readonly DELAYLOADSTATE_NONE: number;
  90562. /** Defines that the ressource was successfully delay loaded */
  90563. static readonly DELAYLOADSTATE_LOADED: number;
  90564. /** Defines that the ressource is currently delay loading */
  90565. static readonly DELAYLOADSTATE_LOADING: number;
  90566. /** Defines that the ressource is delayed and has not started loading */
  90567. static readonly DELAYLOADSTATE_NOTLOADED: number;
  90568. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  90569. static readonly NEVER: number;
  90570. /** 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 */
  90571. static readonly ALWAYS: number;
  90572. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  90573. static readonly LESS: number;
  90574. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  90575. static readonly EQUAL: number;
  90576. /** 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 */
  90577. static readonly LEQUAL: number;
  90578. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  90579. static readonly GREATER: number;
  90580. /** 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 */
  90581. static readonly GEQUAL: number;
  90582. /** 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 */
  90583. static readonly NOTEQUAL: number;
  90584. /** Passed to stencilOperation to specify that stencil value must be kept */
  90585. static readonly KEEP: number;
  90586. /** Passed to stencilOperation to specify that stencil value must be replaced */
  90587. static readonly REPLACE: number;
  90588. /** Passed to stencilOperation to specify that stencil value must be incremented */
  90589. static readonly INCR: number;
  90590. /** Passed to stencilOperation to specify that stencil value must be decremented */
  90591. static readonly DECR: number;
  90592. /** Passed to stencilOperation to specify that stencil value must be inverted */
  90593. static readonly INVERT: number;
  90594. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  90595. static readonly INCR_WRAP: number;
  90596. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  90597. static readonly DECR_WRAP: number;
  90598. /** Texture is not repeating outside of 0..1 UVs */
  90599. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  90600. /** Texture is repeating outside of 0..1 UVs */
  90601. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  90602. /** Texture is repeating and mirrored */
  90603. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  90604. /** ALPHA */
  90605. static readonly TEXTUREFORMAT_ALPHA: number;
  90606. /** LUMINANCE */
  90607. static readonly TEXTUREFORMAT_LUMINANCE: number;
  90608. /** LUMINANCE_ALPHA */
  90609. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  90610. /** RGB */
  90611. static readonly TEXTUREFORMAT_RGB: number;
  90612. /** RGBA */
  90613. static readonly TEXTUREFORMAT_RGBA: number;
  90614. /** RED */
  90615. static readonly TEXTUREFORMAT_RED: number;
  90616. /** RED (2nd reference) */
  90617. static readonly TEXTUREFORMAT_R: number;
  90618. /** RG */
  90619. static readonly TEXTUREFORMAT_RG: number;
  90620. /** RED_INTEGER */
  90621. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  90622. /** RED_INTEGER (2nd reference) */
  90623. static readonly TEXTUREFORMAT_R_INTEGER: number;
  90624. /** RG_INTEGER */
  90625. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  90626. /** RGB_INTEGER */
  90627. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  90628. /** RGBA_INTEGER */
  90629. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  90630. /** UNSIGNED_BYTE */
  90631. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  90632. /** UNSIGNED_BYTE (2nd reference) */
  90633. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  90634. /** FLOAT */
  90635. static readonly TEXTURETYPE_FLOAT: number;
  90636. /** HALF_FLOAT */
  90637. static readonly TEXTURETYPE_HALF_FLOAT: number;
  90638. /** BYTE */
  90639. static readonly TEXTURETYPE_BYTE: number;
  90640. /** SHORT */
  90641. static readonly TEXTURETYPE_SHORT: number;
  90642. /** UNSIGNED_SHORT */
  90643. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  90644. /** INT */
  90645. static readonly TEXTURETYPE_INT: number;
  90646. /** UNSIGNED_INT */
  90647. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  90648. /** UNSIGNED_SHORT_4_4_4_4 */
  90649. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  90650. /** UNSIGNED_SHORT_5_5_5_1 */
  90651. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  90652. /** UNSIGNED_SHORT_5_6_5 */
  90653. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  90654. /** UNSIGNED_INT_2_10_10_10_REV */
  90655. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  90656. /** UNSIGNED_INT_24_8 */
  90657. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  90658. /** UNSIGNED_INT_10F_11F_11F_REV */
  90659. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  90660. /** UNSIGNED_INT_5_9_9_9_REV */
  90661. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  90662. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  90663. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  90664. /** nearest is mag = nearest and min = nearest and mip = linear */
  90665. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  90666. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90667. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  90668. /** Trilinear is mag = linear and min = linear and mip = linear */
  90669. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  90670. /** nearest is mag = nearest and min = nearest and mip = linear */
  90671. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  90672. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90673. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  90674. /** Trilinear is mag = linear and min = linear and mip = linear */
  90675. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  90676. /** mag = nearest and min = nearest and mip = nearest */
  90677. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  90678. /** mag = nearest and min = linear and mip = nearest */
  90679. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  90680. /** mag = nearest and min = linear and mip = linear */
  90681. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  90682. /** mag = nearest and min = linear and mip = none */
  90683. static readonly TEXTURE_NEAREST_LINEAR: number;
  90684. /** mag = nearest and min = nearest and mip = none */
  90685. static readonly TEXTURE_NEAREST_NEAREST: number;
  90686. /** mag = linear and min = nearest and mip = nearest */
  90687. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  90688. /** mag = linear and min = nearest and mip = linear */
  90689. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  90690. /** mag = linear and min = linear and mip = none */
  90691. static readonly TEXTURE_LINEAR_LINEAR: number;
  90692. /** mag = linear and min = nearest and mip = none */
  90693. static readonly TEXTURE_LINEAR_NEAREST: number;
  90694. /** Explicit coordinates mode */
  90695. static readonly TEXTURE_EXPLICIT_MODE: number;
  90696. /** Spherical coordinates mode */
  90697. static readonly TEXTURE_SPHERICAL_MODE: number;
  90698. /** Planar coordinates mode */
  90699. static readonly TEXTURE_PLANAR_MODE: number;
  90700. /** Cubic coordinates mode */
  90701. static readonly TEXTURE_CUBIC_MODE: number;
  90702. /** Projection coordinates mode */
  90703. static readonly TEXTURE_PROJECTION_MODE: number;
  90704. /** Skybox coordinates mode */
  90705. static readonly TEXTURE_SKYBOX_MODE: number;
  90706. /** Inverse Cubic coordinates mode */
  90707. static readonly TEXTURE_INVCUBIC_MODE: number;
  90708. /** Equirectangular coordinates mode */
  90709. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  90710. /** Equirectangular Fixed coordinates mode */
  90711. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  90712. /** Equirectangular Fixed Mirrored coordinates mode */
  90713. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  90714. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  90715. static readonly SCALEMODE_FLOOR: number;
  90716. /** Defines that texture rescaling will look for the nearest power of 2 size */
  90717. static readonly SCALEMODE_NEAREST: number;
  90718. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  90719. static readonly SCALEMODE_CEILING: number;
  90720. /**
  90721. * Returns the current npm package of the sdk
  90722. */
  90723. static readonly NpmPackage: string;
  90724. /**
  90725. * Returns the current version of the framework
  90726. */
  90727. static readonly Version: string;
  90728. /**
  90729. * Returns a string describing the current engine
  90730. */
  90731. readonly description: string;
  90732. /**
  90733. * Gets or sets the epsilon value used by collision engine
  90734. */
  90735. static CollisionsEpsilon: number;
  90736. /**
  90737. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  90738. */
  90739. static ShadersRepository: string;
  90740. /**
  90741. * Method called to create the default loading screen.
  90742. * This can be overriden in your own app.
  90743. * @param canvas The rendering canvas element
  90744. * @returns The loading screen
  90745. */
  90746. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  90747. /**
  90748. * Method called to create the default rescale post process on each engine.
  90749. */
  90750. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  90751. /** @hidden */
  90752. _shaderProcessor: IShaderProcessor;
  90753. /**
  90754. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  90755. */
  90756. forcePOTTextures: boolean;
  90757. /**
  90758. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90759. */
  90760. isFullscreen: boolean;
  90761. /**
  90762. * Gets a boolean indicating if the pointer is currently locked
  90763. */
  90764. isPointerLock: boolean;
  90765. /**
  90766. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90767. */
  90768. cullBackFaces: boolean;
  90769. /**
  90770. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90771. */
  90772. renderEvenInBackground: boolean;
  90773. /**
  90774. * Gets or sets a boolean indicating that cache can be kept between frames
  90775. */
  90776. preventCacheWipeBetweenFrames: boolean;
  90777. /**
  90778. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90779. **/
  90780. enableOfflineSupport: boolean;
  90781. /**
  90782. * 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)
  90783. **/
  90784. disableManifestCheck: boolean;
  90785. /**
  90786. * Gets the list of created scenes
  90787. */
  90788. scenes: Scene[];
  90789. /**
  90790. * Event raised when a new scene is created
  90791. */
  90792. onNewSceneAddedObservable: Observable<Scene>;
  90793. /**
  90794. * Gets the list of created postprocesses
  90795. */
  90796. postProcesses: PostProcess[];
  90797. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90798. validateShaderPrograms: boolean;
  90799. /**
  90800. * Observable event triggered each time the rendering canvas is resized
  90801. */
  90802. onResizeObservable: Observable<Engine>;
  90803. /**
  90804. * Observable event triggered each time the canvas loses focus
  90805. */
  90806. onCanvasBlurObservable: Observable<Engine>;
  90807. /**
  90808. * Observable event triggered each time the canvas gains focus
  90809. */
  90810. onCanvasFocusObservable: Observable<Engine>;
  90811. /**
  90812. * Observable event triggered each time the canvas receives pointerout event
  90813. */
  90814. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90815. /**
  90816. * Observable event triggered before each texture is initialized
  90817. */
  90818. onBeforeTextureInitObservable: Observable<Texture>;
  90819. /**
  90820. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90821. */
  90822. disableUniformBuffers: boolean;
  90823. /** @hidden */
  90824. _uniformBuffers: UniformBuffer[];
  90825. /**
  90826. * Gets a boolean indicating that the engine supports uniform buffers
  90827. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90828. */
  90829. readonly supportsUniformBuffers: boolean;
  90830. /**
  90831. * Observable raised when the engine begins a new frame
  90832. */
  90833. onBeginFrameObservable: Observable<Engine>;
  90834. /**
  90835. * If set, will be used to request the next animation frame for the render loop
  90836. */
  90837. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90838. /**
  90839. * Observable raised when the engine ends the current frame
  90840. */
  90841. onEndFrameObservable: Observable<Engine>;
  90842. /**
  90843. * Observable raised when the engine is about to compile a shader
  90844. */
  90845. onBeforeShaderCompilationObservable: Observable<Engine>;
  90846. /**
  90847. * Observable raised when the engine has jsut compiled a shader
  90848. */
  90849. onAfterShaderCompilationObservable: Observable<Engine>;
  90850. /** @hidden */
  90851. _gl: WebGLRenderingContext;
  90852. private _renderingCanvas;
  90853. private _windowIsBackground;
  90854. private _webGLVersion;
  90855. protected _highPrecisionShadersAllowed: boolean;
  90856. /** @hidden */
  90857. readonly _shouldUseHighPrecisionShader: boolean;
  90858. /**
  90859. * Gets a boolean indicating that only power of 2 textures are supported
  90860. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90861. */
  90862. readonly needPOTTextures: boolean;
  90863. /** @hidden */
  90864. _badOS: boolean;
  90865. /** @hidden */
  90866. _badDesktopOS: boolean;
  90867. /**
  90868. * Gets the audio engine
  90869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90870. * @ignorenaming
  90871. */
  90872. static audioEngine: IAudioEngine;
  90873. /**
  90874. * Default AudioEngine factory responsible of creating the Audio Engine.
  90875. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90876. */
  90877. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90878. /**
  90879. * Default offline support factory responsible of creating a tool used to store data locally.
  90880. * By default, this will create a Database object if the workload has been embedded.
  90881. */
  90882. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90883. private _onFocus;
  90884. private _onBlur;
  90885. private _onCanvasPointerOut;
  90886. private _onCanvasBlur;
  90887. private _onCanvasFocus;
  90888. private _onFullscreenChange;
  90889. private _onPointerLockChange;
  90890. private _hardwareScalingLevel;
  90891. /** @hidden */
  90892. _caps: EngineCapabilities;
  90893. private _pointerLockRequested;
  90894. private _isStencilEnable;
  90895. private _colorWrite;
  90896. private _loadingScreen;
  90897. /** @hidden */
  90898. _drawCalls: PerfCounter;
  90899. private _glVersion;
  90900. private _glRenderer;
  90901. private _glVendor;
  90902. private _videoTextureSupported;
  90903. private _renderingQueueLaunched;
  90904. private _activeRenderLoops;
  90905. private _deterministicLockstep;
  90906. private _lockstepMaxSteps;
  90907. /**
  90908. * Observable signaled when a context lost event is raised
  90909. */
  90910. onContextLostObservable: Observable<Engine>;
  90911. /**
  90912. * Observable signaled when a context restored event is raised
  90913. */
  90914. onContextRestoredObservable: Observable<Engine>;
  90915. private _onContextLost;
  90916. private _onContextRestored;
  90917. private _contextWasLost;
  90918. /** @hidden */
  90919. _doNotHandleContextLost: boolean;
  90920. /**
  90921. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90922. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90923. */
  90924. doNotHandleContextLost: boolean;
  90925. private _performanceMonitor;
  90926. private _fps;
  90927. private _deltaTime;
  90928. /**
  90929. * Turn this value on if you want to pause FPS computation when in background
  90930. */
  90931. disablePerformanceMonitorInBackground: boolean;
  90932. /**
  90933. * Gets the performance monitor attached to this engine
  90934. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90935. */
  90936. readonly performanceMonitor: PerformanceMonitor;
  90937. /**
  90938. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90939. */
  90940. disableVertexArrayObjects: boolean;
  90941. /** @hidden */
  90942. protected _depthCullingState: _DepthCullingState;
  90943. /** @hidden */
  90944. protected _stencilState: _StencilState;
  90945. /** @hidden */
  90946. protected _alphaState: _AlphaState;
  90947. /** @hidden */
  90948. protected _alphaMode: number;
  90949. /** @hidden */
  90950. _internalTexturesCache: InternalTexture[];
  90951. /** @hidden */
  90952. protected _activeChannel: number;
  90953. private _currentTextureChannel;
  90954. /** @hidden */
  90955. protected _boundTexturesCache: {
  90956. [key: string]: Nullable<InternalTexture>;
  90957. };
  90958. /** @hidden */
  90959. protected _currentEffect: Nullable<Effect>;
  90960. /** @hidden */
  90961. protected _currentProgram: Nullable<WebGLProgram>;
  90962. private _compiledEffects;
  90963. private _vertexAttribArraysEnabled;
  90964. /** @hidden */
  90965. protected _cachedViewport: Nullable<Viewport>;
  90966. private _cachedVertexArrayObject;
  90967. /** @hidden */
  90968. protected _cachedVertexBuffers: any;
  90969. /** @hidden */
  90970. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90971. /** @hidden */
  90972. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90973. /** @hidden */
  90974. _currentRenderTarget: Nullable<InternalTexture>;
  90975. private _uintIndicesCurrentlySet;
  90976. private _currentBoundBuffer;
  90977. /** @hidden */
  90978. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90979. private _currentBufferPointers;
  90980. private _currentInstanceLocations;
  90981. private _currentInstanceBuffers;
  90982. private _textureUnits;
  90983. /** @hidden */
  90984. _workingCanvas: Nullable<HTMLCanvasElement>;
  90985. /** @hidden */
  90986. _workingContext: Nullable<CanvasRenderingContext2D>;
  90987. private _rescalePostProcess;
  90988. private _dummyFramebuffer;
  90989. private _externalData;
  90990. /** @hidden */
  90991. _bindedRenderFunction: any;
  90992. private _vaoRecordInProgress;
  90993. private _mustWipeVertexAttributes;
  90994. private _emptyTexture;
  90995. private _emptyCubeTexture;
  90996. private _emptyTexture3D;
  90997. /** @hidden */
  90998. _frameHandler: number;
  90999. private _nextFreeTextureSlots;
  91000. private _maxSimultaneousTextures;
  91001. private _activeRequests;
  91002. private _texturesSupported;
  91003. /** @hidden */
  91004. _textureFormatInUse: Nullable<string>;
  91005. /**
  91006. * Gets the list of texture formats supported
  91007. */
  91008. readonly texturesSupported: Array<string>;
  91009. /**
  91010. * Gets the list of texture formats in use
  91011. */
  91012. readonly textureFormatInUse: Nullable<string>;
  91013. /**
  91014. * Gets the current viewport
  91015. */
  91016. readonly currentViewport: Nullable<Viewport>;
  91017. /**
  91018. * Gets the default empty texture
  91019. */
  91020. readonly emptyTexture: InternalTexture;
  91021. /**
  91022. * Gets the default empty 3D texture
  91023. */
  91024. readonly emptyTexture3D: InternalTexture;
  91025. /**
  91026. * Gets the default empty cube texture
  91027. */
  91028. readonly emptyCubeTexture: InternalTexture;
  91029. /**
  91030. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  91031. */
  91032. readonly premultipliedAlpha: boolean;
  91033. /**
  91034. * Creates a new engine
  91035. * @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
  91036. * @param antialias defines enable antialiasing (default: false)
  91037. * @param options defines further options to be sent to the getContext() function
  91038. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  91039. */
  91040. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  91041. /**
  91042. * Initializes a webVR display and starts listening to display change events
  91043. * The onVRDisplayChangedObservable will be notified upon these changes
  91044. * @returns The onVRDisplayChangedObservable
  91045. */
  91046. initWebVR(): Observable<IDisplayChangedEventArgs>;
  91047. /** @hidden */
  91048. _prepareVRComponent(): void;
  91049. /** @hidden */
  91050. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  91051. /** @hidden */
  91052. _submitVRFrame(): void;
  91053. /**
  91054. * Call this function to leave webVR mode
  91055. * Will do nothing if webVR is not supported or if there is no webVR device
  91056. * @see http://doc.babylonjs.com/how_to/webvr_camera
  91057. */
  91058. disableVR(): void;
  91059. /**
  91060. * Gets a boolean indicating that the system is in VR mode and is presenting
  91061. * @returns true if VR mode is engaged
  91062. */
  91063. isVRPresenting(): boolean;
  91064. /** @hidden */
  91065. _requestVRFrame(): void;
  91066. private _disableTouchAction;
  91067. private _rebuildInternalTextures;
  91068. private _rebuildEffects;
  91069. /**
  91070. * Gets a boolean indicating if all created effects are ready
  91071. * @returns true if all effects are ready
  91072. */
  91073. areAllEffectsReady(): boolean;
  91074. private _rebuildBuffers;
  91075. private _initGLContext;
  91076. /**
  91077. * Gets version of the current webGL context
  91078. */
  91079. readonly webGLVersion: number;
  91080. /**
  91081. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  91082. */
  91083. readonly isStencilEnable: boolean;
  91084. /** @hidden */
  91085. _prepareWorkingCanvas(): void;
  91086. /**
  91087. * Reset the texture cache to empty state
  91088. */
  91089. resetTextureCache(): void;
  91090. /**
  91091. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  91092. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91093. * @returns true if engine is in deterministic lock step mode
  91094. */
  91095. isDeterministicLockStep(): boolean;
  91096. /**
  91097. * Gets the max steps when engine is running in deterministic lock step
  91098. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91099. * @returns the max steps
  91100. */
  91101. getLockstepMaxSteps(): number;
  91102. /**
  91103. * Gets an object containing information about the current webGL context
  91104. * @returns an object containing the vender, the renderer and the version of the current webGL context
  91105. */
  91106. getGlInfo(): {
  91107. vendor: string;
  91108. renderer: string;
  91109. version: string;
  91110. };
  91111. /**
  91112. * Gets current aspect ratio
  91113. * @param camera defines the camera to use to get the aspect ratio
  91114. * @param useScreen defines if screen size must be used (or the current render target if any)
  91115. * @returns a number defining the aspect ratio
  91116. */
  91117. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  91118. /**
  91119. * Gets current screen aspect ratio
  91120. * @returns a number defining the aspect ratio
  91121. */
  91122. getScreenAspectRatio(): number;
  91123. /**
  91124. * Gets the current render width
  91125. * @param useScreen defines if screen size must be used (or the current render target if any)
  91126. * @returns a number defining the current render width
  91127. */
  91128. getRenderWidth(useScreen?: boolean): number;
  91129. /**
  91130. * Gets the current render height
  91131. * @param useScreen defines if screen size must be used (or the current render target if any)
  91132. * @returns a number defining the current render height
  91133. */
  91134. getRenderHeight(useScreen?: boolean): number;
  91135. /**
  91136. * Gets the HTML canvas attached with the current webGL context
  91137. * @returns a HTML canvas
  91138. */
  91139. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  91140. /**
  91141. * Gets the client rect of the HTML canvas attached with the current webGL context
  91142. * @returns a client rectanglee
  91143. */
  91144. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  91145. /**
  91146. * Defines the hardware scaling level.
  91147. * By default the hardware scaling level is computed from the window device ratio.
  91148. * 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.
  91149. * @param level defines the level to use
  91150. */
  91151. setHardwareScalingLevel(level: number): void;
  91152. /**
  91153. * Gets the current hardware scaling level.
  91154. * By default the hardware scaling level is computed from the window device ratio.
  91155. * 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.
  91156. * @returns a number indicating the current hardware scaling level
  91157. */
  91158. getHardwareScalingLevel(): number;
  91159. /**
  91160. * Gets the list of loaded textures
  91161. * @returns an array containing all loaded textures
  91162. */
  91163. getLoadedTexturesCache(): InternalTexture[];
  91164. /**
  91165. * Gets the object containing all engine capabilities
  91166. * @returns the EngineCapabilities object
  91167. */
  91168. getCaps(): EngineCapabilities;
  91169. /**
  91170. * Gets the current depth function
  91171. * @returns a number defining the depth function
  91172. */
  91173. getDepthFunction(): Nullable<number>;
  91174. /**
  91175. * Sets the current depth function
  91176. * @param depthFunc defines the function to use
  91177. */
  91178. setDepthFunction(depthFunc: number): void;
  91179. /**
  91180. * Sets the current depth function to GREATER
  91181. */
  91182. setDepthFunctionToGreater(): void;
  91183. /**
  91184. * Sets the current depth function to GEQUAL
  91185. */
  91186. setDepthFunctionToGreaterOrEqual(): void;
  91187. /**
  91188. * Sets the current depth function to LESS
  91189. */
  91190. setDepthFunctionToLess(): void;
  91191. private _cachedStencilBuffer;
  91192. private _cachedStencilFunction;
  91193. private _cachedStencilMask;
  91194. private _cachedStencilOperationPass;
  91195. private _cachedStencilOperationFail;
  91196. private _cachedStencilOperationDepthFail;
  91197. private _cachedStencilReference;
  91198. /**
  91199. * Caches the the state of the stencil buffer
  91200. */
  91201. cacheStencilState(): void;
  91202. /**
  91203. * Restores the state of the stencil buffer
  91204. */
  91205. restoreStencilState(): void;
  91206. /**
  91207. * Sets the current depth function to LEQUAL
  91208. */
  91209. setDepthFunctionToLessOrEqual(): void;
  91210. /**
  91211. * Gets a boolean indicating if stencil buffer is enabled
  91212. * @returns the current stencil buffer state
  91213. */
  91214. getStencilBuffer(): boolean;
  91215. /**
  91216. * Enable or disable the stencil buffer
  91217. * @param enable defines if the stencil buffer must be enabled or disabled
  91218. */
  91219. setStencilBuffer(enable: boolean): void;
  91220. /**
  91221. * Gets the current stencil mask
  91222. * @returns a number defining the new stencil mask to use
  91223. */
  91224. getStencilMask(): number;
  91225. /**
  91226. * Sets the current stencil mask
  91227. * @param mask defines the new stencil mask to use
  91228. */
  91229. setStencilMask(mask: number): void;
  91230. /**
  91231. * Gets the current stencil function
  91232. * @returns a number defining the stencil function to use
  91233. */
  91234. getStencilFunction(): number;
  91235. /**
  91236. * Gets the current stencil reference value
  91237. * @returns a number defining the stencil reference value to use
  91238. */
  91239. getStencilFunctionReference(): number;
  91240. /**
  91241. * Gets the current stencil mask
  91242. * @returns a number defining the stencil mask to use
  91243. */
  91244. getStencilFunctionMask(): number;
  91245. /**
  91246. * Sets the current stencil function
  91247. * @param stencilFunc defines the new stencil function to use
  91248. */
  91249. setStencilFunction(stencilFunc: number): void;
  91250. /**
  91251. * Sets the current stencil reference
  91252. * @param reference defines the new stencil reference to use
  91253. */
  91254. setStencilFunctionReference(reference: number): void;
  91255. /**
  91256. * Sets the current stencil mask
  91257. * @param mask defines the new stencil mask to use
  91258. */
  91259. setStencilFunctionMask(mask: number): void;
  91260. /**
  91261. * Gets the current stencil operation when stencil fails
  91262. * @returns a number defining stencil operation to use when stencil fails
  91263. */
  91264. getStencilOperationFail(): number;
  91265. /**
  91266. * Gets the current stencil operation when depth fails
  91267. * @returns a number defining stencil operation to use when depth fails
  91268. */
  91269. getStencilOperationDepthFail(): number;
  91270. /**
  91271. * Gets the current stencil operation when stencil passes
  91272. * @returns a number defining stencil operation to use when stencil passes
  91273. */
  91274. getStencilOperationPass(): number;
  91275. /**
  91276. * Sets the stencil operation to use when stencil fails
  91277. * @param operation defines the stencil operation to use when stencil fails
  91278. */
  91279. setStencilOperationFail(operation: number): void;
  91280. /**
  91281. * Sets the stencil operation to use when depth fails
  91282. * @param operation defines the stencil operation to use when depth fails
  91283. */
  91284. setStencilOperationDepthFail(operation: number): void;
  91285. /**
  91286. * Sets the stencil operation to use when stencil passes
  91287. * @param operation defines the stencil operation to use when stencil passes
  91288. */
  91289. setStencilOperationPass(operation: number): void;
  91290. /**
  91291. * Sets a boolean indicating if the dithering state is enabled or disabled
  91292. * @param value defines the dithering state
  91293. */
  91294. setDitheringState(value: boolean): void;
  91295. /**
  91296. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  91297. * @param value defines the rasterizer state
  91298. */
  91299. setRasterizerState(value: boolean): void;
  91300. /**
  91301. * stop executing a render loop function and remove it from the execution array
  91302. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  91303. */
  91304. stopRenderLoop(renderFunction?: () => void): void;
  91305. /** @hidden */
  91306. _renderLoop(): void;
  91307. /**
  91308. * Register and execute a render loop. The engine can have more than one render function
  91309. * @param renderFunction defines the function to continuously execute
  91310. */
  91311. runRenderLoop(renderFunction: () => void): void;
  91312. /**
  91313. * Toggle full screen mode
  91314. * @param requestPointerLock defines if a pointer lock should be requested from the user
  91315. */
  91316. switchFullscreen(requestPointerLock: boolean): void;
  91317. /**
  91318. * Enters full screen mode
  91319. * @param requestPointerLock defines if a pointer lock should be requested from the user
  91320. */
  91321. enterFullscreen(requestPointerLock: boolean): void;
  91322. /**
  91323. * Exits full screen mode
  91324. */
  91325. exitFullscreen(): void;
  91326. /**
  91327. * Enters Pointerlock mode
  91328. */
  91329. enterPointerlock(): void;
  91330. /**
  91331. * Exits Pointerlock mode
  91332. */
  91333. exitPointerlock(): void;
  91334. /**
  91335. * Clear the current render buffer or the current render target (if any is set up)
  91336. * @param color defines the color to use
  91337. * @param backBuffer defines if the back buffer must be cleared
  91338. * @param depth defines if the depth buffer must be cleared
  91339. * @param stencil defines if the stencil buffer must be cleared
  91340. */
  91341. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  91342. /**
  91343. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  91344. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  91345. * @param y defines the y-coordinate of the corner of the clear rectangle
  91346. * @param width defines the width of the clear rectangle
  91347. * @param height defines the height of the clear rectangle
  91348. * @param clearColor defines the clear color
  91349. */
  91350. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  91351. /**
  91352. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  91353. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  91354. * @param y defines the y-coordinate of the corner of the clear rectangle
  91355. * @param width defines the width of the clear rectangle
  91356. * @param height defines the height of the clear rectangle
  91357. */
  91358. enableScissor(x: number, y: number, width: number, height: number): void;
  91359. /**
  91360. * Disable previously set scissor test rectangle
  91361. */
  91362. disableScissor(): void;
  91363. private _viewportCached;
  91364. /** @hidden */
  91365. _viewport(x: number, y: number, width: number, height: number): void;
  91366. /**
  91367. * Set the WebGL's viewport
  91368. * @param viewport defines the viewport element to be used
  91369. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  91370. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  91371. */
  91372. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  91373. /**
  91374. * Directly set the WebGL Viewport
  91375. * @param x defines the x coordinate of the viewport (in screen space)
  91376. * @param y defines the y coordinate of the viewport (in screen space)
  91377. * @param width defines the width of the viewport (in screen space)
  91378. * @param height defines the height of the viewport (in screen space)
  91379. * @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
  91380. */
  91381. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  91382. /**
  91383. * Begin a new frame
  91384. */
  91385. beginFrame(): void;
  91386. /**
  91387. * Enf the current frame
  91388. */
  91389. endFrame(): void;
  91390. /**
  91391. * Resize the view according to the canvas' size
  91392. */
  91393. resize(): void;
  91394. /**
  91395. * Force a specific size of the canvas
  91396. * @param width defines the new canvas' width
  91397. * @param height defines the new canvas' height
  91398. */
  91399. setSize(width: number, height: number): void;
  91400. /**
  91401. * Binds the frame buffer to the specified texture.
  91402. * @param texture The texture to render to or null for the default canvas
  91403. * @param faceIndex The face of the texture to render to in case of cube texture
  91404. * @param requiredWidth The width of the target to render to
  91405. * @param requiredHeight The height of the target to render to
  91406. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  91407. * @param depthStencilTexture The depth stencil texture to use to render
  91408. * @param lodLevel defines le lod level to bind to the frame buffer
  91409. */
  91410. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  91411. /** @hidden */
  91412. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  91413. /**
  91414. * Unbind the current render target texture from the webGL context
  91415. * @param texture defines the render target texture to unbind
  91416. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  91417. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  91418. */
  91419. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  91420. /**
  91421. * Force the mipmap generation for the given render target texture
  91422. * @param texture defines the render target texture to use
  91423. */
  91424. generateMipMapsForCubemap(texture: InternalTexture): void;
  91425. /**
  91426. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  91427. */
  91428. flushFramebuffer(): void;
  91429. /**
  91430. * Unbind the current render target and bind the default framebuffer
  91431. */
  91432. restoreDefaultFramebuffer(): void;
  91433. /**
  91434. * Create an uniform buffer
  91435. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91436. * @param elements defines the content of the uniform buffer
  91437. * @returns the webGL uniform buffer
  91438. */
  91439. createUniformBuffer(elements: FloatArray): DataBuffer;
  91440. /**
  91441. * Create a dynamic uniform buffer
  91442. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91443. * @param elements defines the content of the uniform buffer
  91444. * @returns the webGL uniform buffer
  91445. */
  91446. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  91447. /**
  91448. * Update an existing uniform buffer
  91449. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91450. * @param uniformBuffer defines the target uniform buffer
  91451. * @param elements defines the content to update
  91452. * @param offset defines the offset in the uniform buffer where update should start
  91453. * @param count defines the size of the data to update
  91454. */
  91455. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  91456. private _resetVertexBufferBinding;
  91457. /**
  91458. * Creates a vertex buffer
  91459. * @param data the data for the vertex buffer
  91460. * @returns the new WebGL static buffer
  91461. */
  91462. createVertexBuffer(data: DataArray): DataBuffer;
  91463. /**
  91464. * Creates a dynamic vertex buffer
  91465. * @param data the data for the dynamic vertex buffer
  91466. * @returns the new WebGL dynamic buffer
  91467. */
  91468. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  91469. /**
  91470. * Update a dynamic index buffer
  91471. * @param indexBuffer defines the target index buffer
  91472. * @param indices defines the data to update
  91473. * @param offset defines the offset in the target index buffer where update should start
  91474. */
  91475. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91476. /**
  91477. * Updates a dynamic vertex buffer.
  91478. * @param vertexBuffer the vertex buffer to update
  91479. * @param data the data used to update the vertex buffer
  91480. * @param byteOffset the byte offset of the data
  91481. * @param byteLength the byte length of the data
  91482. */
  91483. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91484. private _resetIndexBufferBinding;
  91485. /**
  91486. * Creates a new index buffer
  91487. * @param indices defines the content of the index buffer
  91488. * @param updatable defines if the index buffer must be updatable
  91489. * @returns a new webGL buffer
  91490. */
  91491. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  91492. /**
  91493. * Bind a webGL buffer to the webGL context
  91494. * @param buffer defines the buffer to bind
  91495. */
  91496. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  91497. /**
  91498. * Bind an uniform buffer to the current webGL context
  91499. * @param buffer defines the buffer to bind
  91500. */
  91501. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  91502. /**
  91503. * Bind a buffer to the current webGL context at a given location
  91504. * @param buffer defines the buffer to bind
  91505. * @param location defines the index where to bind the buffer
  91506. */
  91507. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  91508. /**
  91509. * Bind a specific block at a given index in a specific shader program
  91510. * @param pipelineContext defines the pipeline context to use
  91511. * @param blockName defines the block name
  91512. * @param index defines the index where to bind the block
  91513. */
  91514. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  91515. private bindIndexBuffer;
  91516. private bindBuffer;
  91517. /**
  91518. * update the bound buffer with the given data
  91519. * @param data defines the data to update
  91520. */
  91521. updateArrayBuffer(data: Float32Array): void;
  91522. private _vertexAttribPointer;
  91523. private _bindIndexBufferWithCache;
  91524. private _bindVertexBuffersAttributes;
  91525. /**
  91526. * Records a vertex array object
  91527. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91528. * @param vertexBuffers defines the list of vertex buffers to store
  91529. * @param indexBuffer defines the index buffer to store
  91530. * @param effect defines the effect to store
  91531. * @returns the new vertex array object
  91532. */
  91533. recordVertexArrayObject(vertexBuffers: {
  91534. [key: string]: VertexBuffer;
  91535. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  91536. /**
  91537. * Bind a specific vertex array object
  91538. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91539. * @param vertexArrayObject defines the vertex array object to bind
  91540. * @param indexBuffer defines the index buffer to bind
  91541. */
  91542. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  91543. /**
  91544. * Bind webGl buffers directly to the webGL context
  91545. * @param vertexBuffer defines the vertex buffer to bind
  91546. * @param indexBuffer defines the index buffer to bind
  91547. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  91548. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  91549. * @param effect defines the effect associated with the vertex buffer
  91550. */
  91551. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  91552. private _unbindVertexArrayObject;
  91553. /**
  91554. * Bind a list of vertex buffers to the webGL context
  91555. * @param vertexBuffers defines the list of vertex buffers to bind
  91556. * @param indexBuffer defines the index buffer to bind
  91557. * @param effect defines the effect associated with the vertex buffers
  91558. */
  91559. bindBuffers(vertexBuffers: {
  91560. [key: string]: Nullable<VertexBuffer>;
  91561. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  91562. /**
  91563. * Unbind all instance attributes
  91564. */
  91565. unbindInstanceAttributes(): void;
  91566. /**
  91567. * Release and free the memory of a vertex array object
  91568. * @param vao defines the vertex array object to delete
  91569. */
  91570. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  91571. /** @hidden */
  91572. _releaseBuffer(buffer: DataBuffer): boolean;
  91573. /**
  91574. * Creates a webGL buffer to use with instanciation
  91575. * @param capacity defines the size of the buffer
  91576. * @returns the webGL buffer
  91577. */
  91578. createInstancesBuffer(capacity: number): DataBuffer;
  91579. /**
  91580. * Delete a webGL buffer used with instanciation
  91581. * @param buffer defines the webGL buffer to delete
  91582. */
  91583. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  91584. /**
  91585. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  91586. * @param instancesBuffer defines the webGL buffer to update and bind
  91587. * @param data defines the data to store in the buffer
  91588. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  91589. */
  91590. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  91591. /**
  91592. * Apply all cached states (depth, culling, stencil and alpha)
  91593. */
  91594. applyStates(): void;
  91595. /**
  91596. * Send a draw order
  91597. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91598. * @param indexStart defines the starting index
  91599. * @param indexCount defines the number of index to draw
  91600. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91601. */
  91602. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  91603. /**
  91604. * Draw a list of points
  91605. * @param verticesStart defines the index of first vertex to draw
  91606. * @param verticesCount defines the count of vertices to draw
  91607. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91608. */
  91609. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91610. /**
  91611. * Draw a list of unindexed primitives
  91612. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91613. * @param verticesStart defines the index of first vertex to draw
  91614. * @param verticesCount defines the count of vertices to draw
  91615. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91616. */
  91617. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91618. /**
  91619. * Draw a list of indexed primitives
  91620. * @param fillMode defines the primitive to use
  91621. * @param indexStart defines the starting index
  91622. * @param indexCount defines the number of index to draw
  91623. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91624. */
  91625. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  91626. /**
  91627. * Draw a list of unindexed primitives
  91628. * @param fillMode defines the primitive to use
  91629. * @param verticesStart defines the index of first vertex to draw
  91630. * @param verticesCount defines the count of vertices to draw
  91631. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91632. */
  91633. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91634. private _drawMode;
  91635. /** @hidden */
  91636. _releaseEffect(effect: Effect): void;
  91637. /** @hidden */
  91638. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  91639. /**
  91640. * Create a new effect (used to store vertex/fragment shaders)
  91641. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  91642. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  91643. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  91644. * @param samplers defines an array of string used to represent textures
  91645. * @param defines defines the string containing the defines to use to compile the shaders
  91646. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  91647. * @param onCompiled defines a function to call when the effect creation is successful
  91648. * @param onError defines a function to call when the effect creation has failed
  91649. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  91650. * @returns the new Effect
  91651. */
  91652. 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;
  91653. private _compileShader;
  91654. private _compileRawShader;
  91655. /**
  91656. * Directly creates a webGL program
  91657. * @param pipelineContext defines the pipeline context to attach to
  91658. * @param vertexCode defines the vertex shader code to use
  91659. * @param fragmentCode defines the fragment shader code to use
  91660. * @param context defines the webGL context to use (if not set, the current one will be used)
  91661. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91662. * @returns the new webGL program
  91663. */
  91664. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91665. /**
  91666. * Creates a webGL program
  91667. * @param pipelineContext defines the pipeline context to attach to
  91668. * @param vertexCode defines the vertex shader code to use
  91669. * @param fragmentCode defines the fragment shader code to use
  91670. * @param defines defines the string containing the defines to use to compile the shaders
  91671. * @param context defines the webGL context to use (if not set, the current one will be used)
  91672. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91673. * @returns the new webGL program
  91674. */
  91675. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91676. /**
  91677. * Creates a new pipeline context
  91678. * @returns the new pipeline
  91679. */
  91680. createPipelineContext(): WebGLPipelineContext;
  91681. private _createShaderProgram;
  91682. private _finalizePipelineContext;
  91683. /** @hidden */
  91684. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  91685. /** @hidden */
  91686. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  91687. /** @hidden */
  91688. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  91689. /**
  91690. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  91691. * @param pipelineContext defines the pipeline context to use
  91692. * @param uniformsNames defines the list of uniform names
  91693. * @returns an array of webGL uniform locations
  91694. */
  91695. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  91696. /**
  91697. * Gets the lsit of active attributes for a given webGL program
  91698. * @param pipelineContext defines the pipeline context to use
  91699. * @param attributesNames defines the list of attribute names to get
  91700. * @returns an array of indices indicating the offset of each attribute
  91701. */
  91702. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  91703. /**
  91704. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  91705. * @param effect defines the effect to activate
  91706. */
  91707. enableEffect(effect: Nullable<Effect>): void;
  91708. /**
  91709. * Set the value of an uniform to an array of int32
  91710. * @param uniform defines the webGL uniform location where to store the value
  91711. * @param array defines the array of int32 to store
  91712. */
  91713. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91714. /**
  91715. * Set the value of an uniform to an array of int32 (stored as vec2)
  91716. * @param uniform defines the webGL uniform location where to store the value
  91717. * @param array defines the array of int32 to store
  91718. */
  91719. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91720. /**
  91721. * Set the value of an uniform to an array of int32 (stored as vec3)
  91722. * @param uniform defines the webGL uniform location where to store the value
  91723. * @param array defines the array of int32 to store
  91724. */
  91725. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91726. /**
  91727. * Set the value of an uniform to an array of int32 (stored as vec4)
  91728. * @param uniform defines the webGL uniform location where to store the value
  91729. * @param array defines the array of int32 to store
  91730. */
  91731. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91732. /**
  91733. * Set the value of an uniform to an array of float32
  91734. * @param uniform defines the webGL uniform location where to store the value
  91735. * @param array defines the array of float32 to store
  91736. */
  91737. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91738. /**
  91739. * Set the value of an uniform to an array of float32 (stored as vec2)
  91740. * @param uniform defines the webGL uniform location where to store the value
  91741. * @param array defines the array of float32 to store
  91742. */
  91743. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91744. /**
  91745. * Set the value of an uniform to an array of float32 (stored as vec3)
  91746. * @param uniform defines the webGL uniform location where to store the value
  91747. * @param array defines the array of float32 to store
  91748. */
  91749. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91750. /**
  91751. * Set the value of an uniform to an array of float32 (stored as vec4)
  91752. * @param uniform defines the webGL uniform location where to store the value
  91753. * @param array defines the array of float32 to store
  91754. */
  91755. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91756. /**
  91757. * Set the value of an uniform to an array of number
  91758. * @param uniform defines the webGL uniform location where to store the value
  91759. * @param array defines the array of number to store
  91760. */
  91761. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91762. /**
  91763. * Set the value of an uniform to an array of number (stored as vec2)
  91764. * @param uniform defines the webGL uniform location where to store the value
  91765. * @param array defines the array of number to store
  91766. */
  91767. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91768. /**
  91769. * Set the value of an uniform to an array of number (stored as vec3)
  91770. * @param uniform defines the webGL uniform location where to store the value
  91771. * @param array defines the array of number to store
  91772. */
  91773. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91774. /**
  91775. * Set the value of an uniform to an array of number (stored as vec4)
  91776. * @param uniform defines the webGL uniform location where to store the value
  91777. * @param array defines the array of number to store
  91778. */
  91779. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91780. /**
  91781. * Set the value of an uniform to an array of float32 (stored as matrices)
  91782. * @param uniform defines the webGL uniform location where to store the value
  91783. * @param matrices defines the array of float32 to store
  91784. */
  91785. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91786. /**
  91787. * Set the value of an uniform to a matrix
  91788. * @param uniform defines the webGL uniform location where to store the value
  91789. * @param matrix defines the matrix to store
  91790. */
  91791. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91792. /**
  91793. * Set the value of an uniform to a matrix (3x3)
  91794. * @param uniform defines the webGL uniform location where to store the value
  91795. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91796. */
  91797. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91798. /**
  91799. * Set the value of an uniform to a matrix (2x2)
  91800. * @param uniform defines the webGL uniform location where to store the value
  91801. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91802. */
  91803. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91804. /**
  91805. * Set the value of an uniform to a number (int)
  91806. * @param uniform defines the webGL uniform location where to store the value
  91807. * @param value defines the int number to store
  91808. */
  91809. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91810. /**
  91811. * Set the value of an uniform to a number (float)
  91812. * @param uniform defines the webGL uniform location where to store the value
  91813. * @param value defines the float number to store
  91814. */
  91815. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91816. /**
  91817. * Set the value of an uniform to a vec2
  91818. * @param uniform defines the webGL uniform location where to store the value
  91819. * @param x defines the 1st component of the value
  91820. * @param y defines the 2nd component of the value
  91821. */
  91822. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91823. /**
  91824. * Set the value of an uniform to a vec3
  91825. * @param uniform defines the webGL uniform location where to store the value
  91826. * @param x defines the 1st component of the value
  91827. * @param y defines the 2nd component of the value
  91828. * @param z defines the 3rd component of the value
  91829. */
  91830. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91831. /**
  91832. * Set the value of an uniform to a boolean
  91833. * @param uniform defines the webGL uniform location where to store the value
  91834. * @param bool defines the boolean to store
  91835. */
  91836. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91837. /**
  91838. * Set the value of an uniform to a vec4
  91839. * @param uniform defines the webGL uniform location where to store the value
  91840. * @param x defines the 1st component of the value
  91841. * @param y defines the 2nd component of the value
  91842. * @param z defines the 3rd component of the value
  91843. * @param w defines the 4th component of the value
  91844. */
  91845. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91846. /**
  91847. * Set the value of an uniform to a Color3
  91848. * @param uniform defines the webGL uniform location where to store the value
  91849. * @param color3 defines the color to store
  91850. */
  91851. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91852. /**
  91853. * Set the value of an uniform to a Color3 and an alpha value
  91854. * @param uniform defines the webGL uniform location where to store the value
  91855. * @param color3 defines the color to store
  91856. * @param alpha defines the alpha component to store
  91857. */
  91858. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91859. /**
  91860. * Sets a Color4 on a uniform variable
  91861. * @param uniform defines the uniform location
  91862. * @param color4 defines the value to be set
  91863. */
  91864. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91865. /**
  91866. * Set various states to the webGL context
  91867. * @param culling defines backface culling state
  91868. * @param zOffset defines the value to apply to zOffset (0 by default)
  91869. * @param force defines if states must be applied even if cache is up to date
  91870. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91871. */
  91872. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91873. /**
  91874. * Set the z offset to apply to current rendering
  91875. * @param value defines the offset to apply
  91876. */
  91877. setZOffset(value: number): void;
  91878. /**
  91879. * Gets the current value of the zOffset
  91880. * @returns the current zOffset state
  91881. */
  91882. getZOffset(): number;
  91883. /**
  91884. * Enable or disable depth buffering
  91885. * @param enable defines the state to set
  91886. */
  91887. setDepthBuffer(enable: boolean): void;
  91888. /**
  91889. * Gets a boolean indicating if depth writing is enabled
  91890. * @returns the current depth writing state
  91891. */
  91892. getDepthWrite(): boolean;
  91893. /**
  91894. * Enable or disable depth writing
  91895. * @param enable defines the state to set
  91896. */
  91897. setDepthWrite(enable: boolean): void;
  91898. /**
  91899. * Enable or disable color writing
  91900. * @param enable defines the state to set
  91901. */
  91902. setColorWrite(enable: boolean): void;
  91903. /**
  91904. * Gets a boolean indicating if color writing is enabled
  91905. * @returns the current color writing state
  91906. */
  91907. getColorWrite(): boolean;
  91908. /**
  91909. * Sets alpha constants used by some alpha blending modes
  91910. * @param r defines the red component
  91911. * @param g defines the green component
  91912. * @param b defines the blue component
  91913. * @param a defines the alpha component
  91914. */
  91915. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91916. /**
  91917. * Sets the current alpha mode
  91918. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91919. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91920. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91921. */
  91922. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91923. /**
  91924. * Gets the current alpha mode
  91925. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91926. * @returns the current alpha mode
  91927. */
  91928. getAlphaMode(): number;
  91929. /**
  91930. * Clears the list of texture accessible through engine.
  91931. * This can help preventing texture load conflict due to name collision.
  91932. */
  91933. clearInternalTexturesCache(): void;
  91934. /**
  91935. * Force the entire cache to be cleared
  91936. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91937. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91938. */
  91939. wipeCaches(bruteForce?: boolean): void;
  91940. /**
  91941. * Set the compressed texture format to use, based on the formats you have, and the formats
  91942. * supported by the hardware / browser.
  91943. *
  91944. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91945. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91946. * to API arguments needed to compressed textures. This puts the burden on the container
  91947. * generator to house the arcane code for determining these for current & future formats.
  91948. *
  91949. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91950. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91951. *
  91952. * Note: The result of this call is not taken into account when a texture is base64.
  91953. *
  91954. * @param formatsAvailable defines the list of those format families you have created
  91955. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91956. *
  91957. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91958. * @returns The extension selected.
  91959. */
  91960. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91961. /** @hidden */
  91962. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91963. min: number;
  91964. mag: number;
  91965. };
  91966. /** @hidden */
  91967. _createTexture(): WebGLTexture;
  91968. /**
  91969. * Usually called from Texture.ts.
  91970. * Passed information to create a WebGLTexture
  91971. * @param urlArg defines a value which contains one of the following:
  91972. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91973. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91974. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91975. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91976. * @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)
  91977. * @param scene needed for loading to the correct scene
  91978. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91979. * @param onLoad optional callback to be called upon successful completion
  91980. * @param onError optional callback to be called upon failure
  91981. * @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
  91982. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91983. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91984. * @param forcedExtension defines the extension to use to pick the right loader
  91985. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91986. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91987. */
  91988. 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;
  91989. /**
  91990. * @hidden
  91991. * Rescales a texture
  91992. * @param source input texutre
  91993. * @param destination destination texture
  91994. * @param scene scene to use to render the resize
  91995. * @param internalFormat format to use when resizing
  91996. * @param onComplete callback to be called when resize has completed
  91997. */
  91998. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  91999. private _unpackFlipYCached;
  92000. /**
  92001. * In case you are sharing the context with other applications, it might
  92002. * be interested to not cache the unpack flip y state to ensure a consistent
  92003. * value would be set.
  92004. */
  92005. enableUnpackFlipYCached: boolean;
  92006. /** @hidden */
  92007. _unpackFlipY(value: boolean): void;
  92008. /** @hidden */
  92009. _getUnpackAlignement(): number;
  92010. /**
  92011. * Creates a dynamic texture
  92012. * @param width defines the width of the texture
  92013. * @param height defines the height of the texture
  92014. * @param generateMipMaps defines if the engine should generate the mip levels
  92015. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  92016. * @returns the dynamic texture inside an InternalTexture
  92017. */
  92018. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  92019. /**
  92020. * Update the sampling mode of a given texture
  92021. * @param samplingMode defines the required sampling mode
  92022. * @param texture defines the texture to update
  92023. */
  92024. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  92025. /**
  92026. * Update the content of a dynamic texture
  92027. * @param texture defines the texture to update
  92028. * @param canvas defines the canvas containing the source
  92029. * @param invertY defines if data must be stored with Y axis inverted
  92030. * @param premulAlpha defines if alpha is stored as premultiplied
  92031. * @param format defines the format of the data
  92032. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  92033. */
  92034. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  92035. /**
  92036. * Update a video texture
  92037. * @param texture defines the texture to update
  92038. * @param video defines the video element to use
  92039. * @param invertY defines if data must be stored with Y axis inverted
  92040. */
  92041. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  92042. /**
  92043. * Updates a depth texture Comparison Mode and Function.
  92044. * If the comparison Function is equal to 0, the mode will be set to none.
  92045. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  92046. * @param texture The texture to set the comparison function for
  92047. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  92048. */
  92049. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  92050. /** @hidden */
  92051. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  92052. width: number;
  92053. height: number;
  92054. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  92055. /**
  92056. * Creates a depth stencil texture.
  92057. * This is only available in WebGL 2 or with the depth texture extension available.
  92058. * @param size The size of face edge in the texture.
  92059. * @param options The options defining the texture.
  92060. * @returns The texture
  92061. */
  92062. createDepthStencilTexture(size: number | {
  92063. width: number;
  92064. height: number;
  92065. }, options: DepthTextureCreationOptions): InternalTexture;
  92066. /**
  92067. * Creates a depth stencil texture.
  92068. * This is only available in WebGL 2 or with the depth texture extension available.
  92069. * @param size The size of face edge in the texture.
  92070. * @param options The options defining the texture.
  92071. * @returns The texture
  92072. */
  92073. private _createDepthStencilTexture;
  92074. /**
  92075. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  92076. * @param renderTarget The render target to set the frame buffer for
  92077. */
  92078. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  92079. /**
  92080. * Creates a new render target texture
  92081. * @param size defines the size of the texture
  92082. * @param options defines the options used to create the texture
  92083. * @returns a new render target texture stored in an InternalTexture
  92084. */
  92085. createRenderTargetTexture(size: number | {
  92086. width: number;
  92087. height: number;
  92088. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  92089. /** @hidden */
  92090. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  92091. /**
  92092. * Updates the sample count of a render target texture
  92093. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  92094. * @param texture defines the texture to update
  92095. * @param samples defines the sample count to set
  92096. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  92097. */
  92098. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  92099. /** @hidden */
  92100. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  92101. /** @hidden */
  92102. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  92103. /** @hidden */
  92104. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  92105. /** @hidden */
  92106. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  92107. /**
  92108. * @hidden
  92109. */
  92110. _setCubeMapTextureParams(loadMipmap: boolean): void;
  92111. private _prepareWebGLTextureContinuation;
  92112. private _prepareWebGLTexture;
  92113. /** @hidden */
  92114. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  92115. /** @hidden */
  92116. _releaseFramebufferObjects(texture: InternalTexture): void;
  92117. /** @hidden */
  92118. _releaseTexture(texture: InternalTexture): void;
  92119. private setProgram;
  92120. private _boundUniforms;
  92121. /**
  92122. * Binds an effect to the webGL context
  92123. * @param effect defines the effect to bind
  92124. */
  92125. bindSamplers(effect: Effect): void;
  92126. private _activateCurrentTexture;
  92127. /** @hidden */
  92128. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  92129. /** @hidden */
  92130. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  92131. /**
  92132. * Sets a texture to the webGL context from a postprocess
  92133. * @param channel defines the channel to use
  92134. * @param postProcess defines the source postprocess
  92135. */
  92136. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  92137. /**
  92138. * Binds the output of the passed in post process to the texture channel specified
  92139. * @param channel The channel the texture should be bound to
  92140. * @param postProcess The post process which's output should be bound
  92141. */
  92142. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  92143. /**
  92144. * Unbind all textures from the webGL context
  92145. */
  92146. unbindAllTextures(): void;
  92147. /**
  92148. * Sets a texture to the according uniform.
  92149. * @param channel The texture channel
  92150. * @param uniform The uniform to set
  92151. * @param texture The texture to apply
  92152. */
  92153. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  92154. /**
  92155. * Sets a depth stencil texture from a render target to the according uniform.
  92156. * @param channel The texture channel
  92157. * @param uniform The uniform to set
  92158. * @param texture The render target texture containing the depth stencil texture to apply
  92159. */
  92160. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  92161. private _bindSamplerUniformToChannel;
  92162. private _getTextureWrapMode;
  92163. private _setTexture;
  92164. /**
  92165. * Sets an array of texture to the webGL context
  92166. * @param channel defines the channel where the texture array must be set
  92167. * @param uniform defines the associated uniform location
  92168. * @param textures defines the array of textures to bind
  92169. */
  92170. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  92171. /** @hidden */
  92172. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  92173. private _setTextureParameterFloat;
  92174. private _setTextureParameterInteger;
  92175. /**
  92176. * Reads pixels from the current frame buffer. Please note that this function can be slow
  92177. * @param x defines the x coordinate of the rectangle where pixels must be read
  92178. * @param y defines the y coordinate of the rectangle where pixels must be read
  92179. * @param width defines the width of the rectangle where pixels must be read
  92180. * @param height defines the height of the rectangle where pixels must be read
  92181. * @returns a Uint8Array containing RGBA colors
  92182. */
  92183. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  92184. /**
  92185. * Add an externaly attached data from its key.
  92186. * This method call will fail and return false, if such key already exists.
  92187. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92188. * @param key the unique key that identifies the data
  92189. * @param data the data object to associate to the key for this Engine instance
  92190. * @return true if no such key were already present and the data was added successfully, false otherwise
  92191. */
  92192. addExternalData<T>(key: string, data: T): boolean;
  92193. /**
  92194. * Get an externaly attached data from its key
  92195. * @param key the unique key that identifies the data
  92196. * @return the associated data, if present (can be null), or undefined if not present
  92197. */
  92198. getExternalData<T>(key: string): T;
  92199. /**
  92200. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92201. * @param key the unique key that identifies the data
  92202. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92203. * @return the associated data, can be null if the factory returned null.
  92204. */
  92205. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92206. /**
  92207. * Remove an externaly attached data from the Engine instance
  92208. * @param key the unique key that identifies the data
  92209. * @return true if the data was successfully removed, false if it doesn't exist
  92210. */
  92211. removeExternalData(key: string): boolean;
  92212. /**
  92213. * Unbind all vertex attributes from the webGL context
  92214. */
  92215. unbindAllAttributes(): void;
  92216. /**
  92217. * 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
  92218. */
  92219. releaseEffects(): void;
  92220. /**
  92221. * Dispose and release all associated resources
  92222. */
  92223. dispose(): void;
  92224. /**
  92225. * Display the loading screen
  92226. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92227. */
  92228. displayLoadingUI(): void;
  92229. /**
  92230. * Hide the loading screen
  92231. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92232. */
  92233. hideLoadingUI(): void;
  92234. /**
  92235. * Gets the current loading screen object
  92236. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92237. */
  92238. /**
  92239. * Sets the current loading screen object
  92240. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92241. */
  92242. loadingScreen: ILoadingScreen;
  92243. /**
  92244. * Sets the current loading screen text
  92245. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92246. */
  92247. loadingUIText: string;
  92248. /**
  92249. * Sets the current loading screen background color
  92250. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92251. */
  92252. loadingUIBackgroundColor: string;
  92253. /**
  92254. * Attach a new callback raised when context lost event is fired
  92255. * @param callback defines the callback to call
  92256. */
  92257. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  92258. /**
  92259. * Attach a new callback raised when context restored event is fired
  92260. * @param callback defines the callback to call
  92261. */
  92262. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  92263. /**
  92264. * Gets the source code of the vertex shader associated with a specific webGL program
  92265. * @param program defines the program to use
  92266. * @returns a string containing the source code of the vertex shader associated with the program
  92267. */
  92268. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  92269. /**
  92270. * Gets the source code of the fragment shader associated with a specific webGL program
  92271. * @param program defines the program to use
  92272. * @returns a string containing the source code of the fragment shader associated with the program
  92273. */
  92274. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  92275. /**
  92276. * Get the current error code of the webGL context
  92277. * @returns the error code
  92278. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  92279. */
  92280. getError(): number;
  92281. /**
  92282. * Gets the current framerate
  92283. * @returns a number representing the framerate
  92284. */
  92285. getFps(): number;
  92286. /**
  92287. * Gets the time spent between current and previous frame
  92288. * @returns a number representing the delta time in ms
  92289. */
  92290. getDeltaTime(): number;
  92291. private _measureFps;
  92292. /** @hidden */
  92293. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  92294. private _canRenderToFloatFramebuffer;
  92295. private _canRenderToHalfFloatFramebuffer;
  92296. private _canRenderToFramebuffer;
  92297. /** @hidden */
  92298. _getWebGLTextureType(type: number): number;
  92299. /** @hidden */
  92300. _getInternalFormat(format: number): number;
  92301. /** @hidden */
  92302. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  92303. /** @hidden */
  92304. _getRGBAMultiSampleBufferFormat(type: number): number;
  92305. /** @hidden */
  92306. _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;
  92307. /** @hidden */
  92308. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92309. /**
  92310. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  92311. * @returns true if the engine can be created
  92312. * @ignorenaming
  92313. */
  92314. static isSupported(): boolean;
  92315. }
  92316. }
  92317. declare module BABYLON {
  92318. /**
  92319. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  92320. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  92321. */
  92322. export class EffectFallbacks {
  92323. private _defines;
  92324. private _currentRank;
  92325. private _maxRank;
  92326. private _mesh;
  92327. /**
  92328. * Removes the fallback from the bound mesh.
  92329. */
  92330. unBindMesh(): void;
  92331. /**
  92332. * Adds a fallback on the specified property.
  92333. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92334. * @param define The name of the define in the shader
  92335. */
  92336. addFallback(rank: number, define: string): void;
  92337. /**
  92338. * Sets the mesh to use CPU skinning when needing to fallback.
  92339. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92340. * @param mesh The mesh to use the fallbacks.
  92341. */
  92342. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92343. /**
  92344. * Checks to see if more fallbacks are still availible.
  92345. */
  92346. readonly isMoreFallbacks: boolean;
  92347. /**
  92348. * Removes the defines that should be removed when falling back.
  92349. * @param currentDefines defines the current define statements for the shader.
  92350. * @param effect defines the current effect we try to compile
  92351. * @returns The resulting defines with defines of the current rank removed.
  92352. */
  92353. reduce(currentDefines: string, effect: Effect): string;
  92354. }
  92355. /**
  92356. * Options to be used when creating an effect.
  92357. */
  92358. export class EffectCreationOptions {
  92359. /**
  92360. * Atrributes that will be used in the shader.
  92361. */
  92362. attributes: string[];
  92363. /**
  92364. * Uniform varible names that will be set in the shader.
  92365. */
  92366. uniformsNames: string[];
  92367. /**
  92368. * Uniform buffer varible names that will be set in the shader.
  92369. */
  92370. uniformBuffersNames: string[];
  92371. /**
  92372. * Sampler texture variable names that will be set in the shader.
  92373. */
  92374. samplers: string[];
  92375. /**
  92376. * Define statements that will be set in the shader.
  92377. */
  92378. defines: any;
  92379. /**
  92380. * Possible fallbacks for this effect to improve performance when needed.
  92381. */
  92382. fallbacks: Nullable<EffectFallbacks>;
  92383. /**
  92384. * Callback that will be called when the shader is compiled.
  92385. */
  92386. onCompiled: Nullable<(effect: Effect) => void>;
  92387. /**
  92388. * Callback that will be called if an error occurs during shader compilation.
  92389. */
  92390. onError: Nullable<(effect: Effect, errors: string) => void>;
  92391. /**
  92392. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92393. */
  92394. indexParameters: any;
  92395. /**
  92396. * Max number of lights that can be used in the shader.
  92397. */
  92398. maxSimultaneousLights: number;
  92399. /**
  92400. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92401. */
  92402. transformFeedbackVaryings: Nullable<string[]>;
  92403. }
  92404. /**
  92405. * Effect containing vertex and fragment shader that can be executed on an object.
  92406. */
  92407. export class Effect implements IDisposable {
  92408. /**
  92409. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92410. */
  92411. static ShadersRepository: string;
  92412. /**
  92413. * Name of the effect.
  92414. */
  92415. name: any;
  92416. /**
  92417. * String container all the define statements that should be set on the shader.
  92418. */
  92419. defines: string;
  92420. /**
  92421. * Callback that will be called when the shader is compiled.
  92422. */
  92423. onCompiled: Nullable<(effect: Effect) => void>;
  92424. /**
  92425. * Callback that will be called if an error occurs during shader compilation.
  92426. */
  92427. onError: Nullable<(effect: Effect, errors: string) => void>;
  92428. /**
  92429. * Callback that will be called when effect is bound.
  92430. */
  92431. onBind: Nullable<(effect: Effect) => void>;
  92432. /**
  92433. * Unique ID of the effect.
  92434. */
  92435. uniqueId: number;
  92436. /**
  92437. * Observable that will be called when the shader is compiled.
  92438. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92439. */
  92440. onCompileObservable: Observable<Effect>;
  92441. /**
  92442. * Observable that will be called if an error occurs during shader compilation.
  92443. */
  92444. onErrorObservable: Observable<Effect>;
  92445. /** @hidden */
  92446. _onBindObservable: Nullable<Observable<Effect>>;
  92447. /**
  92448. * Observable that will be called when effect is bound.
  92449. */
  92450. readonly onBindObservable: Observable<Effect>;
  92451. /** @hidden */
  92452. _bonesComputationForcedToCPU: boolean;
  92453. private static _uniqueIdSeed;
  92454. private _engine;
  92455. private _uniformBuffersNames;
  92456. private _uniformsNames;
  92457. private _samplerList;
  92458. private _samplers;
  92459. private _isReady;
  92460. private _compilationError;
  92461. private _attributesNames;
  92462. private _attributes;
  92463. private _uniforms;
  92464. /**
  92465. * Key for the effect.
  92466. * @hidden
  92467. */
  92468. _key: string;
  92469. private _indexParameters;
  92470. private _fallbacks;
  92471. private _vertexSourceCode;
  92472. private _fragmentSourceCode;
  92473. private _vertexSourceCodeOverride;
  92474. private _fragmentSourceCodeOverride;
  92475. private _transformFeedbackVaryings;
  92476. /**
  92477. * Compiled shader to webGL program.
  92478. * @hidden
  92479. */
  92480. _pipelineContext: Nullable<IPipelineContext>;
  92481. private _valueCache;
  92482. private static _baseCache;
  92483. /**
  92484. * Instantiates an effect.
  92485. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92486. * @param baseName Name of the effect.
  92487. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92488. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92489. * @param samplers List of sampler variables that will be passed to the shader.
  92490. * @param engine Engine to be used to render the effect
  92491. * @param defines Define statements to be added to the shader.
  92492. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92493. * @param onCompiled Callback that will be called when the shader is compiled.
  92494. * @param onError Callback that will be called if an error occurs during shader compilation.
  92495. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92496. */
  92497. 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);
  92498. private _useFinalCode;
  92499. /**
  92500. * Unique key for this effect
  92501. */
  92502. readonly key: string;
  92503. /**
  92504. * If the effect has been compiled and prepared.
  92505. * @returns if the effect is compiled and prepared.
  92506. */
  92507. isReady(): boolean;
  92508. /**
  92509. * The engine the effect was initialized with.
  92510. * @returns the engine.
  92511. */
  92512. getEngine(): Engine;
  92513. /**
  92514. * The pipeline context for this effect
  92515. * @returns the associated pipeline context
  92516. */
  92517. getPipelineContext(): Nullable<IPipelineContext>;
  92518. /**
  92519. * The set of names of attribute variables for the shader.
  92520. * @returns An array of attribute names.
  92521. */
  92522. getAttributesNames(): string[];
  92523. /**
  92524. * Returns the attribute at the given index.
  92525. * @param index The index of the attribute.
  92526. * @returns The location of the attribute.
  92527. */
  92528. getAttributeLocation(index: number): number;
  92529. /**
  92530. * Returns the attribute based on the name of the variable.
  92531. * @param name of the attribute to look up.
  92532. * @returns the attribute location.
  92533. */
  92534. getAttributeLocationByName(name: string): number;
  92535. /**
  92536. * The number of attributes.
  92537. * @returns the numnber of attributes.
  92538. */
  92539. getAttributesCount(): number;
  92540. /**
  92541. * Gets the index of a uniform variable.
  92542. * @param uniformName of the uniform to look up.
  92543. * @returns the index.
  92544. */
  92545. getUniformIndex(uniformName: string): number;
  92546. /**
  92547. * Returns the attribute based on the name of the variable.
  92548. * @param uniformName of the uniform to look up.
  92549. * @returns the location of the uniform.
  92550. */
  92551. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92552. /**
  92553. * Returns an array of sampler variable names
  92554. * @returns The array of sampler variable neames.
  92555. */
  92556. getSamplers(): string[];
  92557. /**
  92558. * The error from the last compilation.
  92559. * @returns the error string.
  92560. */
  92561. getCompilationError(): string;
  92562. /**
  92563. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92564. * @param func The callback to be used.
  92565. */
  92566. executeWhenCompiled(func: (effect: Effect) => void): void;
  92567. private _checkIsReady;
  92568. /** @hidden */
  92569. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92570. /** @hidden */
  92571. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92572. /** @hidden */
  92573. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92574. /**
  92575. * Recompiles the webGL program
  92576. * @param vertexSourceCode The source code for the vertex shader.
  92577. * @param fragmentSourceCode The source code for the fragment shader.
  92578. * @param onCompiled Callback called when completed.
  92579. * @param onError Callback called on error.
  92580. * @hidden
  92581. */
  92582. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92583. /**
  92584. * Prepares the effect
  92585. * @hidden
  92586. */
  92587. _prepareEffect(): void;
  92588. /**
  92589. * Checks if the effect is supported. (Must be called after compilation)
  92590. */
  92591. readonly isSupported: boolean;
  92592. /**
  92593. * Binds a texture to the engine to be used as output of the shader.
  92594. * @param channel Name of the output variable.
  92595. * @param texture Texture to bind.
  92596. * @hidden
  92597. */
  92598. _bindTexture(channel: string, texture: InternalTexture): void;
  92599. /**
  92600. * Sets a texture on the engine to be used in the shader.
  92601. * @param channel Name of the sampler variable.
  92602. * @param texture Texture to set.
  92603. */
  92604. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92605. /**
  92606. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92607. * @param channel Name of the sampler variable.
  92608. * @param texture Texture to set.
  92609. */
  92610. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92611. /**
  92612. * Sets an array of textures on the engine to be used in the shader.
  92613. * @param channel Name of the variable.
  92614. * @param textures Textures to set.
  92615. */
  92616. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92617. /**
  92618. * 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)
  92619. * @param channel Name of the sampler variable.
  92620. * @param postProcess Post process to get the input texture from.
  92621. */
  92622. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92623. /**
  92624. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92625. * 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)
  92626. * @param channel Name of the sampler variable.
  92627. * @param postProcess Post process to get the output texture from.
  92628. */
  92629. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92630. /** @hidden */
  92631. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  92632. /** @hidden */
  92633. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92634. /** @hidden */
  92635. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92636. /** @hidden */
  92637. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92638. /**
  92639. * Binds a buffer to a uniform.
  92640. * @param buffer Buffer to bind.
  92641. * @param name Name of the uniform variable to bind to.
  92642. */
  92643. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92644. /**
  92645. * Binds block to a uniform.
  92646. * @param blockName Name of the block to bind.
  92647. * @param index Index to bind.
  92648. */
  92649. bindUniformBlock(blockName: string, index: number): void;
  92650. /**
  92651. * Sets an interger value on a uniform variable.
  92652. * @param uniformName Name of the variable.
  92653. * @param value Value to be set.
  92654. * @returns this effect.
  92655. */
  92656. setInt(uniformName: string, value: number): Effect;
  92657. /**
  92658. * Sets an int array on a uniform variable.
  92659. * @param uniformName Name of the variable.
  92660. * @param array array to be set.
  92661. * @returns this effect.
  92662. */
  92663. setIntArray(uniformName: string, array: Int32Array): Effect;
  92664. /**
  92665. * 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)
  92666. * @param uniformName Name of the variable.
  92667. * @param array array to be set.
  92668. * @returns this effect.
  92669. */
  92670. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92671. /**
  92672. * 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)
  92673. * @param uniformName Name of the variable.
  92674. * @param array array to be set.
  92675. * @returns this effect.
  92676. */
  92677. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92678. /**
  92679. * 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)
  92680. * @param uniformName Name of the variable.
  92681. * @param array array to be set.
  92682. * @returns this effect.
  92683. */
  92684. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92685. /**
  92686. * Sets an float array on a uniform variable.
  92687. * @param uniformName Name of the variable.
  92688. * @param array array to be set.
  92689. * @returns this effect.
  92690. */
  92691. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92692. /**
  92693. * 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)
  92694. * @param uniformName Name of the variable.
  92695. * @param array array to be set.
  92696. * @returns this effect.
  92697. */
  92698. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92699. /**
  92700. * 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)
  92701. * @param uniformName Name of the variable.
  92702. * @param array array to be set.
  92703. * @returns this effect.
  92704. */
  92705. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92706. /**
  92707. * 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)
  92708. * @param uniformName Name of the variable.
  92709. * @param array array to be set.
  92710. * @returns this effect.
  92711. */
  92712. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92713. /**
  92714. * Sets an array on a uniform variable.
  92715. * @param uniformName Name of the variable.
  92716. * @param array array to be set.
  92717. * @returns this effect.
  92718. */
  92719. setArray(uniformName: string, array: number[]): Effect;
  92720. /**
  92721. * 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)
  92722. * @param uniformName Name of the variable.
  92723. * @param array array to be set.
  92724. * @returns this effect.
  92725. */
  92726. setArray2(uniformName: string, array: number[]): Effect;
  92727. /**
  92728. * 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)
  92729. * @param uniformName Name of the variable.
  92730. * @param array array to be set.
  92731. * @returns this effect.
  92732. */
  92733. setArray3(uniformName: string, array: number[]): Effect;
  92734. /**
  92735. * 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)
  92736. * @param uniformName Name of the variable.
  92737. * @param array array to be set.
  92738. * @returns this effect.
  92739. */
  92740. setArray4(uniformName: string, array: number[]): Effect;
  92741. /**
  92742. * Sets matrices on a uniform variable.
  92743. * @param uniformName Name of the variable.
  92744. * @param matrices matrices to be set.
  92745. * @returns this effect.
  92746. */
  92747. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92748. /**
  92749. * Sets matrix on a uniform variable.
  92750. * @param uniformName Name of the variable.
  92751. * @param matrix matrix to be set.
  92752. * @returns this effect.
  92753. */
  92754. setMatrix(uniformName: string, matrix: Matrix): Effect;
  92755. /**
  92756. * 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)
  92757. * @param uniformName Name of the variable.
  92758. * @param matrix matrix to be set.
  92759. * @returns this effect.
  92760. */
  92761. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92762. /**
  92763. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92764. * @param uniformName Name of the variable.
  92765. * @param matrix matrix to be set.
  92766. * @returns this effect.
  92767. */
  92768. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92769. /**
  92770. * Sets a float on a uniform variable.
  92771. * @param uniformName Name of the variable.
  92772. * @param value value to be set.
  92773. * @returns this effect.
  92774. */
  92775. setFloat(uniformName: string, value: number): Effect;
  92776. /**
  92777. * Sets a boolean on a uniform variable.
  92778. * @param uniformName Name of the variable.
  92779. * @param bool value to be set.
  92780. * @returns this effect.
  92781. */
  92782. setBool(uniformName: string, bool: boolean): Effect;
  92783. /**
  92784. * Sets a Vector2 on a uniform variable.
  92785. * @param uniformName Name of the variable.
  92786. * @param vector2 vector2 to be set.
  92787. * @returns this effect.
  92788. */
  92789. setVector2(uniformName: string, vector2: Vector2): Effect;
  92790. /**
  92791. * Sets a float2 on a uniform variable.
  92792. * @param uniformName Name of the variable.
  92793. * @param x First float in float2.
  92794. * @param y Second float in float2.
  92795. * @returns this effect.
  92796. */
  92797. setFloat2(uniformName: string, x: number, y: number): Effect;
  92798. /**
  92799. * Sets a Vector3 on a uniform variable.
  92800. * @param uniformName Name of the variable.
  92801. * @param vector3 Value to be set.
  92802. * @returns this effect.
  92803. */
  92804. setVector3(uniformName: string, vector3: Vector3): Effect;
  92805. /**
  92806. * Sets a float3 on a uniform variable.
  92807. * @param uniformName Name of the variable.
  92808. * @param x First float in float3.
  92809. * @param y Second float in float3.
  92810. * @param z Third float in float3.
  92811. * @returns this effect.
  92812. */
  92813. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92814. /**
  92815. * Sets a Vector4 on a uniform variable.
  92816. * @param uniformName Name of the variable.
  92817. * @param vector4 Value to be set.
  92818. * @returns this effect.
  92819. */
  92820. setVector4(uniformName: string, vector4: Vector4): Effect;
  92821. /**
  92822. * Sets a float4 on a uniform variable.
  92823. * @param uniformName Name of the variable.
  92824. * @param x First float in float4.
  92825. * @param y Second float in float4.
  92826. * @param z Third float in float4.
  92827. * @param w Fourth float in float4.
  92828. * @returns this effect.
  92829. */
  92830. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92831. /**
  92832. * Sets a Color3 on a uniform variable.
  92833. * @param uniformName Name of the variable.
  92834. * @param color3 Value to be set.
  92835. * @returns this effect.
  92836. */
  92837. setColor3(uniformName: string, color3: Color3): Effect;
  92838. /**
  92839. * Sets a Color4 on a uniform variable.
  92840. * @param uniformName Name of the variable.
  92841. * @param color3 Value to be set.
  92842. * @param alpha Alpha value to be set.
  92843. * @returns this effect.
  92844. */
  92845. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92846. /**
  92847. * Sets a Color4 on a uniform variable
  92848. * @param uniformName defines the name of the variable
  92849. * @param color4 defines the value to be set
  92850. * @returns this effect.
  92851. */
  92852. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92853. /** Release all associated resources */
  92854. dispose(): void;
  92855. /**
  92856. * This function will add a new shader to the shader store
  92857. * @param name the name of the shader
  92858. * @param pixelShader optional pixel shader content
  92859. * @param vertexShader optional vertex shader content
  92860. */
  92861. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92862. /**
  92863. * Store of each shader (The can be looked up using effect.key)
  92864. */
  92865. static ShadersStore: {
  92866. [key: string]: string;
  92867. };
  92868. /**
  92869. * Store of each included file for a shader (The can be looked up using effect.key)
  92870. */
  92871. static IncludesShadersStore: {
  92872. [key: string]: string;
  92873. };
  92874. /**
  92875. * Resets the cache of effects.
  92876. */
  92877. static ResetCache(): void;
  92878. }
  92879. }
  92880. declare module BABYLON {
  92881. /**
  92882. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92883. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92884. * 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;
  92885. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92886. */
  92887. export class ColorCurves {
  92888. private _dirty;
  92889. private _tempColor;
  92890. private _globalCurve;
  92891. private _highlightsCurve;
  92892. private _midtonesCurve;
  92893. private _shadowsCurve;
  92894. private _positiveCurve;
  92895. private _negativeCurve;
  92896. private _globalHue;
  92897. private _globalDensity;
  92898. private _globalSaturation;
  92899. private _globalExposure;
  92900. /**
  92901. * Gets the global Hue value.
  92902. * 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).
  92903. */
  92904. /**
  92905. * Sets the global Hue value.
  92906. * 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).
  92907. */
  92908. globalHue: number;
  92909. /**
  92910. * Gets the global Density value.
  92911. * 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.
  92912. * Values less than zero provide a filter of opposite hue.
  92913. */
  92914. /**
  92915. * Sets the global Density value.
  92916. * 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.
  92917. * Values less than zero provide a filter of opposite hue.
  92918. */
  92919. globalDensity: number;
  92920. /**
  92921. * Gets the global Saturation value.
  92922. * 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.
  92923. */
  92924. /**
  92925. * Sets the global Saturation value.
  92926. * 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.
  92927. */
  92928. globalSaturation: number;
  92929. /**
  92930. * Gets the global Exposure value.
  92931. * 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.
  92932. */
  92933. /**
  92934. * Sets the global Exposure value.
  92935. * 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.
  92936. */
  92937. globalExposure: number;
  92938. private _highlightsHue;
  92939. private _highlightsDensity;
  92940. private _highlightsSaturation;
  92941. private _highlightsExposure;
  92942. /**
  92943. * Gets the highlights Hue value.
  92944. * 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).
  92945. */
  92946. /**
  92947. * Sets the highlights Hue value.
  92948. * 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).
  92949. */
  92950. highlightsHue: number;
  92951. /**
  92952. * Gets the highlights Density value.
  92953. * 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.
  92954. * Values less than zero provide a filter of opposite hue.
  92955. */
  92956. /**
  92957. * Sets the highlights Density value.
  92958. * 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.
  92959. * Values less than zero provide a filter of opposite hue.
  92960. */
  92961. highlightsDensity: number;
  92962. /**
  92963. * Gets the highlights Saturation value.
  92964. * 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.
  92965. */
  92966. /**
  92967. * Sets the highlights Saturation value.
  92968. * 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.
  92969. */
  92970. highlightsSaturation: number;
  92971. /**
  92972. * Gets the highlights Exposure value.
  92973. * 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.
  92974. */
  92975. /**
  92976. * Sets the highlights Exposure value.
  92977. * 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.
  92978. */
  92979. highlightsExposure: number;
  92980. private _midtonesHue;
  92981. private _midtonesDensity;
  92982. private _midtonesSaturation;
  92983. private _midtonesExposure;
  92984. /**
  92985. * Gets the midtones Hue value.
  92986. * 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).
  92987. */
  92988. /**
  92989. * Sets the midtones Hue value.
  92990. * 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).
  92991. */
  92992. midtonesHue: number;
  92993. /**
  92994. * Gets the midtones Density value.
  92995. * 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.
  92996. * Values less than zero provide a filter of opposite hue.
  92997. */
  92998. /**
  92999. * Sets the midtones Density value.
  93000. * 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.
  93001. * Values less than zero provide a filter of opposite hue.
  93002. */
  93003. midtonesDensity: number;
  93004. /**
  93005. * Gets the midtones Saturation value.
  93006. * 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.
  93007. */
  93008. /**
  93009. * Sets the midtones Saturation value.
  93010. * 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.
  93011. */
  93012. midtonesSaturation: number;
  93013. /**
  93014. * Gets the midtones Exposure value.
  93015. * 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.
  93016. */
  93017. /**
  93018. * Sets the midtones Exposure value.
  93019. * 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.
  93020. */
  93021. midtonesExposure: number;
  93022. private _shadowsHue;
  93023. private _shadowsDensity;
  93024. private _shadowsSaturation;
  93025. private _shadowsExposure;
  93026. /**
  93027. * Gets the shadows Hue value.
  93028. * 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).
  93029. */
  93030. /**
  93031. * Sets the shadows Hue value.
  93032. * 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).
  93033. */
  93034. shadowsHue: number;
  93035. /**
  93036. * Gets the shadows Density value.
  93037. * 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.
  93038. * Values less than zero provide a filter of opposite hue.
  93039. */
  93040. /**
  93041. * Sets the shadows Density value.
  93042. * 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.
  93043. * Values less than zero provide a filter of opposite hue.
  93044. */
  93045. shadowsDensity: number;
  93046. /**
  93047. * Gets the shadows Saturation value.
  93048. * 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.
  93049. */
  93050. /**
  93051. * Sets the shadows Saturation value.
  93052. * 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.
  93053. */
  93054. shadowsSaturation: number;
  93055. /**
  93056. * Gets the shadows Exposure value.
  93057. * 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.
  93058. */
  93059. /**
  93060. * Sets the shadows Exposure value.
  93061. * 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.
  93062. */
  93063. shadowsExposure: number;
  93064. /**
  93065. * Returns the class name
  93066. * @returns The class name
  93067. */
  93068. getClassName(): string;
  93069. /**
  93070. * Binds the color curves to the shader.
  93071. * @param colorCurves The color curve to bind
  93072. * @param effect The effect to bind to
  93073. * @param positiveUniform The positive uniform shader parameter
  93074. * @param neutralUniform The neutral uniform shader parameter
  93075. * @param negativeUniform The negative uniform shader parameter
  93076. */
  93077. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  93078. /**
  93079. * Prepare the list of uniforms associated with the ColorCurves effects.
  93080. * @param uniformsList The list of uniforms used in the effect
  93081. */
  93082. static PrepareUniforms(uniformsList: string[]): void;
  93083. /**
  93084. * Returns color grading data based on a hue, density, saturation and exposure value.
  93085. * @param filterHue The hue of the color filter.
  93086. * @param filterDensity The density of the color filter.
  93087. * @param saturation The saturation.
  93088. * @param exposure The exposure.
  93089. * @param result The result data container.
  93090. */
  93091. private getColorGradingDataToRef;
  93092. /**
  93093. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  93094. * @param value The input slider value in range [-100,100].
  93095. * @returns Adjusted value.
  93096. */
  93097. private static applyColorGradingSliderNonlinear;
  93098. /**
  93099. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  93100. * @param hue The hue (H) input.
  93101. * @param saturation The saturation (S) input.
  93102. * @param brightness The brightness (B) input.
  93103. * @result An RGBA color represented as Vector4.
  93104. */
  93105. private static fromHSBToRef;
  93106. /**
  93107. * Returns a value clamped between min and max
  93108. * @param value The value to clamp
  93109. * @param min The minimum of value
  93110. * @param max The maximum of value
  93111. * @returns The clamped value.
  93112. */
  93113. private static clamp;
  93114. /**
  93115. * Clones the current color curve instance.
  93116. * @return The cloned curves
  93117. */
  93118. clone(): ColorCurves;
  93119. /**
  93120. * Serializes the current color curve instance to a json representation.
  93121. * @return a JSON representation
  93122. */
  93123. serialize(): any;
  93124. /**
  93125. * Parses the color curve from a json representation.
  93126. * @param source the JSON source to parse
  93127. * @return The parsed curves
  93128. */
  93129. static Parse(source: any): ColorCurves;
  93130. }
  93131. }
  93132. declare module BABYLON {
  93133. /**
  93134. * Interface to follow in your material defines to integrate easily the
  93135. * Image proccessing functions.
  93136. * @hidden
  93137. */
  93138. export interface IImageProcessingConfigurationDefines {
  93139. IMAGEPROCESSING: boolean;
  93140. VIGNETTE: boolean;
  93141. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93142. VIGNETTEBLENDMODEOPAQUE: boolean;
  93143. TONEMAPPING: boolean;
  93144. TONEMAPPING_ACES: boolean;
  93145. CONTRAST: boolean;
  93146. EXPOSURE: boolean;
  93147. COLORCURVES: boolean;
  93148. COLORGRADING: boolean;
  93149. COLORGRADING3D: boolean;
  93150. SAMPLER3DGREENDEPTH: boolean;
  93151. SAMPLER3DBGRMAP: boolean;
  93152. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93153. }
  93154. /**
  93155. * @hidden
  93156. */
  93157. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  93158. IMAGEPROCESSING: boolean;
  93159. VIGNETTE: boolean;
  93160. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93161. VIGNETTEBLENDMODEOPAQUE: boolean;
  93162. TONEMAPPING: boolean;
  93163. TONEMAPPING_ACES: boolean;
  93164. CONTRAST: boolean;
  93165. COLORCURVES: boolean;
  93166. COLORGRADING: boolean;
  93167. COLORGRADING3D: boolean;
  93168. SAMPLER3DGREENDEPTH: boolean;
  93169. SAMPLER3DBGRMAP: boolean;
  93170. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93171. EXPOSURE: boolean;
  93172. constructor();
  93173. }
  93174. /**
  93175. * This groups together the common properties used for image processing either in direct forward pass
  93176. * or through post processing effect depending on the use of the image processing pipeline in your scene
  93177. * or not.
  93178. */
  93179. export class ImageProcessingConfiguration {
  93180. /**
  93181. * Default tone mapping applied in BabylonJS.
  93182. */
  93183. static readonly TONEMAPPING_STANDARD: number;
  93184. /**
  93185. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  93186. * to other engines rendering to increase portability.
  93187. */
  93188. static readonly TONEMAPPING_ACES: number;
  93189. /**
  93190. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  93191. */
  93192. colorCurves: Nullable<ColorCurves>;
  93193. private _colorCurvesEnabled;
  93194. /**
  93195. * Gets wether the color curves effect is enabled.
  93196. */
  93197. /**
  93198. * Sets wether the color curves effect is enabled.
  93199. */
  93200. colorCurvesEnabled: boolean;
  93201. private _colorGradingTexture;
  93202. /**
  93203. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  93204. */
  93205. /**
  93206. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  93207. */
  93208. colorGradingTexture: Nullable<BaseTexture>;
  93209. private _colorGradingEnabled;
  93210. /**
  93211. * Gets wether the color grading effect is enabled.
  93212. */
  93213. /**
  93214. * Sets wether the color grading effect is enabled.
  93215. */
  93216. colorGradingEnabled: boolean;
  93217. private _colorGradingWithGreenDepth;
  93218. /**
  93219. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  93220. */
  93221. /**
  93222. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  93223. */
  93224. colorGradingWithGreenDepth: boolean;
  93225. private _colorGradingBGR;
  93226. /**
  93227. * Gets wether the color grading texture contains BGR values.
  93228. */
  93229. /**
  93230. * Sets wether the color grading texture contains BGR values.
  93231. */
  93232. colorGradingBGR: boolean;
  93233. /** @hidden */
  93234. _exposure: number;
  93235. /**
  93236. * Gets the Exposure used in the effect.
  93237. */
  93238. /**
  93239. * Sets the Exposure used in the effect.
  93240. */
  93241. exposure: number;
  93242. private _toneMappingEnabled;
  93243. /**
  93244. * Gets wether the tone mapping effect is enabled.
  93245. */
  93246. /**
  93247. * Sets wether the tone mapping effect is enabled.
  93248. */
  93249. toneMappingEnabled: boolean;
  93250. private _toneMappingType;
  93251. /**
  93252. * Gets the type of tone mapping effect.
  93253. */
  93254. /**
  93255. * Sets the type of tone mapping effect used in BabylonJS.
  93256. */
  93257. toneMappingType: number;
  93258. protected _contrast: number;
  93259. /**
  93260. * Gets the contrast used in the effect.
  93261. */
  93262. /**
  93263. * Sets the contrast used in the effect.
  93264. */
  93265. contrast: number;
  93266. /**
  93267. * Vignette stretch size.
  93268. */
  93269. vignetteStretch: number;
  93270. /**
  93271. * Vignette centre X Offset.
  93272. */
  93273. vignetteCentreX: number;
  93274. /**
  93275. * Vignette centre Y Offset.
  93276. */
  93277. vignetteCentreY: number;
  93278. /**
  93279. * Vignette weight or intensity of the vignette effect.
  93280. */
  93281. vignetteWeight: number;
  93282. /**
  93283. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  93284. * if vignetteEnabled is set to true.
  93285. */
  93286. vignetteColor: Color4;
  93287. /**
  93288. * Camera field of view used by the Vignette effect.
  93289. */
  93290. vignetteCameraFov: number;
  93291. private _vignetteBlendMode;
  93292. /**
  93293. * Gets the vignette blend mode allowing different kind of effect.
  93294. */
  93295. /**
  93296. * Sets the vignette blend mode allowing different kind of effect.
  93297. */
  93298. vignetteBlendMode: number;
  93299. private _vignetteEnabled;
  93300. /**
  93301. * Gets wether the vignette effect is enabled.
  93302. */
  93303. /**
  93304. * Sets wether the vignette effect is enabled.
  93305. */
  93306. vignetteEnabled: boolean;
  93307. private _applyByPostProcess;
  93308. /**
  93309. * Gets wether the image processing is applied through a post process or not.
  93310. */
  93311. /**
  93312. * Sets wether the image processing is applied through a post process or not.
  93313. */
  93314. applyByPostProcess: boolean;
  93315. private _isEnabled;
  93316. /**
  93317. * Gets wether the image processing is enabled or not.
  93318. */
  93319. /**
  93320. * Sets wether the image processing is enabled or not.
  93321. */
  93322. isEnabled: boolean;
  93323. /**
  93324. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  93325. */
  93326. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  93327. /**
  93328. * Method called each time the image processing information changes requires to recompile the effect.
  93329. */
  93330. protected _updateParameters(): void;
  93331. /**
  93332. * Gets the current class name.
  93333. * @return "ImageProcessingConfiguration"
  93334. */
  93335. getClassName(): string;
  93336. /**
  93337. * Prepare the list of uniforms associated with the Image Processing effects.
  93338. * @param uniforms The list of uniforms used in the effect
  93339. * @param defines the list of defines currently in use
  93340. */
  93341. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  93342. /**
  93343. * Prepare the list of samplers associated with the Image Processing effects.
  93344. * @param samplersList The list of uniforms used in the effect
  93345. * @param defines the list of defines currently in use
  93346. */
  93347. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  93348. /**
  93349. * Prepare the list of defines associated to the shader.
  93350. * @param defines the list of defines to complete
  93351. * @param forPostProcess Define if we are currently in post process mode or not
  93352. */
  93353. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  93354. /**
  93355. * Returns true if all the image processing information are ready.
  93356. * @returns True if ready, otherwise, false
  93357. */
  93358. isReady(): boolean;
  93359. /**
  93360. * Binds the image processing to the shader.
  93361. * @param effect The effect to bind to
  93362. * @param aspectRatio Define the current aspect ratio of the effect
  93363. */
  93364. bind(effect: Effect, aspectRatio?: number): void;
  93365. /**
  93366. * Clones the current image processing instance.
  93367. * @return The cloned image processing
  93368. */
  93369. clone(): ImageProcessingConfiguration;
  93370. /**
  93371. * Serializes the current image processing instance to a json representation.
  93372. * @return a JSON representation
  93373. */
  93374. serialize(): any;
  93375. /**
  93376. * Parses the image processing from a json representation.
  93377. * @param source the JSON source to parse
  93378. * @return The parsed image processing
  93379. */
  93380. static Parse(source: any): ImageProcessingConfiguration;
  93381. private static _VIGNETTEMODE_MULTIPLY;
  93382. private static _VIGNETTEMODE_OPAQUE;
  93383. /**
  93384. * Used to apply the vignette as a mix with the pixel color.
  93385. */
  93386. static readonly VIGNETTEMODE_MULTIPLY: number;
  93387. /**
  93388. * Used to apply the vignette as a replacement of the pixel color.
  93389. */
  93390. static readonly VIGNETTEMODE_OPAQUE: number;
  93391. }
  93392. }
  93393. declare module BABYLON {
  93394. /**
  93395. * This represents all the required information to add a fresnel effect on a material:
  93396. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93397. */
  93398. export class FresnelParameters {
  93399. private _isEnabled;
  93400. /**
  93401. * Define if the fresnel effect is enable or not.
  93402. */
  93403. isEnabled: boolean;
  93404. /**
  93405. * Define the color used on edges (grazing angle)
  93406. */
  93407. leftColor: Color3;
  93408. /**
  93409. * Define the color used on center
  93410. */
  93411. rightColor: Color3;
  93412. /**
  93413. * Define bias applied to computed fresnel term
  93414. */
  93415. bias: number;
  93416. /**
  93417. * Defined the power exponent applied to fresnel term
  93418. */
  93419. power: number;
  93420. /**
  93421. * Clones the current fresnel and its valuues
  93422. * @returns a clone fresnel configuration
  93423. */
  93424. clone(): FresnelParameters;
  93425. /**
  93426. * Serializes the current fresnel parameters to a JSON representation.
  93427. * @return the JSON serialization
  93428. */
  93429. serialize(): any;
  93430. /**
  93431. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93432. * @param parsedFresnelParameters Define the JSON representation
  93433. * @returns the parsed parameters
  93434. */
  93435. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93436. }
  93437. }
  93438. declare module BABYLON {
  93439. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93440. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93441. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93442. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93443. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93444. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93445. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93446. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93447. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93448. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93449. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93450. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93451. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93452. /**
  93453. * Decorator used to define property that can be serialized as reference to a camera
  93454. * @param sourceName defines the name of the property to decorate
  93455. */
  93456. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93457. /**
  93458. * Class used to help serialization objects
  93459. */
  93460. export class SerializationHelper {
  93461. /** @hidden */
  93462. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93463. /** @hidden */
  93464. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93465. /** @hidden */
  93466. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93467. /** @hidden */
  93468. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93469. /**
  93470. * Appends the serialized animations from the source animations
  93471. * @param source Source containing the animations
  93472. * @param destination Target to store the animations
  93473. */
  93474. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93475. /**
  93476. * Static function used to serialized a specific entity
  93477. * @param entity defines the entity to serialize
  93478. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93479. * @returns a JSON compatible object representing the serialization of the entity
  93480. */
  93481. static Serialize<T>(entity: T, serializationObject?: any): any;
  93482. /**
  93483. * Creates a new entity from a serialization data object
  93484. * @param creationFunction defines a function used to instanciated the new entity
  93485. * @param source defines the source serialization data
  93486. * @param scene defines the hosting scene
  93487. * @param rootUrl defines the root url for resources
  93488. * @returns a new entity
  93489. */
  93490. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93491. /**
  93492. * Clones an object
  93493. * @param creationFunction defines the function used to instanciate the new object
  93494. * @param source defines the source object
  93495. * @returns the cloned object
  93496. */
  93497. static Clone<T>(creationFunction: () => T, source: T): T;
  93498. /**
  93499. * Instanciates a new object based on a source one (some data will be shared between both object)
  93500. * @param creationFunction defines the function used to instanciate the new object
  93501. * @param source defines the source object
  93502. * @returns the new object
  93503. */
  93504. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93505. }
  93506. }
  93507. declare module BABYLON {
  93508. /**
  93509. * This is the base class of all the camera used in the application.
  93510. * @see http://doc.babylonjs.com/features/cameras
  93511. */
  93512. export class Camera extends Node {
  93513. /** @hidden */
  93514. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93515. /**
  93516. * This is the default projection mode used by the cameras.
  93517. * It helps recreating a feeling of perspective and better appreciate depth.
  93518. * This is the best way to simulate real life cameras.
  93519. */
  93520. static readonly PERSPECTIVE_CAMERA: number;
  93521. /**
  93522. * This helps creating camera with an orthographic mode.
  93523. * 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.
  93524. */
  93525. static readonly ORTHOGRAPHIC_CAMERA: number;
  93526. /**
  93527. * This is the default FOV mode for perspective cameras.
  93528. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93529. */
  93530. static readonly FOVMODE_VERTICAL_FIXED: number;
  93531. /**
  93532. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93533. */
  93534. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93535. /**
  93536. * This specifies ther is no need for a camera rig.
  93537. * Basically only one eye is rendered corresponding to the camera.
  93538. */
  93539. static readonly RIG_MODE_NONE: number;
  93540. /**
  93541. * Simulates a camera Rig with one blue eye and one red eye.
  93542. * This can be use with 3d blue and red glasses.
  93543. */
  93544. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93545. /**
  93546. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93547. */
  93548. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93549. /**
  93550. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93551. */
  93552. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93553. /**
  93554. * Defines that both eyes of the camera will be rendered over under each other.
  93555. */
  93556. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93557. /**
  93558. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93559. */
  93560. static readonly RIG_MODE_VR: number;
  93561. /**
  93562. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93563. */
  93564. static readonly RIG_MODE_WEBVR: number;
  93565. /**
  93566. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93567. */
  93568. static readonly RIG_MODE_CUSTOM: number;
  93569. /**
  93570. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93571. */
  93572. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93573. /**
  93574. * Define the input manager associated with the camera.
  93575. */
  93576. inputs: CameraInputsManager<Camera>;
  93577. /** @hidden */
  93578. _position: Vector3;
  93579. /**
  93580. * Define the current local position of the camera in the scene
  93581. */
  93582. position: Vector3;
  93583. /**
  93584. * The vector the camera should consider as up.
  93585. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93586. */
  93587. upVector: Vector3;
  93588. /**
  93589. * Define the current limit on the left side for an orthographic camera
  93590. * In scene unit
  93591. */
  93592. orthoLeft: Nullable<number>;
  93593. /**
  93594. * Define the current limit on the right side for an orthographic camera
  93595. * In scene unit
  93596. */
  93597. orthoRight: Nullable<number>;
  93598. /**
  93599. * Define the current limit on the bottom side for an orthographic camera
  93600. * In scene unit
  93601. */
  93602. orthoBottom: Nullable<number>;
  93603. /**
  93604. * Define the current limit on the top side for an orthographic camera
  93605. * In scene unit
  93606. */
  93607. orthoTop: Nullable<number>;
  93608. /**
  93609. * Field Of View is set in Radians. (default is 0.8)
  93610. */
  93611. fov: number;
  93612. /**
  93613. * Define the minimum distance the camera can see from.
  93614. * This is important to note that the depth buffer are not infinite and the closer it starts
  93615. * the more your scene might encounter depth fighting issue.
  93616. */
  93617. minZ: number;
  93618. /**
  93619. * Define the maximum distance the camera can see to.
  93620. * This is important to note that the depth buffer are not infinite and the further it end
  93621. * the more your scene might encounter depth fighting issue.
  93622. */
  93623. maxZ: number;
  93624. /**
  93625. * Define the default inertia of the camera.
  93626. * This helps giving a smooth feeling to the camera movement.
  93627. */
  93628. inertia: number;
  93629. /**
  93630. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93631. */
  93632. mode: number;
  93633. /**
  93634. * Define wether the camera is intermediate.
  93635. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93636. */
  93637. isIntermediate: boolean;
  93638. /**
  93639. * Define the viewport of the camera.
  93640. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93641. */
  93642. viewport: Viewport;
  93643. /**
  93644. * Restricts the camera to viewing objects with the same layerMask.
  93645. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93646. */
  93647. layerMask: number;
  93648. /**
  93649. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93650. */
  93651. fovMode: number;
  93652. /**
  93653. * Rig mode of the camera.
  93654. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93655. * This is normally controlled byt the camera themselves as internal use.
  93656. */
  93657. cameraRigMode: number;
  93658. /**
  93659. * Defines the distance between both "eyes" in case of a RIG
  93660. */
  93661. interaxialDistance: number;
  93662. /**
  93663. * Defines if stereoscopic rendering is done side by side or over under.
  93664. */
  93665. isStereoscopicSideBySide: boolean;
  93666. /**
  93667. * 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
  93668. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93669. * else in the scene.
  93670. */
  93671. customRenderTargets: RenderTargetTexture[];
  93672. /**
  93673. * When set, the camera will render to this render target instead of the default canvas
  93674. */
  93675. outputRenderTarget: Nullable<RenderTargetTexture>;
  93676. /**
  93677. * Observable triggered when the camera view matrix has changed.
  93678. */
  93679. onViewMatrixChangedObservable: Observable<Camera>;
  93680. /**
  93681. * Observable triggered when the camera Projection matrix has changed.
  93682. */
  93683. onProjectionMatrixChangedObservable: Observable<Camera>;
  93684. /**
  93685. * Observable triggered when the inputs have been processed.
  93686. */
  93687. onAfterCheckInputsObservable: Observable<Camera>;
  93688. /**
  93689. * Observable triggered when reset has been called and applied to the camera.
  93690. */
  93691. onRestoreStateObservable: Observable<Camera>;
  93692. /** @hidden */
  93693. _cameraRigParams: any;
  93694. /** @hidden */
  93695. _rigCameras: Camera[];
  93696. /** @hidden */
  93697. _rigPostProcess: Nullable<PostProcess>;
  93698. protected _webvrViewMatrix: Matrix;
  93699. /** @hidden */
  93700. _skipRendering: boolean;
  93701. /** @hidden */
  93702. _projectionMatrix: Matrix;
  93703. /** @hidden */
  93704. _postProcesses: Nullable<PostProcess>[];
  93705. /** @hidden */
  93706. _activeMeshes: SmartArray<AbstractMesh>;
  93707. protected _globalPosition: Vector3;
  93708. /** @hidden */
  93709. _computedViewMatrix: Matrix;
  93710. private _doNotComputeProjectionMatrix;
  93711. private _transformMatrix;
  93712. private _frustumPlanes;
  93713. private _refreshFrustumPlanes;
  93714. private _storedFov;
  93715. private _stateStored;
  93716. /**
  93717. * Instantiates a new camera object.
  93718. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93719. * @see http://doc.babylonjs.com/features/cameras
  93720. * @param name Defines the name of the camera in the scene
  93721. * @param position Defines the position of the camera
  93722. * @param scene Defines the scene the camera belongs too
  93723. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93724. */
  93725. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93726. /**
  93727. * Store current camera state (fov, position, etc..)
  93728. * @returns the camera
  93729. */
  93730. storeState(): Camera;
  93731. /**
  93732. * Restores the camera state values if it has been stored. You must call storeState() first
  93733. */
  93734. protected _restoreStateValues(): boolean;
  93735. /**
  93736. * Restored camera state. You must call storeState() first.
  93737. * @returns true if restored and false otherwise
  93738. */
  93739. restoreState(): boolean;
  93740. /**
  93741. * Gets the class name of the camera.
  93742. * @returns the class name
  93743. */
  93744. getClassName(): string;
  93745. /** @hidden */
  93746. readonly _isCamera: boolean;
  93747. /**
  93748. * Gets a string representation of the camera useful for debug purpose.
  93749. * @param fullDetails Defines that a more verboe level of logging is required
  93750. * @returns the string representation
  93751. */
  93752. toString(fullDetails?: boolean): string;
  93753. /**
  93754. * Gets the current world space position of the camera.
  93755. */
  93756. readonly globalPosition: Vector3;
  93757. /**
  93758. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93759. * @returns the active meshe list
  93760. */
  93761. getActiveMeshes(): SmartArray<AbstractMesh>;
  93762. /**
  93763. * Check wether a mesh is part of the current active mesh list of the camera
  93764. * @param mesh Defines the mesh to check
  93765. * @returns true if active, false otherwise
  93766. */
  93767. isActiveMesh(mesh: Mesh): boolean;
  93768. /**
  93769. * Is this camera ready to be used/rendered
  93770. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93771. * @return true if the camera is ready
  93772. */
  93773. isReady(completeCheck?: boolean): boolean;
  93774. /** @hidden */
  93775. _initCache(): void;
  93776. /** @hidden */
  93777. _updateCache(ignoreParentClass?: boolean): void;
  93778. /** @hidden */
  93779. _isSynchronized(): boolean;
  93780. /** @hidden */
  93781. _isSynchronizedViewMatrix(): boolean;
  93782. /** @hidden */
  93783. _isSynchronizedProjectionMatrix(): boolean;
  93784. /**
  93785. * Attach the input controls to a specific dom element to get the input from.
  93786. * @param element Defines the element the controls should be listened from
  93787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93788. */
  93789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93790. /**
  93791. * Detach the current controls from the specified dom element.
  93792. * @param element Defines the element to stop listening the inputs from
  93793. */
  93794. detachControl(element: HTMLElement): void;
  93795. /**
  93796. * Update the camera state according to the different inputs gathered during the frame.
  93797. */
  93798. update(): void;
  93799. /** @hidden */
  93800. _checkInputs(): void;
  93801. /** @hidden */
  93802. readonly rigCameras: Camera[];
  93803. /**
  93804. * Gets the post process used by the rig cameras
  93805. */
  93806. readonly rigPostProcess: Nullable<PostProcess>;
  93807. /**
  93808. * Internal, gets the first post proces.
  93809. * @returns the first post process to be run on this camera.
  93810. */
  93811. _getFirstPostProcess(): Nullable<PostProcess>;
  93812. private _cascadePostProcessesToRigCams;
  93813. /**
  93814. * Attach a post process to the camera.
  93815. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93816. * @param postProcess The post process to attach to the camera
  93817. * @param insertAt The position of the post process in case several of them are in use in the scene
  93818. * @returns the position the post process has been inserted at
  93819. */
  93820. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93821. /**
  93822. * Detach a post process to the camera.
  93823. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93824. * @param postProcess The post process to detach from the camera
  93825. */
  93826. detachPostProcess(postProcess: PostProcess): void;
  93827. /**
  93828. * Gets the current world matrix of the camera
  93829. */
  93830. getWorldMatrix(): Matrix;
  93831. /** @hidden */
  93832. _getViewMatrix(): Matrix;
  93833. /**
  93834. * Gets the current view matrix of the camera.
  93835. * @param force forces the camera to recompute the matrix without looking at the cached state
  93836. * @returns the view matrix
  93837. */
  93838. getViewMatrix(force?: boolean): Matrix;
  93839. /**
  93840. * Freeze the projection matrix.
  93841. * It will prevent the cache check of the camera projection compute and can speed up perf
  93842. * if no parameter of the camera are meant to change
  93843. * @param projection Defines manually a projection if necessary
  93844. */
  93845. freezeProjectionMatrix(projection?: Matrix): void;
  93846. /**
  93847. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93848. */
  93849. unfreezeProjectionMatrix(): void;
  93850. /**
  93851. * Gets the current projection matrix of the camera.
  93852. * @param force forces the camera to recompute the matrix without looking at the cached state
  93853. * @returns the projection matrix
  93854. */
  93855. getProjectionMatrix(force?: boolean): Matrix;
  93856. /**
  93857. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93858. * @returns a Matrix
  93859. */
  93860. getTransformationMatrix(): Matrix;
  93861. private _updateFrustumPlanes;
  93862. /**
  93863. * Checks if a cullable object (mesh...) is in the camera frustum
  93864. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93865. * @param target The object to check
  93866. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93867. * @returns true if the object is in frustum otherwise false
  93868. */
  93869. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93870. /**
  93871. * Checks if a cullable object (mesh...) is in the camera frustum
  93872. * Unlike isInFrustum this cheks the full bounding box
  93873. * @param target The object to check
  93874. * @returns true if the object is in frustum otherwise false
  93875. */
  93876. isCompletelyInFrustum(target: ICullable): boolean;
  93877. /**
  93878. * Gets a ray in the forward direction from the camera.
  93879. * @param length Defines the length of the ray to create
  93880. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93881. * @param origin Defines the start point of the ray which defaults to the camera position
  93882. * @returns the forward ray
  93883. */
  93884. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93885. /**
  93886. * Releases resources associated with this node.
  93887. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93888. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93889. */
  93890. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93891. /** @hidden */
  93892. _isLeftCamera: boolean;
  93893. /**
  93894. * Gets the left camera of a rig setup in case of Rigged Camera
  93895. */
  93896. readonly isLeftCamera: boolean;
  93897. /** @hidden */
  93898. _isRightCamera: boolean;
  93899. /**
  93900. * Gets the right camera of a rig setup in case of Rigged Camera
  93901. */
  93902. readonly isRightCamera: boolean;
  93903. /**
  93904. * Gets the left camera of a rig setup in case of Rigged Camera
  93905. */
  93906. readonly leftCamera: Nullable<FreeCamera>;
  93907. /**
  93908. * Gets the right camera of a rig setup in case of Rigged Camera
  93909. */
  93910. readonly rightCamera: Nullable<FreeCamera>;
  93911. /**
  93912. * Gets the left camera target of a rig setup in case of Rigged Camera
  93913. * @returns the target position
  93914. */
  93915. getLeftTarget(): Nullable<Vector3>;
  93916. /**
  93917. * Gets the right camera target of a rig setup in case of Rigged Camera
  93918. * @returns the target position
  93919. */
  93920. getRightTarget(): Nullable<Vector3>;
  93921. /**
  93922. * @hidden
  93923. */
  93924. setCameraRigMode(mode: number, rigParams: any): void;
  93925. /** @hidden */
  93926. static _setStereoscopicRigMode(camera: Camera): void;
  93927. /** @hidden */
  93928. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93929. /** @hidden */
  93930. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93931. /** @hidden */
  93932. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93933. /** @hidden */
  93934. _getVRProjectionMatrix(): Matrix;
  93935. protected _updateCameraRotationMatrix(): void;
  93936. protected _updateWebVRCameraRotationMatrix(): void;
  93937. /**
  93938. * This function MUST be overwritten by the different WebVR cameras available.
  93939. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93940. * @hidden
  93941. */
  93942. _getWebVRProjectionMatrix(): Matrix;
  93943. /**
  93944. * This function MUST be overwritten by the different WebVR cameras available.
  93945. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93946. * @hidden
  93947. */
  93948. _getWebVRViewMatrix(): Matrix;
  93949. /** @hidden */
  93950. setCameraRigParameter(name: string, value: any): void;
  93951. /**
  93952. * needs to be overridden by children so sub has required properties to be copied
  93953. * @hidden
  93954. */
  93955. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93956. /**
  93957. * May need to be overridden by children
  93958. * @hidden
  93959. */
  93960. _updateRigCameras(): void;
  93961. /** @hidden */
  93962. _setupInputs(): void;
  93963. /**
  93964. * Serialiaze the camera setup to a json represention
  93965. * @returns the JSON representation
  93966. */
  93967. serialize(): any;
  93968. /**
  93969. * Clones the current camera.
  93970. * @param name The cloned camera name
  93971. * @returns the cloned camera
  93972. */
  93973. clone(name: string): Camera;
  93974. /**
  93975. * Gets the direction of the camera relative to a given local axis.
  93976. * @param localAxis Defines the reference axis to provide a relative direction.
  93977. * @return the direction
  93978. */
  93979. getDirection(localAxis: Vector3): Vector3;
  93980. /**
  93981. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93982. * @param localAxis Defines the reference axis to provide a relative direction.
  93983. * @param result Defines the vector to store the result in
  93984. */
  93985. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93986. /**
  93987. * Gets a camera constructor for a given camera type
  93988. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93989. * @param name The name of the camera the result will be able to instantiate
  93990. * @param scene The scene the result will construct the camera in
  93991. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93992. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93993. * @returns a factory method to construc the camera
  93994. */
  93995. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93996. /**
  93997. * Compute the world matrix of the camera.
  93998. * @returns the camera workd matrix
  93999. */
  94000. computeWorldMatrix(): Matrix;
  94001. /**
  94002. * Parse a JSON and creates the camera from the parsed information
  94003. * @param parsedCamera The JSON to parse
  94004. * @param scene The scene to instantiate the camera in
  94005. * @returns the newly constructed camera
  94006. */
  94007. static Parse(parsedCamera: any, scene: Scene): Camera;
  94008. }
  94009. }
  94010. declare module BABYLON {
  94011. /**
  94012. * Interface for any object that can request an animation frame
  94013. */
  94014. export interface ICustomAnimationFrameRequester {
  94015. /**
  94016. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  94017. */
  94018. renderFunction?: Function;
  94019. /**
  94020. * Called to request the next frame to render to
  94021. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  94022. */
  94023. requestAnimationFrame: Function;
  94024. /**
  94025. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  94026. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  94027. */
  94028. requestID?: number;
  94029. }
  94030. /**
  94031. * Interface containing an array of animations
  94032. */
  94033. export interface IAnimatable {
  94034. /**
  94035. * Array of animations
  94036. */
  94037. animations: Nullable<Array<Animation>>;
  94038. }
  94039. /** Interface used by value gradients (color, factor, ...) */
  94040. export interface IValueGradient {
  94041. /**
  94042. * Gets or sets the gradient value (between 0 and 1)
  94043. */
  94044. gradient: number;
  94045. }
  94046. /** Class used to store color4 gradient */
  94047. export class ColorGradient implements IValueGradient {
  94048. /**
  94049. * Gets or sets the gradient value (between 0 and 1)
  94050. */
  94051. gradient: number;
  94052. /**
  94053. * Gets or sets first associated color
  94054. */
  94055. color1: Color4;
  94056. /**
  94057. * Gets or sets second associated color
  94058. */
  94059. color2?: Color4;
  94060. /**
  94061. * Will get a color picked randomly between color1 and color2.
  94062. * If color2 is undefined then color1 will be used
  94063. * @param result defines the target Color4 to store the result in
  94064. */
  94065. getColorToRef(result: Color4): void;
  94066. }
  94067. /** Class used to store color 3 gradient */
  94068. export class Color3Gradient implements IValueGradient {
  94069. /**
  94070. * Gets or sets the gradient value (between 0 and 1)
  94071. */
  94072. gradient: number;
  94073. /**
  94074. * Gets or sets the associated color
  94075. */
  94076. color: Color3;
  94077. }
  94078. /** Class used to store factor gradient */
  94079. export class FactorGradient implements IValueGradient {
  94080. /**
  94081. * Gets or sets the gradient value (between 0 and 1)
  94082. */
  94083. gradient: number;
  94084. /**
  94085. * Gets or sets first associated factor
  94086. */
  94087. factor1: number;
  94088. /**
  94089. * Gets or sets second associated factor
  94090. */
  94091. factor2?: number;
  94092. /**
  94093. * Will get a number picked randomly between factor1 and factor2.
  94094. * If factor2 is undefined then factor1 will be used
  94095. * @returns the picked number
  94096. */
  94097. getFactor(): number;
  94098. }
  94099. /**
  94100. * @ignore
  94101. * Application error to support additional information when loading a file
  94102. */
  94103. export class LoadFileError extends Error {
  94104. /** defines the optional web request */
  94105. request?: WebRequest | undefined;
  94106. private static _setPrototypeOf;
  94107. /**
  94108. * Creates a new LoadFileError
  94109. * @param message defines the message of the error
  94110. * @param request defines the optional web request
  94111. */
  94112. constructor(message: string,
  94113. /** defines the optional web request */
  94114. request?: WebRequest | undefined);
  94115. }
  94116. /**
  94117. * Class used to define a retry strategy when error happens while loading assets
  94118. */
  94119. export class RetryStrategy {
  94120. /**
  94121. * Function used to defines an exponential back off strategy
  94122. * @param maxRetries defines the maximum number of retries (3 by default)
  94123. * @param baseInterval defines the interval between retries
  94124. * @returns the strategy function to use
  94125. */
  94126. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  94127. }
  94128. /**
  94129. * File request interface
  94130. */
  94131. export interface IFileRequest {
  94132. /**
  94133. * Raised when the request is complete (success or error).
  94134. */
  94135. onCompleteObservable: Observable<IFileRequest>;
  94136. /**
  94137. * Aborts the request for a file.
  94138. */
  94139. abort: () => void;
  94140. }
  94141. /**
  94142. * Class containing a set of static utilities functions
  94143. */
  94144. export class Tools {
  94145. /**
  94146. * Gets or sets the base URL to use to load assets
  94147. */
  94148. static BaseUrl: string;
  94149. /**
  94150. * Enable/Disable Custom HTTP Request Headers globally.
  94151. * default = false
  94152. * @see CustomRequestHeaders
  94153. */
  94154. static UseCustomRequestHeaders: boolean;
  94155. /**
  94156. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  94157. * i.e. when loading files, where the server/service expects an Authorization header
  94158. */
  94159. static CustomRequestHeaders: {
  94160. [key: string]: string;
  94161. };
  94162. /**
  94163. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  94164. */
  94165. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  94166. /**
  94167. * Default behaviour for cors in the application.
  94168. * It can be a string if the expected behavior is identical in the entire app.
  94169. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  94170. */
  94171. static CorsBehavior: string | ((url: string | string[]) => string);
  94172. /**
  94173. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  94174. * @ignorenaming
  94175. */
  94176. static UseFallbackTexture: boolean;
  94177. /**
  94178. * Use this object to register external classes like custom textures or material
  94179. * to allow the laoders to instantiate them
  94180. */
  94181. static RegisteredExternalClasses: {
  94182. [key: string]: Object;
  94183. };
  94184. /**
  94185. * Texture content used if a texture cannot loaded
  94186. * @ignorenaming
  94187. */
  94188. static fallbackTexture: string;
  94189. /**
  94190. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  94191. * @param u defines the coordinate on X axis
  94192. * @param v defines the coordinate on Y axis
  94193. * @param width defines the width of the source data
  94194. * @param height defines the height of the source data
  94195. * @param pixels defines the source byte array
  94196. * @param color defines the output color
  94197. */
  94198. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  94199. /**
  94200. * Interpolates between a and b via alpha
  94201. * @param a The lower value (returned when alpha = 0)
  94202. * @param b The upper value (returned when alpha = 1)
  94203. * @param alpha The interpolation-factor
  94204. * @return The mixed value
  94205. */
  94206. static Mix(a: number, b: number, alpha: number): number;
  94207. /**
  94208. * Tries to instantiate a new object from a given class name
  94209. * @param className defines the class name to instantiate
  94210. * @returns the new object or null if the system was not able to do the instantiation
  94211. */
  94212. static Instantiate(className: string): any;
  94213. /**
  94214. * Provides a slice function that will work even on IE
  94215. * @param data defines the array to slice
  94216. * @param start defines the start of the data (optional)
  94217. * @param end defines the end of the data (optional)
  94218. * @returns the new sliced array
  94219. */
  94220. static Slice<T>(data: T, start?: number, end?: number): T;
  94221. /**
  94222. * Polyfill for setImmediate
  94223. * @param action defines the action to execute after the current execution block
  94224. */
  94225. static SetImmediate(action: () => void): void;
  94226. /**
  94227. * Function indicating if a number is an exponent of 2
  94228. * @param value defines the value to test
  94229. * @returns true if the value is an exponent of 2
  94230. */
  94231. static IsExponentOfTwo(value: number): boolean;
  94232. private static _tmpFloatArray;
  94233. /**
  94234. * Returns the nearest 32-bit single precision float representation of a Number
  94235. * @param value A Number. If the parameter is of a different type, it will get converted
  94236. * to a number or to NaN if it cannot be converted
  94237. * @returns number
  94238. */
  94239. static FloatRound(value: number): number;
  94240. /**
  94241. * Find the next highest power of two.
  94242. * @param x Number to start search from.
  94243. * @return Next highest power of two.
  94244. */
  94245. static CeilingPOT(x: number): number;
  94246. /**
  94247. * Find the next lowest power of two.
  94248. * @param x Number to start search from.
  94249. * @return Next lowest power of two.
  94250. */
  94251. static FloorPOT(x: number): number;
  94252. /**
  94253. * Find the nearest power of two.
  94254. * @param x Number to start search from.
  94255. * @return Next nearest power of two.
  94256. */
  94257. static NearestPOT(x: number): number;
  94258. /**
  94259. * Get the closest exponent of two
  94260. * @param value defines the value to approximate
  94261. * @param max defines the maximum value to return
  94262. * @param mode defines how to define the closest value
  94263. * @returns closest exponent of two of the given value
  94264. */
  94265. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  94266. /**
  94267. * Extracts the filename from a path
  94268. * @param path defines the path to use
  94269. * @returns the filename
  94270. */
  94271. static GetFilename(path: string): string;
  94272. /**
  94273. * Extracts the "folder" part of a path (everything before the filename).
  94274. * @param uri The URI to extract the info from
  94275. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  94276. * @returns The "folder" part of the path
  94277. */
  94278. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  94279. /**
  94280. * Extracts text content from a DOM element hierarchy
  94281. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  94282. */
  94283. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  94284. /**
  94285. * Convert an angle in radians to degrees
  94286. * @param angle defines the angle to convert
  94287. * @returns the angle in degrees
  94288. */
  94289. static ToDegrees(angle: number): number;
  94290. /**
  94291. * Convert an angle in degrees to radians
  94292. * @param angle defines the angle to convert
  94293. * @returns the angle in radians
  94294. */
  94295. static ToRadians(angle: number): number;
  94296. /**
  94297. * Encode a buffer to a base64 string
  94298. * @param buffer defines the buffer to encode
  94299. * @returns the encoded string
  94300. */
  94301. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  94302. /**
  94303. * Extracts minimum and maximum values from a list of indexed positions
  94304. * @param positions defines the positions to use
  94305. * @param indices defines the indices to the positions
  94306. * @param indexStart defines the start index
  94307. * @param indexCount defines the end index
  94308. * @param bias defines bias value to add to the result
  94309. * @return minimum and maximum values
  94310. */
  94311. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  94312. minimum: Vector3;
  94313. maximum: Vector3;
  94314. };
  94315. /**
  94316. * Extracts minimum and maximum values from a list of positions
  94317. * @param positions defines the positions to use
  94318. * @param start defines the start index in the positions array
  94319. * @param count defines the number of positions to handle
  94320. * @param bias defines bias value to add to the result
  94321. * @param stride defines the stride size to use (distance between two positions in the positions array)
  94322. * @return minimum and maximum values
  94323. */
  94324. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  94325. minimum: Vector3;
  94326. maximum: Vector3;
  94327. };
  94328. /**
  94329. * Returns an array if obj is not an array
  94330. * @param obj defines the object to evaluate as an array
  94331. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  94332. * @returns either obj directly if obj is an array or a new array containing obj
  94333. */
  94334. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  94335. /**
  94336. * Gets the pointer prefix to use
  94337. * @returns "pointer" if touch is enabled. Else returns "mouse"
  94338. */
  94339. static GetPointerPrefix(): string;
  94340. /**
  94341. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  94342. * @param func - the function to be called
  94343. * @param requester - the object that will request the next frame. Falls back to window.
  94344. * @returns frame number
  94345. */
  94346. static QueueNewFrame(func: () => void, requester?: any): number;
  94347. /**
  94348. * Ask the browser to promote the current element to fullscreen rendering mode
  94349. * @param element defines the DOM element to promote
  94350. */
  94351. static RequestFullscreen(element: HTMLElement): void;
  94352. /**
  94353. * Asks the browser to exit fullscreen mode
  94354. */
  94355. static ExitFullscreen(): void;
  94356. /**
  94357. * Ask the browser to promote the current element to pointerlock mode
  94358. * @param element defines the DOM element to promote
  94359. */
  94360. static RequestPointerlock(element: HTMLElement): void;
  94361. /**
  94362. * Asks the browser to exit pointerlock mode
  94363. */
  94364. static ExitPointerlock(): void;
  94365. /**
  94366. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  94367. * @param url define the url we are trying
  94368. * @param element define the dom element where to configure the cors policy
  94369. */
  94370. static SetCorsBehavior(url: string | string[], element: {
  94371. crossOrigin: string | null;
  94372. }): void;
  94373. /**
  94374. * Removes unwanted characters from an url
  94375. * @param url defines the url to clean
  94376. * @returns the cleaned url
  94377. */
  94378. static CleanUrl(url: string): string;
  94379. /**
  94380. * Gets or sets a function used to pre-process url before using them to load assets
  94381. */
  94382. static PreprocessUrl: (url: string) => string;
  94383. /**
  94384. * Loads an image as an HTMLImageElement.
  94385. * @param input url string, ArrayBuffer, or Blob to load
  94386. * @param onLoad callback called when the image successfully loads
  94387. * @param onError callback called when the image fails to load
  94388. * @param offlineProvider offline provider for caching
  94389. * @returns the HTMLImageElement of the loaded image
  94390. */
  94391. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  94392. /**
  94393. * Loads a file
  94394. * @param url url string, ArrayBuffer, or Blob to load
  94395. * @param onSuccess callback called when the file successfully loads
  94396. * @param onProgress callback called while file is loading (if the server supports this mode)
  94397. * @param offlineProvider defines the offline provider for caching
  94398. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  94399. * @param onError callback called when the file fails to load
  94400. * @returns a file request object
  94401. */
  94402. 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;
  94403. /**
  94404. * Loads a file from a url
  94405. * @param url the file url to load
  94406. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  94407. */
  94408. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  94409. /**
  94410. * Load a script (identified by an url). When the url returns, the
  94411. * content of this file is added into a new script element, attached to the DOM (body element)
  94412. * @param scriptUrl defines the url of the script to laod
  94413. * @param onSuccess defines the callback called when the script is loaded
  94414. * @param onError defines the callback to call if an error occurs
  94415. * @param scriptId defines the id of the script element
  94416. */
  94417. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  94418. /**
  94419. * Load an asynchronous script (identified by an url). When the url returns, the
  94420. * content of this file is added into a new script element, attached to the DOM (body element)
  94421. * @param scriptUrl defines the url of the script to laod
  94422. * @param scriptId defines the id of the script element
  94423. * @returns a promise request object
  94424. */
  94425. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  94426. /**
  94427. * Loads a file from a blob
  94428. * @param fileToLoad defines the blob to use
  94429. * @param callback defines the callback to call when data is loaded
  94430. * @param progressCallback defines the callback to call during loading process
  94431. * @returns a file request object
  94432. */
  94433. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  94434. /**
  94435. * Loads a file
  94436. * @param fileToLoad defines the file to load
  94437. * @param callback defines the callback to call when data is loaded
  94438. * @param progressCallBack defines the callback to call during loading process
  94439. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  94440. * @returns a file request object
  94441. */
  94442. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  94443. /**
  94444. * Creates a data url from a given string content
  94445. * @param content defines the content to convert
  94446. * @returns the new data url link
  94447. */
  94448. static FileAsURL(content: string): string;
  94449. /**
  94450. * Format the given number to a specific decimal format
  94451. * @param value defines the number to format
  94452. * @param decimals defines the number of decimals to use
  94453. * @returns the formatted string
  94454. */
  94455. static Format(value: number, decimals?: number): string;
  94456. /**
  94457. * Checks if a given vector is inside a specific range
  94458. * @param v defines the vector to test
  94459. * @param min defines the minimum range
  94460. * @param max defines the maximum range
  94461. */
  94462. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  94463. /**
  94464. * Tries to copy an object by duplicating every property
  94465. * @param source defines the source object
  94466. * @param destination defines the target object
  94467. * @param doNotCopyList defines a list of properties to avoid
  94468. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  94469. */
  94470. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  94471. /**
  94472. * Gets a boolean indicating if the given object has no own property
  94473. * @param obj defines the object to test
  94474. * @returns true if object has no own property
  94475. */
  94476. static IsEmpty(obj: any): boolean;
  94477. /**
  94478. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  94479. * @param str Source string
  94480. * @param suffix Suffix to search for in the source string
  94481. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94482. */
  94483. static EndsWith(str: string, suffix: string): boolean;
  94484. /**
  94485. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  94486. * @param str Source string
  94487. * @param suffix Suffix to search for in the source string
  94488. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94489. */
  94490. static StartsWith(str: string, suffix: string): boolean;
  94491. /**
  94492. * Function used to register events at window level
  94493. * @param events defines the events to register
  94494. */
  94495. static RegisterTopRootEvents(events: {
  94496. name: string;
  94497. handler: Nullable<(e: FocusEvent) => any>;
  94498. }[]): void;
  94499. /**
  94500. * Function used to unregister events from window level
  94501. * @param events defines the events to unregister
  94502. */
  94503. static UnregisterTopRootEvents(events: {
  94504. name: string;
  94505. handler: Nullable<(e: FocusEvent) => any>;
  94506. }[]): void;
  94507. /**
  94508. * @ignore
  94509. */
  94510. static _ScreenshotCanvas: HTMLCanvasElement;
  94511. /**
  94512. * Dumps the current bound framebuffer
  94513. * @param width defines the rendering width
  94514. * @param height defines the rendering height
  94515. * @param engine defines the hosting engine
  94516. * @param successCallback defines the callback triggered once the data are available
  94517. * @param mimeType defines the mime type of the result
  94518. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  94519. */
  94520. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94521. /**
  94522. * Converts the canvas data to blob.
  94523. * This acts as a polyfill for browsers not supporting the to blob function.
  94524. * @param canvas Defines the canvas to extract the data from
  94525. * @param successCallback Defines the callback triggered once the data are available
  94526. * @param mimeType Defines the mime type of the result
  94527. */
  94528. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  94529. /**
  94530. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  94531. * @param successCallback defines the callback triggered once the data are available
  94532. * @param mimeType defines the mime type of the result
  94533. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  94534. */
  94535. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94536. /**
  94537. * Downloads a blob in the browser
  94538. * @param blob defines the blob to download
  94539. * @param fileName defines the name of the downloaded file
  94540. */
  94541. static Download(blob: Blob, fileName: string): void;
  94542. /**
  94543. * Captures a screenshot of the current rendering
  94544. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94545. * @param engine defines the rendering engine
  94546. * @param camera defines the source camera
  94547. * @param size This parameter can be set to a single number or to an object with the
  94548. * following (optional) properties: precision, width, height. If a single number is passed,
  94549. * it will be used for both width and height. If an object is passed, the screenshot size
  94550. * will be derived from the parameters. The precision property is a multiplier allowing
  94551. * rendering at a higher or lower resolution
  94552. * @param successCallback defines the callback receives a single parameter which contains the
  94553. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94554. * src parameter of an <img> to display it
  94555. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  94556. * Check your browser for supported MIME types
  94557. */
  94558. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  94559. /**
  94560. * Generates an image screenshot from the specified camera.
  94561. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94562. * @param engine The engine to use for rendering
  94563. * @param camera The camera to use for rendering
  94564. * @param size This parameter can be set to a single number or to an object with the
  94565. * following (optional) properties: precision, width, height. If a single number is passed,
  94566. * it will be used for both width and height. If an object is passed, the screenshot size
  94567. * will be derived from the parameters. The precision property is a multiplier allowing
  94568. * rendering at a higher or lower resolution
  94569. * @param successCallback The callback receives a single parameter which contains the
  94570. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94571. * src parameter of an <img> to display it
  94572. * @param mimeType The MIME type of the screenshot image (default: image/png).
  94573. * Check your browser for supported MIME types
  94574. * @param samples Texture samples (default: 1)
  94575. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  94576. * @param fileName A name for for the downloaded file.
  94577. */
  94578. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  94579. /**
  94580. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94581. * Be aware Math.random() could cause collisions, but:
  94582. * "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"
  94583. * @returns a pseudo random id
  94584. */
  94585. static RandomId(): string;
  94586. /**
  94587. * Test if the given uri is a base64 string
  94588. * @param uri The uri to test
  94589. * @return True if the uri is a base64 string or false otherwise
  94590. */
  94591. static IsBase64(uri: string): boolean;
  94592. /**
  94593. * Decode the given base64 uri.
  94594. * @param uri The uri to decode
  94595. * @return The decoded base64 data.
  94596. */
  94597. static DecodeBase64(uri: string): ArrayBuffer;
  94598. /**
  94599. * Gets the absolute url.
  94600. * @param url the input url
  94601. * @return the absolute url
  94602. */
  94603. static GetAbsoluteUrl(url: string): string;
  94604. /**
  94605. * No log
  94606. */
  94607. static readonly NoneLogLevel: number;
  94608. /**
  94609. * Only message logs
  94610. */
  94611. static readonly MessageLogLevel: number;
  94612. /**
  94613. * Only warning logs
  94614. */
  94615. static readonly WarningLogLevel: number;
  94616. /**
  94617. * Only error logs
  94618. */
  94619. static readonly ErrorLogLevel: number;
  94620. /**
  94621. * All logs
  94622. */
  94623. static readonly AllLogLevel: number;
  94624. /**
  94625. * Gets a value indicating the number of loading errors
  94626. * @ignorenaming
  94627. */
  94628. static readonly errorsCount: number;
  94629. /**
  94630. * Callback called when a new log is added
  94631. */
  94632. static OnNewCacheEntry: (entry: string) => void;
  94633. /**
  94634. * Log a message to the console
  94635. * @param message defines the message to log
  94636. */
  94637. static Log(message: string): void;
  94638. /**
  94639. * Write a warning message to the console
  94640. * @param message defines the message to log
  94641. */
  94642. static Warn(message: string): void;
  94643. /**
  94644. * Write an error message to the console
  94645. * @param message defines the message to log
  94646. */
  94647. static Error(message: string): void;
  94648. /**
  94649. * Gets current log cache (list of logs)
  94650. */
  94651. static readonly LogCache: string;
  94652. /**
  94653. * Clears the log cache
  94654. */
  94655. static ClearLogCache(): void;
  94656. /**
  94657. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94658. */
  94659. static LogLevels: number;
  94660. /**
  94661. * Checks if the loaded document was accessed via `file:`-Protocol.
  94662. * @returns boolean
  94663. */
  94664. static IsFileURL(): boolean;
  94665. /**
  94666. * Checks if the window object exists
  94667. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  94668. */
  94669. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  94670. /**
  94671. * No performance log
  94672. */
  94673. static readonly PerformanceNoneLogLevel: number;
  94674. /**
  94675. * Use user marks to log performance
  94676. */
  94677. static readonly PerformanceUserMarkLogLevel: number;
  94678. /**
  94679. * Log performance to the console
  94680. */
  94681. static readonly PerformanceConsoleLogLevel: number;
  94682. private static _performance;
  94683. /**
  94684. * Sets the current performance log level
  94685. */
  94686. static PerformanceLogLevel: number;
  94687. private static _StartPerformanceCounterDisabled;
  94688. private static _EndPerformanceCounterDisabled;
  94689. private static _StartUserMark;
  94690. private static _EndUserMark;
  94691. private static _StartPerformanceConsole;
  94692. private static _EndPerformanceConsole;
  94693. /**
  94694. * Starts a performance counter
  94695. */
  94696. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94697. /**
  94698. * Ends a specific performance coutner
  94699. */
  94700. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94701. /**
  94702. * Gets either window.performance.now() if supported or Date.now() else
  94703. */
  94704. static readonly Now: number;
  94705. /**
  94706. * This method will return the name of the class used to create the instance of the given object.
  94707. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  94708. * @param object the object to get the class name from
  94709. * @param isType defines if the object is actually a type
  94710. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  94711. */
  94712. static GetClassName(object: any, isType?: boolean): string;
  94713. /**
  94714. * Gets the first element of an array satisfying a given predicate
  94715. * @param array defines the array to browse
  94716. * @param predicate defines the predicate to use
  94717. * @returns null if not found or the element
  94718. */
  94719. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  94720. /**
  94721. * This method will return the name of the full name of the class, including its owning module (if any).
  94722. * 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).
  94723. * @param object the object to get the class name from
  94724. * @param isType defines if the object is actually a type
  94725. * @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.
  94726. * @ignorenaming
  94727. */
  94728. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  94729. /**
  94730. * Returns a promise that resolves after the given amount of time.
  94731. * @param delay Number of milliseconds to delay
  94732. * @returns Promise that resolves after the given amount of time
  94733. */
  94734. static DelayAsync(delay: number): Promise<void>;
  94735. /**
  94736. * Gets the current gradient from an array of IValueGradient
  94737. * @param ratio defines the current ratio to get
  94738. * @param gradients defines the array of IValueGradient
  94739. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  94740. */
  94741. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  94742. }
  94743. /**
  94744. * This class is used to track a performance counter which is number based.
  94745. * The user has access to many properties which give statistics of different nature.
  94746. *
  94747. * The implementer can track two kinds of Performance Counter: time and count.
  94748. * 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.
  94749. * 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.
  94750. */
  94751. export class PerfCounter {
  94752. /**
  94753. * Gets or sets a global boolean to turn on and off all the counters
  94754. */
  94755. static Enabled: boolean;
  94756. /**
  94757. * Returns the smallest value ever
  94758. */
  94759. readonly min: number;
  94760. /**
  94761. * Returns the biggest value ever
  94762. */
  94763. readonly max: number;
  94764. /**
  94765. * Returns the average value since the performance counter is running
  94766. */
  94767. readonly average: number;
  94768. /**
  94769. * Returns the average value of the last second the counter was monitored
  94770. */
  94771. readonly lastSecAverage: number;
  94772. /**
  94773. * Returns the current value
  94774. */
  94775. readonly current: number;
  94776. /**
  94777. * Gets the accumulated total
  94778. */
  94779. readonly total: number;
  94780. /**
  94781. * Gets the total value count
  94782. */
  94783. readonly count: number;
  94784. /**
  94785. * Creates a new counter
  94786. */
  94787. constructor();
  94788. /**
  94789. * Call this method to start monitoring a new frame.
  94790. * 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.
  94791. */
  94792. fetchNewFrame(): void;
  94793. /**
  94794. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94795. * @param newCount the count value to add to the monitored count
  94796. * @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.
  94797. */
  94798. addCount(newCount: number, fetchResult: boolean): void;
  94799. /**
  94800. * Start monitoring this performance counter
  94801. */
  94802. beginMonitoring(): void;
  94803. /**
  94804. * Compute the time lapsed since the previous beginMonitoring() call.
  94805. * @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
  94806. */
  94807. endMonitoring(newFrame?: boolean): void;
  94808. private _fetchResult;
  94809. private _startMonitoringTime;
  94810. private _min;
  94811. private _max;
  94812. private _average;
  94813. private _current;
  94814. private _totalValueCount;
  94815. private _totalAccumulated;
  94816. private _lastSecAverage;
  94817. private _lastSecAccumulated;
  94818. private _lastSecTime;
  94819. private _lastSecValueCount;
  94820. }
  94821. /**
  94822. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94823. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94824. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94825. * @param name The name of the class, case should be preserved
  94826. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94827. */
  94828. export function className(name: string, module?: string): (target: Object) => void;
  94829. /**
  94830. * An implementation of a loop for asynchronous functions.
  94831. */
  94832. export class AsyncLoop {
  94833. /**
  94834. * Defines the number of iterations for the loop
  94835. */
  94836. iterations: number;
  94837. /**
  94838. * Defines the current index of the loop.
  94839. */
  94840. index: number;
  94841. private _done;
  94842. private _fn;
  94843. private _successCallback;
  94844. /**
  94845. * Constructor.
  94846. * @param iterations the number of iterations.
  94847. * @param func the function to run each iteration
  94848. * @param successCallback the callback that will be called upon succesful execution
  94849. * @param offset starting offset.
  94850. */
  94851. constructor(
  94852. /**
  94853. * Defines the number of iterations for the loop
  94854. */
  94855. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94856. /**
  94857. * Execute the next iteration. Must be called after the last iteration was finished.
  94858. */
  94859. executeNext(): void;
  94860. /**
  94861. * Break the loop and run the success callback.
  94862. */
  94863. breakLoop(): void;
  94864. /**
  94865. * Create and run an async loop.
  94866. * @param iterations the number of iterations.
  94867. * @param fn the function to run each iteration
  94868. * @param successCallback the callback that will be called upon succesful execution
  94869. * @param offset starting offset.
  94870. * @returns the created async loop object
  94871. */
  94872. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94873. /**
  94874. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94875. * @param iterations total number of iterations
  94876. * @param syncedIterations number of synchronous iterations in each async iteration.
  94877. * @param fn the function to call each iteration.
  94878. * @param callback a success call back that will be called when iterating stops.
  94879. * @param breakFunction a break condition (optional)
  94880. * @param timeout timeout settings for the setTimeout function. default - 0.
  94881. * @returns the created async loop object
  94882. */
  94883. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94884. }
  94885. }
  94886. declare module BABYLON {
  94887. /** @hidden */
  94888. export interface ICollisionCoordinator {
  94889. createCollider(): Collider;
  94890. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94891. init(scene: Scene): void;
  94892. }
  94893. /** @hidden */
  94894. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94895. private _scene;
  94896. private _scaledPosition;
  94897. private _scaledVelocity;
  94898. private _finalPosition;
  94899. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94900. createCollider(): Collider;
  94901. init(scene: Scene): void;
  94902. private _collideWithWorld;
  94903. }
  94904. }
  94905. declare module BABYLON {
  94906. /**
  94907. * Class used to manage all inputs for the scene.
  94908. */
  94909. export class InputManager {
  94910. /** The distance in pixel that you have to move to prevent some events */
  94911. static DragMovementThreshold: number;
  94912. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94913. static LongPressDelay: number;
  94914. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94915. static DoubleClickDelay: number;
  94916. /** If you need to check double click without raising a single click at first click, enable this flag */
  94917. static ExclusiveDoubleClickMode: boolean;
  94918. private _wheelEventName;
  94919. private _onPointerMove;
  94920. private _onPointerDown;
  94921. private _onPointerUp;
  94922. private _initClickEvent;
  94923. private _initActionManager;
  94924. private _delayedSimpleClick;
  94925. private _delayedSimpleClickTimeout;
  94926. private _previousDelayedSimpleClickTimeout;
  94927. private _meshPickProceed;
  94928. private _previousButtonPressed;
  94929. private _currentPickResult;
  94930. private _previousPickResult;
  94931. private _totalPointersPressed;
  94932. private _doubleClickOccured;
  94933. private _pointerOverMesh;
  94934. private _pickedDownMesh;
  94935. private _pickedUpMesh;
  94936. private _pointerX;
  94937. private _pointerY;
  94938. private _unTranslatedPointerX;
  94939. private _unTranslatedPointerY;
  94940. private _startingPointerPosition;
  94941. private _previousStartingPointerPosition;
  94942. private _startingPointerTime;
  94943. private _previousStartingPointerTime;
  94944. private _pointerCaptures;
  94945. private _onKeyDown;
  94946. private _onKeyUp;
  94947. private _onCanvasFocusObserver;
  94948. private _onCanvasBlurObserver;
  94949. private _scene;
  94950. /**
  94951. * Creates a new InputManager
  94952. * @param scene defines the hosting scene
  94953. */
  94954. constructor(scene: Scene);
  94955. /**
  94956. * Gets the mesh that is currently under the pointer
  94957. */
  94958. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94959. /**
  94960. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94961. */
  94962. readonly unTranslatedPointer: Vector2;
  94963. /**
  94964. * Gets or sets the current on-screen X position of the pointer
  94965. */
  94966. pointerX: number;
  94967. /**
  94968. * Gets or sets the current on-screen Y position of the pointer
  94969. */
  94970. pointerY: number;
  94971. private _updatePointerPosition;
  94972. private _processPointerMove;
  94973. private _setRayOnPointerInfo;
  94974. private _checkPrePointerObservable;
  94975. /**
  94976. * Use this method to simulate a pointer move on a mesh
  94977. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94978. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94979. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94980. */
  94981. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94982. /**
  94983. * Use this method to simulate a pointer down on a mesh
  94984. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94985. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94986. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94987. */
  94988. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94989. private _processPointerDown;
  94990. /** @hidden */
  94991. _isPointerSwiping(): boolean;
  94992. /**
  94993. * Use this method to simulate a pointer up on a mesh
  94994. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94995. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94996. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94997. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94998. */
  94999. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  95000. private _processPointerUp;
  95001. /**
  95002. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  95003. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  95004. * @returns true if the pointer was captured
  95005. */
  95006. isPointerCaptured(pointerId?: number): boolean;
  95007. /**
  95008. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95009. * @param attachUp defines if you want to attach events to pointerup
  95010. * @param attachDown defines if you want to attach events to pointerdown
  95011. * @param attachMove defines if you want to attach events to pointermove
  95012. */
  95013. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95014. /**
  95015. * Detaches all event handlers
  95016. */
  95017. detachControl(): void;
  95018. /**
  95019. * Force the value of meshUnderPointer
  95020. * @param mesh defines the mesh to use
  95021. */
  95022. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  95023. /**
  95024. * Gets the mesh under the pointer
  95025. * @returns a Mesh or null if no mesh is under the pointer
  95026. */
  95027. getPointerOverMesh(): Nullable<AbstractMesh>;
  95028. }
  95029. }
  95030. declare module BABYLON {
  95031. /**
  95032. * This class defines the direct association between an animation and a target
  95033. */
  95034. export class TargetedAnimation {
  95035. /**
  95036. * Animation to perform
  95037. */
  95038. animation: Animation;
  95039. /**
  95040. * Target to animate
  95041. */
  95042. target: any;
  95043. /**
  95044. * Serialize the object
  95045. * @returns the JSON object representing the current entity
  95046. */
  95047. serialize(): any;
  95048. }
  95049. /**
  95050. * Use this class to create coordinated animations on multiple targets
  95051. */
  95052. export class AnimationGroup implements IDisposable {
  95053. /** The name of the animation group */
  95054. name: string;
  95055. private _scene;
  95056. private _targetedAnimations;
  95057. private _animatables;
  95058. private _from;
  95059. private _to;
  95060. private _isStarted;
  95061. private _isPaused;
  95062. private _speedRatio;
  95063. private _loopAnimation;
  95064. /**
  95065. * Gets or sets the unique id of the node
  95066. */
  95067. uniqueId: number;
  95068. /**
  95069. * This observable will notify when one animation have ended
  95070. */
  95071. onAnimationEndObservable: Observable<TargetedAnimation>;
  95072. /**
  95073. * Observer raised when one animation loops
  95074. */
  95075. onAnimationLoopObservable: Observable<TargetedAnimation>;
  95076. /**
  95077. * This observable will notify when all animations have ended.
  95078. */
  95079. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  95080. /**
  95081. * This observable will notify when all animations have paused.
  95082. */
  95083. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  95084. /**
  95085. * This observable will notify when all animations are playing.
  95086. */
  95087. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  95088. /**
  95089. * Gets the first frame
  95090. */
  95091. readonly from: number;
  95092. /**
  95093. * Gets the last frame
  95094. */
  95095. readonly to: number;
  95096. /**
  95097. * Define if the animations are started
  95098. */
  95099. readonly isStarted: boolean;
  95100. /**
  95101. * Gets a value indicating that the current group is playing
  95102. */
  95103. readonly isPlaying: boolean;
  95104. /**
  95105. * Gets or sets the speed ratio to use for all animations
  95106. */
  95107. /**
  95108. * Gets or sets the speed ratio to use for all animations
  95109. */
  95110. speedRatio: number;
  95111. /**
  95112. * Gets or sets if all animations should loop or not
  95113. */
  95114. loopAnimation: boolean;
  95115. /**
  95116. * Gets the targeted animations for this animation group
  95117. */
  95118. readonly targetedAnimations: Array<TargetedAnimation>;
  95119. /**
  95120. * returning the list of animatables controlled by this animation group.
  95121. */
  95122. readonly animatables: Array<Animatable>;
  95123. /**
  95124. * Instantiates a new Animation Group.
  95125. * This helps managing several animations at once.
  95126. * @see http://doc.babylonjs.com/how_to/group
  95127. * @param name Defines the name of the group
  95128. * @param scene Defines the scene the group belongs to
  95129. */
  95130. constructor(
  95131. /** The name of the animation group */
  95132. name: string, scene?: Nullable<Scene>);
  95133. /**
  95134. * Add an animation (with its target) in the group
  95135. * @param animation defines the animation we want to add
  95136. * @param target defines the target of the animation
  95137. * @returns the TargetedAnimation object
  95138. */
  95139. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  95140. /**
  95141. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  95142. * It can add constant keys at begin or end
  95143. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  95144. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  95145. * @returns the animation group
  95146. */
  95147. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  95148. /**
  95149. * Start all animations on given targets
  95150. * @param loop defines if animations must loop
  95151. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  95152. * @param from defines the from key (optional)
  95153. * @param to defines the to key (optional)
  95154. * @returns the current animation group
  95155. */
  95156. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  95157. /**
  95158. * Pause all animations
  95159. * @returns the animation group
  95160. */
  95161. pause(): AnimationGroup;
  95162. /**
  95163. * Play all animations to initial state
  95164. * This function will start() the animations if they were not started or will restart() them if they were paused
  95165. * @param loop defines if animations must loop
  95166. * @returns the animation group
  95167. */
  95168. play(loop?: boolean): AnimationGroup;
  95169. /**
  95170. * Reset all animations to initial state
  95171. * @returns the animation group
  95172. */
  95173. reset(): AnimationGroup;
  95174. /**
  95175. * Restart animations from key 0
  95176. * @returns the animation group
  95177. */
  95178. restart(): AnimationGroup;
  95179. /**
  95180. * Stop all animations
  95181. * @returns the animation group
  95182. */
  95183. stop(): AnimationGroup;
  95184. /**
  95185. * Set animation weight for all animatables
  95186. * @param weight defines the weight to use
  95187. * @return the animationGroup
  95188. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  95189. */
  95190. setWeightForAllAnimatables(weight: number): AnimationGroup;
  95191. /**
  95192. * Synchronize and normalize all animatables with a source animatable
  95193. * @param root defines the root animatable to synchronize with
  95194. * @return the animationGroup
  95195. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  95196. */
  95197. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  95198. /**
  95199. * Goes to a specific frame in this animation group
  95200. * @param frame the frame number to go to
  95201. * @return the animationGroup
  95202. */
  95203. goToFrame(frame: number): AnimationGroup;
  95204. /**
  95205. * Dispose all associated resources
  95206. */
  95207. dispose(): void;
  95208. private _checkAnimationGroupEnded;
  95209. /**
  95210. * Clone the current animation group and returns a copy
  95211. * @param newName defines the name of the new group
  95212. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  95213. * @returns the new aniamtion group
  95214. */
  95215. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  95216. /**
  95217. * Serializes the animationGroup to an object
  95218. * @returns Serialized object
  95219. */
  95220. serialize(): any;
  95221. /**
  95222. * Returns a new AnimationGroup object parsed from the source provided.
  95223. * @param parsedAnimationGroup defines the source
  95224. * @param scene defines the scene that will receive the animationGroup
  95225. * @returns a new AnimationGroup
  95226. */
  95227. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  95228. /**
  95229. * Returns the string "AnimationGroup"
  95230. * @returns "AnimationGroup"
  95231. */
  95232. getClassName(): string;
  95233. /**
  95234. * Creates a detailled string about the object
  95235. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  95236. * @returns a string representing the object
  95237. */
  95238. toString(fullDetails?: boolean): string;
  95239. }
  95240. }
  95241. declare module BABYLON {
  95242. /**
  95243. * Define an interface for all classes that will hold resources
  95244. */
  95245. export interface IDisposable {
  95246. /**
  95247. * Releases all held resources
  95248. */
  95249. dispose(): void;
  95250. }
  95251. /** Interface defining initialization parameters for Scene class */
  95252. export interface SceneOptions {
  95253. /**
  95254. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  95255. * It will improve performance when the number of geometries becomes important.
  95256. */
  95257. useGeometryUniqueIdsMap?: boolean;
  95258. /**
  95259. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  95260. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  95261. */
  95262. useMaterialMeshMap?: boolean;
  95263. /**
  95264. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  95265. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  95266. */
  95267. useClonedMeshhMap?: boolean;
  95268. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  95269. virtual?: boolean;
  95270. }
  95271. /**
  95272. * Represents a scene to be rendered by the engine.
  95273. * @see http://doc.babylonjs.com/features/scene
  95274. */
  95275. export class Scene extends AbstractScene implements IAnimatable {
  95276. private static _uniqueIdCounter;
  95277. /** The fog is deactivated */
  95278. static readonly FOGMODE_NONE: number;
  95279. /** The fog density is following an exponential function */
  95280. static readonly FOGMODE_EXP: number;
  95281. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  95282. static readonly FOGMODE_EXP2: number;
  95283. /** The fog density is following a linear function. */
  95284. static readonly FOGMODE_LINEAR: number;
  95285. /**
  95286. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  95287. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95288. */
  95289. static MinDeltaTime: number;
  95290. /**
  95291. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  95292. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95293. */
  95294. static MaxDeltaTime: number;
  95295. /**
  95296. * Factory used to create the default material.
  95297. * @param name The name of the material to create
  95298. * @param scene The scene to create the material for
  95299. * @returns The default material
  95300. */
  95301. static DefaultMaterialFactory(scene: Scene): Material;
  95302. /**
  95303. * Factory used to create the a collision coordinator.
  95304. * @returns The collision coordinator
  95305. */
  95306. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  95307. /** @hidden */
  95308. _inputManager: InputManager;
  95309. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  95310. cameraToUseForPointers: Nullable<Camera>;
  95311. /** @hidden */
  95312. readonly _isScene: boolean;
  95313. /**
  95314. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  95315. */
  95316. autoClear: boolean;
  95317. /**
  95318. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  95319. */
  95320. autoClearDepthAndStencil: boolean;
  95321. /**
  95322. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  95323. */
  95324. clearColor: Color4;
  95325. /**
  95326. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  95327. */
  95328. ambientColor: Color3;
  95329. /**
  95330. * This is use to store the default BRDF lookup for PBR materials in your scene.
  95331. * It should only be one of the following (if not the default embedded one):
  95332. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  95333. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  95334. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  95335. * The material properties need to be setup according to the type of texture in use.
  95336. */
  95337. environmentBRDFTexture: BaseTexture;
  95338. /** @hidden */
  95339. protected _environmentTexture: Nullable<BaseTexture>;
  95340. /**
  95341. * Texture used in all pbr material as the reflection texture.
  95342. * As in the majority of the scene they are the same (exception for multi room and so on),
  95343. * this is easier to reference from here than from all the materials.
  95344. */
  95345. /**
  95346. * Texture used in all pbr material as the reflection texture.
  95347. * As in the majority of the scene they are the same (exception for multi room and so on),
  95348. * this is easier to set here than in all the materials.
  95349. */
  95350. environmentTexture: Nullable<BaseTexture>;
  95351. /** @hidden */
  95352. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95353. /**
  95354. * Default image processing configuration used either in the rendering
  95355. * Forward main pass or through the imageProcessingPostProcess if present.
  95356. * As in the majority of the scene they are the same (exception for multi camera),
  95357. * this is easier to reference from here than from all the materials and post process.
  95358. *
  95359. * No setter as we it is a shared configuration, you can set the values instead.
  95360. */
  95361. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  95362. private _forceWireframe;
  95363. /**
  95364. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  95365. */
  95366. forceWireframe: boolean;
  95367. private _forcePointsCloud;
  95368. /**
  95369. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  95370. */
  95371. forcePointsCloud: boolean;
  95372. /**
  95373. * Gets or sets the active clipplane 1
  95374. */
  95375. clipPlane: Nullable<Plane>;
  95376. /**
  95377. * Gets or sets the active clipplane 2
  95378. */
  95379. clipPlane2: Nullable<Plane>;
  95380. /**
  95381. * Gets or sets the active clipplane 3
  95382. */
  95383. clipPlane3: Nullable<Plane>;
  95384. /**
  95385. * Gets or sets the active clipplane 4
  95386. */
  95387. clipPlane4: Nullable<Plane>;
  95388. /**
  95389. * Gets or sets a boolean indicating if animations are enabled
  95390. */
  95391. animationsEnabled: boolean;
  95392. private _animationPropertiesOverride;
  95393. /**
  95394. * Gets or sets the animation properties override
  95395. */
  95396. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95397. /**
  95398. * Gets or sets a boolean indicating if a constant deltatime has to be used
  95399. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  95400. */
  95401. useConstantAnimationDeltaTime: boolean;
  95402. /**
  95403. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  95404. * Please note that it requires to run a ray cast through the scene on every frame
  95405. */
  95406. constantlyUpdateMeshUnderPointer: boolean;
  95407. /**
  95408. * Defines the HTML cursor to use when hovering over interactive elements
  95409. */
  95410. hoverCursor: string;
  95411. /**
  95412. * Defines the HTML default cursor to use (empty by default)
  95413. */
  95414. defaultCursor: string;
  95415. /**
  95416. * This is used to call preventDefault() on pointer down
  95417. * in order to block unwanted artifacts like system double clicks
  95418. */
  95419. preventDefaultOnPointerDown: boolean;
  95420. /**
  95421. * This is used to call preventDefault() on pointer up
  95422. * in order to block unwanted artifacts like system double clicks
  95423. */
  95424. preventDefaultOnPointerUp: boolean;
  95425. /**
  95426. * Gets or sets user defined metadata
  95427. */
  95428. metadata: any;
  95429. /**
  95430. * For internal use only. Please do not use.
  95431. */
  95432. reservedDataStore: any;
  95433. /**
  95434. * Gets the name of the plugin used to load this scene (null by default)
  95435. */
  95436. loadingPluginName: string;
  95437. /**
  95438. * Use this array to add regular expressions used to disable offline support for specific urls
  95439. */
  95440. disableOfflineSupportExceptionRules: RegExp[];
  95441. /**
  95442. * An event triggered when the scene is disposed.
  95443. */
  95444. onDisposeObservable: Observable<Scene>;
  95445. private _onDisposeObserver;
  95446. /** Sets a function to be executed when this scene is disposed. */
  95447. onDispose: () => void;
  95448. /**
  95449. * An event triggered before rendering the scene (right after animations and physics)
  95450. */
  95451. onBeforeRenderObservable: Observable<Scene>;
  95452. private _onBeforeRenderObserver;
  95453. /** Sets a function to be executed before rendering this scene */
  95454. beforeRender: Nullable<() => void>;
  95455. /**
  95456. * An event triggered after rendering the scene
  95457. */
  95458. onAfterRenderObservable: Observable<Scene>;
  95459. /**
  95460. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  95461. */
  95462. onAfterRenderCameraObservable: Observable<Camera>;
  95463. private _onAfterRenderObserver;
  95464. /** Sets a function to be executed after rendering this scene */
  95465. afterRender: Nullable<() => void>;
  95466. /**
  95467. * An event triggered before animating the scene
  95468. */
  95469. onBeforeAnimationsObservable: Observable<Scene>;
  95470. /**
  95471. * An event triggered after animations processing
  95472. */
  95473. onAfterAnimationsObservable: Observable<Scene>;
  95474. /**
  95475. * An event triggered before draw calls are ready to be sent
  95476. */
  95477. onBeforeDrawPhaseObservable: Observable<Scene>;
  95478. /**
  95479. * An event triggered after draw calls have been sent
  95480. */
  95481. onAfterDrawPhaseObservable: Observable<Scene>;
  95482. /**
  95483. * An event triggered when the scene is ready
  95484. */
  95485. onReadyObservable: Observable<Scene>;
  95486. /**
  95487. * An event triggered before rendering a camera
  95488. */
  95489. onBeforeCameraRenderObservable: Observable<Camera>;
  95490. private _onBeforeCameraRenderObserver;
  95491. /** Sets a function to be executed before rendering a camera*/
  95492. beforeCameraRender: () => void;
  95493. /**
  95494. * An event triggered after rendering a camera
  95495. */
  95496. onAfterCameraRenderObservable: Observable<Camera>;
  95497. private _onAfterCameraRenderObserver;
  95498. /** Sets a function to be executed after rendering a camera*/
  95499. afterCameraRender: () => void;
  95500. /**
  95501. * An event triggered when active meshes evaluation is about to start
  95502. */
  95503. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  95504. /**
  95505. * An event triggered when active meshes evaluation is done
  95506. */
  95507. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  95508. /**
  95509. * An event triggered when particles rendering is about to start
  95510. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95511. */
  95512. onBeforeParticlesRenderingObservable: Observable<Scene>;
  95513. /**
  95514. * An event triggered when particles rendering is done
  95515. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95516. */
  95517. onAfterParticlesRenderingObservable: Observable<Scene>;
  95518. /**
  95519. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  95520. */
  95521. onDataLoadedObservable: Observable<Scene>;
  95522. /**
  95523. * An event triggered when a camera is created
  95524. */
  95525. onNewCameraAddedObservable: Observable<Camera>;
  95526. /**
  95527. * An event triggered when a camera is removed
  95528. */
  95529. onCameraRemovedObservable: Observable<Camera>;
  95530. /**
  95531. * An event triggered when a light is created
  95532. */
  95533. onNewLightAddedObservable: Observable<Light>;
  95534. /**
  95535. * An event triggered when a light is removed
  95536. */
  95537. onLightRemovedObservable: Observable<Light>;
  95538. /**
  95539. * An event triggered when a geometry is created
  95540. */
  95541. onNewGeometryAddedObservable: Observable<Geometry>;
  95542. /**
  95543. * An event triggered when a geometry is removed
  95544. */
  95545. onGeometryRemovedObservable: Observable<Geometry>;
  95546. /**
  95547. * An event triggered when a transform node is created
  95548. */
  95549. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  95550. /**
  95551. * An event triggered when a transform node is removed
  95552. */
  95553. onTransformNodeRemovedObservable: Observable<TransformNode>;
  95554. /**
  95555. * An event triggered when a mesh is created
  95556. */
  95557. onNewMeshAddedObservable: Observable<AbstractMesh>;
  95558. /**
  95559. * An event triggered when a mesh is removed
  95560. */
  95561. onMeshRemovedObservable: Observable<AbstractMesh>;
  95562. /**
  95563. * An event triggered when a skeleton is created
  95564. */
  95565. onNewSkeletonAddedObservable: Observable<Skeleton>;
  95566. /**
  95567. * An event triggered when a skeleton is removed
  95568. */
  95569. onSkeletonRemovedObservable: Observable<Skeleton>;
  95570. /**
  95571. * An event triggered when a material is created
  95572. */
  95573. onNewMaterialAddedObservable: Observable<Material>;
  95574. /**
  95575. * An event triggered when a material is removed
  95576. */
  95577. onMaterialRemovedObservable: Observable<Material>;
  95578. /**
  95579. * An event triggered when a texture is created
  95580. */
  95581. onNewTextureAddedObservable: Observable<BaseTexture>;
  95582. /**
  95583. * An event triggered when a texture is removed
  95584. */
  95585. onTextureRemovedObservable: Observable<BaseTexture>;
  95586. /**
  95587. * An event triggered when render targets are about to be rendered
  95588. * Can happen multiple times per frame.
  95589. */
  95590. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  95591. /**
  95592. * An event triggered when render targets were rendered.
  95593. * Can happen multiple times per frame.
  95594. */
  95595. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  95596. /**
  95597. * An event triggered before calculating deterministic simulation step
  95598. */
  95599. onBeforeStepObservable: Observable<Scene>;
  95600. /**
  95601. * An event triggered after calculating deterministic simulation step
  95602. */
  95603. onAfterStepObservable: Observable<Scene>;
  95604. /**
  95605. * An event triggered when the activeCamera property is updated
  95606. */
  95607. onActiveCameraChanged: Observable<Scene>;
  95608. /**
  95609. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  95610. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95611. * 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)
  95612. */
  95613. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95614. /**
  95615. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  95616. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95617. * 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)
  95618. */
  95619. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95620. /**
  95621. * This Observable will when a mesh has been imported into the scene.
  95622. */
  95623. onMeshImportedObservable: Observable<AbstractMesh>;
  95624. /**
  95625. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  95626. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  95627. */
  95628. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  95629. /** @hidden */
  95630. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  95631. /**
  95632. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  95633. */
  95634. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  95635. /**
  95636. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  95637. */
  95638. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  95639. /**
  95640. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  95641. */
  95642. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  95643. /** Callback called when a pointer move is detected */
  95644. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95645. /** Callback called when a pointer down is detected */
  95646. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95647. /** Callback called when a pointer up is detected */
  95648. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  95649. /** Callback called when a pointer pick is detected */
  95650. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  95651. /**
  95652. * 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).
  95653. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  95654. */
  95655. onPrePointerObservable: Observable<PointerInfoPre>;
  95656. /**
  95657. * Observable event triggered each time an input event is received from the rendering canvas
  95658. */
  95659. onPointerObservable: Observable<PointerInfo>;
  95660. /**
  95661. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  95662. */
  95663. readonly unTranslatedPointer: Vector2;
  95664. /**
  95665. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  95666. */
  95667. static DragMovementThreshold: number;
  95668. /**
  95669. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  95670. */
  95671. static LongPressDelay: number;
  95672. /**
  95673. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  95674. */
  95675. static DoubleClickDelay: number;
  95676. /** If you need to check double click without raising a single click at first click, enable this flag */
  95677. static ExclusiveDoubleClickMode: boolean;
  95678. /** @hidden */
  95679. _mirroredCameraPosition: Nullable<Vector3>;
  95680. /**
  95681. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  95682. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  95683. */
  95684. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  95685. /**
  95686. * Observable event triggered each time an keyboard event is received from the hosting window
  95687. */
  95688. onKeyboardObservable: Observable<KeyboardInfo>;
  95689. private _useRightHandedSystem;
  95690. /**
  95691. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  95692. */
  95693. useRightHandedSystem: boolean;
  95694. private _timeAccumulator;
  95695. private _currentStepId;
  95696. private _currentInternalStep;
  95697. /**
  95698. * Sets the step Id used by deterministic lock step
  95699. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95700. * @param newStepId defines the step Id
  95701. */
  95702. setStepId(newStepId: number): void;
  95703. /**
  95704. * Gets the step Id used by deterministic lock step
  95705. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95706. * @returns the step Id
  95707. */
  95708. getStepId(): number;
  95709. /**
  95710. * Gets the internal step used by deterministic lock step
  95711. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95712. * @returns the internal step
  95713. */
  95714. getInternalStep(): number;
  95715. private _fogEnabled;
  95716. /**
  95717. * Gets or sets a boolean indicating if fog is enabled on this scene
  95718. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95719. * (Default is true)
  95720. */
  95721. fogEnabled: boolean;
  95722. private _fogMode;
  95723. /**
  95724. * Gets or sets the fog mode to use
  95725. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95726. * | mode | value |
  95727. * | --- | --- |
  95728. * | FOGMODE_NONE | 0 |
  95729. * | FOGMODE_EXP | 1 |
  95730. * | FOGMODE_EXP2 | 2 |
  95731. * | FOGMODE_LINEAR | 3 |
  95732. */
  95733. fogMode: number;
  95734. /**
  95735. * Gets or sets the fog color to use
  95736. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95737. * (Default is Color3(0.2, 0.2, 0.3))
  95738. */
  95739. fogColor: Color3;
  95740. /**
  95741. * Gets or sets the fog density to use
  95742. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95743. * (Default is 0.1)
  95744. */
  95745. fogDensity: number;
  95746. /**
  95747. * Gets or sets the fog start distance to use
  95748. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95749. * (Default is 0)
  95750. */
  95751. fogStart: number;
  95752. /**
  95753. * Gets or sets the fog end distance to use
  95754. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95755. * (Default is 1000)
  95756. */
  95757. fogEnd: number;
  95758. private _shadowsEnabled;
  95759. /**
  95760. * Gets or sets a boolean indicating if shadows are enabled on this scene
  95761. */
  95762. shadowsEnabled: boolean;
  95763. private _lightsEnabled;
  95764. /**
  95765. * Gets or sets a boolean indicating if lights are enabled on this scene
  95766. */
  95767. lightsEnabled: boolean;
  95768. /** All of the active cameras added to this scene. */
  95769. activeCameras: Camera[];
  95770. /** @hidden */
  95771. _activeCamera: Nullable<Camera>;
  95772. /** Gets or sets the current active camera */
  95773. activeCamera: Nullable<Camera>;
  95774. private _defaultMaterial;
  95775. /** The default material used on meshes when no material is affected */
  95776. /** The default material used on meshes when no material is affected */
  95777. defaultMaterial: Material;
  95778. private _texturesEnabled;
  95779. /**
  95780. * Gets or sets a boolean indicating if textures are enabled on this scene
  95781. */
  95782. texturesEnabled: boolean;
  95783. /**
  95784. * Gets or sets a boolean indicating if particles are enabled on this scene
  95785. */
  95786. particlesEnabled: boolean;
  95787. /**
  95788. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95789. */
  95790. spritesEnabled: boolean;
  95791. private _skeletonsEnabled;
  95792. /**
  95793. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95794. */
  95795. skeletonsEnabled: boolean;
  95796. /**
  95797. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95798. */
  95799. lensFlaresEnabled: boolean;
  95800. /**
  95801. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95802. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95803. */
  95804. collisionsEnabled: boolean;
  95805. private _collisionCoordinator;
  95806. /** @hidden */
  95807. readonly collisionCoordinator: ICollisionCoordinator;
  95808. /**
  95809. * Defines the gravity applied to this scene (used only for collisions)
  95810. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95811. */
  95812. gravity: Vector3;
  95813. /**
  95814. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95815. */
  95816. postProcessesEnabled: boolean;
  95817. /**
  95818. * The list of postprocesses added to the scene
  95819. */
  95820. postProcesses: PostProcess[];
  95821. /**
  95822. * Gets the current postprocess manager
  95823. */
  95824. postProcessManager: PostProcessManager;
  95825. /**
  95826. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95827. */
  95828. renderTargetsEnabled: boolean;
  95829. /**
  95830. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95831. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95832. */
  95833. dumpNextRenderTargets: boolean;
  95834. /**
  95835. * The list of user defined render targets added to the scene
  95836. */
  95837. customRenderTargets: RenderTargetTexture[];
  95838. /**
  95839. * Defines if texture loading must be delayed
  95840. * If true, textures will only be loaded when they need to be rendered
  95841. */
  95842. useDelayedTextureLoading: boolean;
  95843. /**
  95844. * Gets the list of meshes imported to the scene through SceneLoader
  95845. */
  95846. importedMeshesFiles: String[];
  95847. /**
  95848. * Gets or sets a boolean indicating if probes are enabled on this scene
  95849. */
  95850. probesEnabled: boolean;
  95851. /**
  95852. * Gets or sets the current offline provider to use to store scene data
  95853. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95854. */
  95855. offlineProvider: IOfflineProvider;
  95856. /**
  95857. * Gets or sets the action manager associated with the scene
  95858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95859. */
  95860. actionManager: AbstractActionManager;
  95861. private _meshesForIntersections;
  95862. /**
  95863. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95864. */
  95865. proceduralTexturesEnabled: boolean;
  95866. private _engine;
  95867. private _totalVertices;
  95868. /** @hidden */
  95869. _activeIndices: PerfCounter;
  95870. /** @hidden */
  95871. _activeParticles: PerfCounter;
  95872. /** @hidden */
  95873. _activeBones: PerfCounter;
  95874. private _animationRatio;
  95875. /** @hidden */
  95876. _animationTimeLast: number;
  95877. /** @hidden */
  95878. _animationTime: number;
  95879. /**
  95880. * Gets or sets a general scale for animation speed
  95881. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95882. */
  95883. animationTimeScale: number;
  95884. /** @hidden */
  95885. _cachedMaterial: Nullable<Material>;
  95886. /** @hidden */
  95887. _cachedEffect: Nullable<Effect>;
  95888. /** @hidden */
  95889. _cachedVisibility: Nullable<number>;
  95890. private _renderId;
  95891. private _frameId;
  95892. private _executeWhenReadyTimeoutId;
  95893. private _intermediateRendering;
  95894. private _viewUpdateFlag;
  95895. private _projectionUpdateFlag;
  95896. /** @hidden */
  95897. _toBeDisposed: Nullable<IDisposable>[];
  95898. private _activeRequests;
  95899. /** @hidden */
  95900. _pendingData: any[];
  95901. private _isDisposed;
  95902. /**
  95903. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95904. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95905. */
  95906. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95907. private _activeMeshes;
  95908. private _processedMaterials;
  95909. private _renderTargets;
  95910. /** @hidden */
  95911. _activeParticleSystems: SmartArray<IParticleSystem>;
  95912. private _activeSkeletons;
  95913. private _softwareSkinnedMeshes;
  95914. private _renderingManager;
  95915. /** @hidden */
  95916. _activeAnimatables: Animatable[];
  95917. private _transformMatrix;
  95918. private _sceneUbo;
  95919. /** @hidden */
  95920. _viewMatrix: Matrix;
  95921. private _projectionMatrix;
  95922. /** @hidden */
  95923. _forcedViewPosition: Nullable<Vector3>;
  95924. /** @hidden */
  95925. _frustumPlanes: Plane[];
  95926. /**
  95927. * Gets the list of frustum planes (built from the active camera)
  95928. */
  95929. readonly frustumPlanes: Plane[];
  95930. /**
  95931. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95932. * This is useful if there are more lights that the maximum simulteanous authorized
  95933. */
  95934. requireLightSorting: boolean;
  95935. /** @hidden */
  95936. readonly useMaterialMeshMap: boolean;
  95937. /** @hidden */
  95938. readonly useClonedMeshhMap: boolean;
  95939. private _externalData;
  95940. private _uid;
  95941. /**
  95942. * @hidden
  95943. * Backing store of defined scene components.
  95944. */
  95945. _components: ISceneComponent[];
  95946. /**
  95947. * @hidden
  95948. * Backing store of defined scene components.
  95949. */
  95950. _serializableComponents: ISceneSerializableComponent[];
  95951. /**
  95952. * List of components to register on the next registration step.
  95953. */
  95954. private _transientComponents;
  95955. /**
  95956. * Registers the transient components if needed.
  95957. */
  95958. private _registerTransientComponents;
  95959. /**
  95960. * @hidden
  95961. * Add a component to the scene.
  95962. * Note that the ccomponent could be registered on th next frame if this is called after
  95963. * the register component stage.
  95964. * @param component Defines the component to add to the scene
  95965. */
  95966. _addComponent(component: ISceneComponent): void;
  95967. /**
  95968. * @hidden
  95969. * Gets a component from the scene.
  95970. * @param name defines the name of the component to retrieve
  95971. * @returns the component or null if not present
  95972. */
  95973. _getComponent(name: string): Nullable<ISceneComponent>;
  95974. /**
  95975. * @hidden
  95976. * Defines the actions happening before camera updates.
  95977. */
  95978. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95979. /**
  95980. * @hidden
  95981. * Defines the actions happening before clear the canvas.
  95982. */
  95983. _beforeClearStage: Stage<SimpleStageAction>;
  95984. /**
  95985. * @hidden
  95986. * Defines the actions when collecting render targets for the frame.
  95987. */
  95988. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95989. /**
  95990. * @hidden
  95991. * Defines the actions happening for one camera in the frame.
  95992. */
  95993. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95994. /**
  95995. * @hidden
  95996. * Defines the actions happening during the per mesh ready checks.
  95997. */
  95998. _isReadyForMeshStage: Stage<MeshStageAction>;
  95999. /**
  96000. * @hidden
  96001. * Defines the actions happening before evaluate active mesh checks.
  96002. */
  96003. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  96004. /**
  96005. * @hidden
  96006. * Defines the actions happening during the evaluate sub mesh checks.
  96007. */
  96008. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  96009. /**
  96010. * @hidden
  96011. * Defines the actions happening during the active mesh stage.
  96012. */
  96013. _activeMeshStage: Stage<ActiveMeshStageAction>;
  96014. /**
  96015. * @hidden
  96016. * Defines the actions happening during the per camera render target step.
  96017. */
  96018. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  96019. /**
  96020. * @hidden
  96021. * Defines the actions happening just before the active camera is drawing.
  96022. */
  96023. _beforeCameraDrawStage: Stage<CameraStageAction>;
  96024. /**
  96025. * @hidden
  96026. * Defines the actions happening just before a render target is drawing.
  96027. */
  96028. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  96029. /**
  96030. * @hidden
  96031. * Defines the actions happening just before a rendering group is drawing.
  96032. */
  96033. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  96034. /**
  96035. * @hidden
  96036. * Defines the actions happening just before a mesh is drawing.
  96037. */
  96038. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  96039. /**
  96040. * @hidden
  96041. * Defines the actions happening just after a mesh has been drawn.
  96042. */
  96043. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  96044. /**
  96045. * @hidden
  96046. * Defines the actions happening just after a rendering group has been drawn.
  96047. */
  96048. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  96049. /**
  96050. * @hidden
  96051. * Defines the actions happening just after the active camera has been drawn.
  96052. */
  96053. _afterCameraDrawStage: Stage<CameraStageAction>;
  96054. /**
  96055. * @hidden
  96056. * Defines the actions happening just after a render target has been drawn.
  96057. */
  96058. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  96059. /**
  96060. * @hidden
  96061. * Defines the actions happening just after rendering all cameras and computing intersections.
  96062. */
  96063. _afterRenderStage: Stage<SimpleStageAction>;
  96064. /**
  96065. * @hidden
  96066. * Defines the actions happening when a pointer move event happens.
  96067. */
  96068. _pointerMoveStage: Stage<PointerMoveStageAction>;
  96069. /**
  96070. * @hidden
  96071. * Defines the actions happening when a pointer down event happens.
  96072. */
  96073. _pointerDownStage: Stage<PointerUpDownStageAction>;
  96074. /**
  96075. * @hidden
  96076. * Defines the actions happening when a pointer up event happens.
  96077. */
  96078. _pointerUpStage: Stage<PointerUpDownStageAction>;
  96079. /**
  96080. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  96081. */
  96082. private geometriesByUniqueId;
  96083. /**
  96084. * Creates a new Scene
  96085. * @param engine defines the engine to use to render this scene
  96086. * @param options defines the scene options
  96087. */
  96088. constructor(engine: Engine, options?: SceneOptions);
  96089. /**
  96090. * Gets a string idenfifying the name of the class
  96091. * @returns "Scene" string
  96092. */
  96093. getClassName(): string;
  96094. private _defaultMeshCandidates;
  96095. /**
  96096. * @hidden
  96097. */
  96098. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  96099. private _defaultSubMeshCandidates;
  96100. /**
  96101. * @hidden
  96102. */
  96103. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  96104. /**
  96105. * Sets the default candidate providers for the scene.
  96106. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  96107. * and getCollidingSubMeshCandidates to their default function
  96108. */
  96109. setDefaultCandidateProviders(): void;
  96110. /**
  96111. * Gets the mesh that is currently under the pointer
  96112. */
  96113. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96114. /**
  96115. * Gets or sets the current on-screen X position of the pointer
  96116. */
  96117. pointerX: number;
  96118. /**
  96119. * Gets or sets the current on-screen Y position of the pointer
  96120. */
  96121. pointerY: number;
  96122. /**
  96123. * Gets the cached material (ie. the latest rendered one)
  96124. * @returns the cached material
  96125. */
  96126. getCachedMaterial(): Nullable<Material>;
  96127. /**
  96128. * Gets the cached effect (ie. the latest rendered one)
  96129. * @returns the cached effect
  96130. */
  96131. getCachedEffect(): Nullable<Effect>;
  96132. /**
  96133. * Gets the cached visibility state (ie. the latest rendered one)
  96134. * @returns the cached visibility state
  96135. */
  96136. getCachedVisibility(): Nullable<number>;
  96137. /**
  96138. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  96139. * @param material defines the current material
  96140. * @param effect defines the current effect
  96141. * @param visibility defines the current visibility state
  96142. * @returns true if one parameter is not cached
  96143. */
  96144. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  96145. /**
  96146. * Gets the engine associated with the scene
  96147. * @returns an Engine
  96148. */
  96149. getEngine(): Engine;
  96150. /**
  96151. * Gets the total number of vertices rendered per frame
  96152. * @returns the total number of vertices rendered per frame
  96153. */
  96154. getTotalVertices(): number;
  96155. /**
  96156. * Gets the performance counter for total vertices
  96157. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96158. */
  96159. readonly totalVerticesPerfCounter: PerfCounter;
  96160. /**
  96161. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  96162. * @returns the total number of active indices rendered per frame
  96163. */
  96164. getActiveIndices(): number;
  96165. /**
  96166. * Gets the performance counter for active indices
  96167. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96168. */
  96169. readonly totalActiveIndicesPerfCounter: PerfCounter;
  96170. /**
  96171. * Gets the total number of active particles rendered per frame
  96172. * @returns the total number of active particles rendered per frame
  96173. */
  96174. getActiveParticles(): number;
  96175. /**
  96176. * Gets the performance counter for active particles
  96177. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96178. */
  96179. readonly activeParticlesPerfCounter: PerfCounter;
  96180. /**
  96181. * Gets the total number of active bones rendered per frame
  96182. * @returns the total number of active bones rendered per frame
  96183. */
  96184. getActiveBones(): number;
  96185. /**
  96186. * Gets the performance counter for active bones
  96187. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96188. */
  96189. readonly activeBonesPerfCounter: PerfCounter;
  96190. /**
  96191. * Gets the array of active meshes
  96192. * @returns an array of AbstractMesh
  96193. */
  96194. getActiveMeshes(): SmartArray<AbstractMesh>;
  96195. /**
  96196. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  96197. * @returns a number
  96198. */
  96199. getAnimationRatio(): number;
  96200. /**
  96201. * Gets an unique Id for the current render phase
  96202. * @returns a number
  96203. */
  96204. getRenderId(): number;
  96205. /**
  96206. * Gets an unique Id for the current frame
  96207. * @returns a number
  96208. */
  96209. getFrameId(): number;
  96210. /** Call this function if you want to manually increment the render Id*/
  96211. incrementRenderId(): void;
  96212. private _createUbo;
  96213. /**
  96214. * Use this method to simulate a pointer move on a mesh
  96215. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96216. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96217. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96218. * @returns the current scene
  96219. */
  96220. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  96221. /**
  96222. * Use this method to simulate a pointer down on a mesh
  96223. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96224. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96225. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96226. * @returns the current scene
  96227. */
  96228. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  96229. /**
  96230. * Use this method to simulate a pointer up on a mesh
  96231. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96232. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96233. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96234. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96235. * @returns the current scene
  96236. */
  96237. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  96238. /**
  96239. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96240. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96241. * @returns true if the pointer was captured
  96242. */
  96243. isPointerCaptured(pointerId?: number): boolean;
  96244. /**
  96245. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96246. * @param attachUp defines if you want to attach events to pointerup
  96247. * @param attachDown defines if you want to attach events to pointerdown
  96248. * @param attachMove defines if you want to attach events to pointermove
  96249. */
  96250. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96251. /** Detaches all event handlers*/
  96252. detachControl(): void;
  96253. /**
  96254. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  96255. * Delay loaded resources are not taking in account
  96256. * @return true if all required resources are ready
  96257. */
  96258. isReady(): boolean;
  96259. /** Resets all cached information relative to material (including effect and visibility) */
  96260. resetCachedMaterial(): void;
  96261. /**
  96262. * Registers a function to be called before every frame render
  96263. * @param func defines the function to register
  96264. */
  96265. registerBeforeRender(func: () => void): void;
  96266. /**
  96267. * Unregisters a function called before every frame render
  96268. * @param func defines the function to unregister
  96269. */
  96270. unregisterBeforeRender(func: () => void): void;
  96271. /**
  96272. * Registers a function to be called after every frame render
  96273. * @param func defines the function to register
  96274. */
  96275. registerAfterRender(func: () => void): void;
  96276. /**
  96277. * Unregisters a function called after every frame render
  96278. * @param func defines the function to unregister
  96279. */
  96280. unregisterAfterRender(func: () => void): void;
  96281. private _executeOnceBeforeRender;
  96282. /**
  96283. * The provided function will run before render once and will be disposed afterwards.
  96284. * A timeout delay can be provided so that the function will be executed in N ms.
  96285. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  96286. * @param func The function to be executed.
  96287. * @param timeout optional delay in ms
  96288. */
  96289. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  96290. /** @hidden */
  96291. _addPendingData(data: any): void;
  96292. /** @hidden */
  96293. _removePendingData(data: any): void;
  96294. /**
  96295. * Returns the number of items waiting to be loaded
  96296. * @returns the number of items waiting to be loaded
  96297. */
  96298. getWaitingItemsCount(): number;
  96299. /**
  96300. * Returns a boolean indicating if the scene is still loading data
  96301. */
  96302. readonly isLoading: boolean;
  96303. /**
  96304. * Registers a function to be executed when the scene is ready
  96305. * @param {Function} func - the function to be executed
  96306. */
  96307. executeWhenReady(func: () => void): void;
  96308. /**
  96309. * Returns a promise that resolves when the scene is ready
  96310. * @returns A promise that resolves when the scene is ready
  96311. */
  96312. whenReadyAsync(): Promise<void>;
  96313. /** @hidden */
  96314. _checkIsReady(): void;
  96315. /**
  96316. * Gets all animatable attached to the scene
  96317. */
  96318. readonly animatables: Animatable[];
  96319. /**
  96320. * Resets the last animation time frame.
  96321. * Useful to override when animations start running when loading a scene for the first time.
  96322. */
  96323. resetLastAnimationTimeFrame(): void;
  96324. /**
  96325. * Gets the current view matrix
  96326. * @returns a Matrix
  96327. */
  96328. getViewMatrix(): Matrix;
  96329. /**
  96330. * Gets the current projection matrix
  96331. * @returns a Matrix
  96332. */
  96333. getProjectionMatrix(): Matrix;
  96334. /**
  96335. * Gets the current transform matrix
  96336. * @returns a Matrix made of View * Projection
  96337. */
  96338. getTransformMatrix(): Matrix;
  96339. /**
  96340. * Sets the current transform matrix
  96341. * @param viewL defines the View matrix to use
  96342. * @param projectionL defines the Projection matrix to use
  96343. * @param viewR defines the right View matrix to use (if provided)
  96344. * @param projectionR defines the right Projection matrix to use (if provided)
  96345. */
  96346. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  96347. /**
  96348. * Gets the uniform buffer used to store scene data
  96349. * @returns a UniformBuffer
  96350. */
  96351. getSceneUniformBuffer(): UniformBuffer;
  96352. /**
  96353. * Gets an unique (relatively to the current scene) Id
  96354. * @returns an unique number for the scene
  96355. */
  96356. getUniqueId(): number;
  96357. /**
  96358. * Add a mesh to the list of scene's meshes
  96359. * @param newMesh defines the mesh to add
  96360. * @param recursive if all child meshes should also be added to the scene
  96361. */
  96362. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  96363. /**
  96364. * Remove a mesh for the list of scene's meshes
  96365. * @param toRemove defines the mesh to remove
  96366. * @param recursive if all child meshes should also be removed from the scene
  96367. * @returns the index where the mesh was in the mesh list
  96368. */
  96369. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  96370. /**
  96371. * Add a transform node to the list of scene's transform nodes
  96372. * @param newTransformNode defines the transform node to add
  96373. */
  96374. addTransformNode(newTransformNode: TransformNode): void;
  96375. /**
  96376. * Remove a transform node for the list of scene's transform nodes
  96377. * @param toRemove defines the transform node to remove
  96378. * @returns the index where the transform node was in the transform node list
  96379. */
  96380. removeTransformNode(toRemove: TransformNode): number;
  96381. /**
  96382. * Remove a skeleton for the list of scene's skeletons
  96383. * @param toRemove defines the skeleton to remove
  96384. * @returns the index where the skeleton was in the skeleton list
  96385. */
  96386. removeSkeleton(toRemove: Skeleton): number;
  96387. /**
  96388. * Remove a morph target for the list of scene's morph targets
  96389. * @param toRemove defines the morph target to remove
  96390. * @returns the index where the morph target was in the morph target list
  96391. */
  96392. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  96393. /**
  96394. * Remove a light for the list of scene's lights
  96395. * @param toRemove defines the light to remove
  96396. * @returns the index where the light was in the light list
  96397. */
  96398. removeLight(toRemove: Light): number;
  96399. /**
  96400. * Remove a camera for the list of scene's cameras
  96401. * @param toRemove defines the camera to remove
  96402. * @returns the index where the camera was in the camera list
  96403. */
  96404. removeCamera(toRemove: Camera): number;
  96405. /**
  96406. * Remove a particle system for the list of scene's particle systems
  96407. * @param toRemove defines the particle system to remove
  96408. * @returns the index where the particle system was in the particle system list
  96409. */
  96410. removeParticleSystem(toRemove: IParticleSystem): number;
  96411. /**
  96412. * Remove a animation for the list of scene's animations
  96413. * @param toRemove defines the animation to remove
  96414. * @returns the index where the animation was in the animation list
  96415. */
  96416. removeAnimation(toRemove: Animation): number;
  96417. /**
  96418. * Will stop the animation of the given target
  96419. * @param target - the target
  96420. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  96421. * @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)
  96422. */
  96423. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  96424. /**
  96425. * Removes the given animation group from this scene.
  96426. * @param toRemove The animation group to remove
  96427. * @returns The index of the removed animation group
  96428. */
  96429. removeAnimationGroup(toRemove: AnimationGroup): number;
  96430. /**
  96431. * Removes the given multi-material from this scene.
  96432. * @param toRemove The multi-material to remove
  96433. * @returns The index of the removed multi-material
  96434. */
  96435. removeMultiMaterial(toRemove: MultiMaterial): number;
  96436. /**
  96437. * Removes the given material from this scene.
  96438. * @param toRemove The material to remove
  96439. * @returns The index of the removed material
  96440. */
  96441. removeMaterial(toRemove: Material): number;
  96442. /**
  96443. * Removes the given action manager from this scene.
  96444. * @param toRemove The action manager to remove
  96445. * @returns The index of the removed action manager
  96446. */
  96447. removeActionManager(toRemove: AbstractActionManager): number;
  96448. /**
  96449. * Removes the given texture from this scene.
  96450. * @param toRemove The texture to remove
  96451. * @returns The index of the removed texture
  96452. */
  96453. removeTexture(toRemove: BaseTexture): number;
  96454. /**
  96455. * Adds the given light to this scene
  96456. * @param newLight The light to add
  96457. */
  96458. addLight(newLight: Light): void;
  96459. /**
  96460. * Sorts the list list based on light priorities
  96461. */
  96462. sortLightsByPriority(): void;
  96463. /**
  96464. * Adds the given camera to this scene
  96465. * @param newCamera The camera to add
  96466. */
  96467. addCamera(newCamera: Camera): void;
  96468. /**
  96469. * Adds the given skeleton to this scene
  96470. * @param newSkeleton The skeleton to add
  96471. */
  96472. addSkeleton(newSkeleton: Skeleton): void;
  96473. /**
  96474. * Adds the given particle system to this scene
  96475. * @param newParticleSystem The particle system to add
  96476. */
  96477. addParticleSystem(newParticleSystem: IParticleSystem): void;
  96478. /**
  96479. * Adds the given animation to this scene
  96480. * @param newAnimation The animation to add
  96481. */
  96482. addAnimation(newAnimation: Animation): void;
  96483. /**
  96484. * Adds the given animation group to this scene.
  96485. * @param newAnimationGroup The animation group to add
  96486. */
  96487. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  96488. /**
  96489. * Adds the given multi-material to this scene
  96490. * @param newMultiMaterial The multi-material to add
  96491. */
  96492. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  96493. /**
  96494. * Adds the given material to this scene
  96495. * @param newMaterial The material to add
  96496. */
  96497. addMaterial(newMaterial: Material): void;
  96498. /**
  96499. * Adds the given morph target to this scene
  96500. * @param newMorphTargetManager The morph target to add
  96501. */
  96502. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  96503. /**
  96504. * Adds the given geometry to this scene
  96505. * @param newGeometry The geometry to add
  96506. */
  96507. addGeometry(newGeometry: Geometry): void;
  96508. /**
  96509. * Adds the given action manager to this scene
  96510. * @param newActionManager The action manager to add
  96511. */
  96512. addActionManager(newActionManager: AbstractActionManager): void;
  96513. /**
  96514. * Adds the given texture to this scene.
  96515. * @param newTexture The texture to add
  96516. */
  96517. addTexture(newTexture: BaseTexture): void;
  96518. /**
  96519. * Switch active camera
  96520. * @param newCamera defines the new active camera
  96521. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  96522. */
  96523. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  96524. /**
  96525. * sets the active camera of the scene using its ID
  96526. * @param id defines the camera's ID
  96527. * @return the new active camera or null if none found.
  96528. */
  96529. setActiveCameraByID(id: string): Nullable<Camera>;
  96530. /**
  96531. * sets the active camera of the scene using its name
  96532. * @param name defines the camera's name
  96533. * @returns the new active camera or null if none found.
  96534. */
  96535. setActiveCameraByName(name: string): Nullable<Camera>;
  96536. /**
  96537. * get an animation group using its name
  96538. * @param name defines the material's name
  96539. * @return the animation group or null if none found.
  96540. */
  96541. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  96542. /**
  96543. * Get a material using its unique id
  96544. * @param uniqueId defines the material's unique id
  96545. * @return the material or null if none found.
  96546. */
  96547. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  96548. /**
  96549. * get a material using its id
  96550. * @param id defines the material's ID
  96551. * @return the material or null if none found.
  96552. */
  96553. getMaterialByID(id: string): Nullable<Material>;
  96554. /**
  96555. * Gets a the last added material using a given id
  96556. * @param id defines the material's ID
  96557. * @return the last material with the given id or null if none found.
  96558. */
  96559. getLastMaterialByID(id: string): Nullable<Material>;
  96560. /**
  96561. * Gets a material using its name
  96562. * @param name defines the material's name
  96563. * @return the material or null if none found.
  96564. */
  96565. getMaterialByName(name: string): Nullable<Material>;
  96566. /**
  96567. * Gets a camera using its id
  96568. * @param id defines the id to look for
  96569. * @returns the camera or null if not found
  96570. */
  96571. getCameraByID(id: string): Nullable<Camera>;
  96572. /**
  96573. * Gets a camera using its unique id
  96574. * @param uniqueId defines the unique id to look for
  96575. * @returns the camera or null if not found
  96576. */
  96577. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  96578. /**
  96579. * Gets a camera using its name
  96580. * @param name defines the camera's name
  96581. * @return the camera or null if none found.
  96582. */
  96583. getCameraByName(name: string): Nullable<Camera>;
  96584. /**
  96585. * Gets a bone using its id
  96586. * @param id defines the bone's id
  96587. * @return the bone or null if not found
  96588. */
  96589. getBoneByID(id: string): Nullable<Bone>;
  96590. /**
  96591. * Gets a bone using its id
  96592. * @param name defines the bone's name
  96593. * @return the bone or null if not found
  96594. */
  96595. getBoneByName(name: string): Nullable<Bone>;
  96596. /**
  96597. * Gets a light node using its name
  96598. * @param name defines the the light's name
  96599. * @return the light or null if none found.
  96600. */
  96601. getLightByName(name: string): Nullable<Light>;
  96602. /**
  96603. * Gets a light node using its id
  96604. * @param id defines the light's id
  96605. * @return the light or null if none found.
  96606. */
  96607. getLightByID(id: string): Nullable<Light>;
  96608. /**
  96609. * Gets a light node using its scene-generated unique ID
  96610. * @param uniqueId defines the light's unique id
  96611. * @return the light or null if none found.
  96612. */
  96613. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  96614. /**
  96615. * Gets a particle system by id
  96616. * @param id defines the particle system id
  96617. * @return the corresponding system or null if none found
  96618. */
  96619. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  96620. /**
  96621. * Gets a geometry using its ID
  96622. * @param id defines the geometry's id
  96623. * @return the geometry or null if none found.
  96624. */
  96625. getGeometryByID(id: string): Nullable<Geometry>;
  96626. private _getGeometryByUniqueID;
  96627. /**
  96628. * Add a new geometry to this scene
  96629. * @param geometry defines the geometry to be added to the scene.
  96630. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  96631. * @return a boolean defining if the geometry was added or not
  96632. */
  96633. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  96634. /**
  96635. * Removes an existing geometry
  96636. * @param geometry defines the geometry to be removed from the scene
  96637. * @return a boolean defining if the geometry was removed or not
  96638. */
  96639. removeGeometry(geometry: Geometry): boolean;
  96640. /**
  96641. * Gets the list of geometries attached to the scene
  96642. * @returns an array of Geometry
  96643. */
  96644. getGeometries(): Geometry[];
  96645. /**
  96646. * Gets the first added mesh found of a given ID
  96647. * @param id defines the id to search for
  96648. * @return the mesh found or null if not found at all
  96649. */
  96650. getMeshByID(id: string): Nullable<AbstractMesh>;
  96651. /**
  96652. * Gets a list of meshes using their id
  96653. * @param id defines the id to search for
  96654. * @returns a list of meshes
  96655. */
  96656. getMeshesByID(id: string): Array<AbstractMesh>;
  96657. /**
  96658. * Gets the first added transform node found of a given ID
  96659. * @param id defines the id to search for
  96660. * @return the found transform node or null if not found at all.
  96661. */
  96662. getTransformNodeByID(id: string): Nullable<TransformNode>;
  96663. /**
  96664. * Gets a transform node with its auto-generated unique id
  96665. * @param uniqueId efines the unique id to search for
  96666. * @return the found transform node or null if not found at all.
  96667. */
  96668. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  96669. /**
  96670. * Gets a list of transform nodes using their id
  96671. * @param id defines the id to search for
  96672. * @returns a list of transform nodes
  96673. */
  96674. getTransformNodesByID(id: string): Array<TransformNode>;
  96675. /**
  96676. * Gets a mesh with its auto-generated unique id
  96677. * @param uniqueId defines the unique id to search for
  96678. * @return the found mesh or null if not found at all.
  96679. */
  96680. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  96681. /**
  96682. * Gets a the last added mesh using a given id
  96683. * @param id defines the id to search for
  96684. * @return the found mesh or null if not found at all.
  96685. */
  96686. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  96687. /**
  96688. * Gets a the last added node (Mesh, Camera, Light) using a given id
  96689. * @param id defines the id to search for
  96690. * @return the found node or null if not found at all
  96691. */
  96692. getLastEntryByID(id: string): Nullable<Node>;
  96693. /**
  96694. * Gets a node (Mesh, Camera, Light) using a given id
  96695. * @param id defines the id to search for
  96696. * @return the found node or null if not found at all
  96697. */
  96698. getNodeByID(id: string): Nullable<Node>;
  96699. /**
  96700. * Gets a node (Mesh, Camera, Light) using a given name
  96701. * @param name defines the name to search for
  96702. * @return the found node or null if not found at all.
  96703. */
  96704. getNodeByName(name: string): Nullable<Node>;
  96705. /**
  96706. * Gets a mesh using a given name
  96707. * @param name defines the name to search for
  96708. * @return the found mesh or null if not found at all.
  96709. */
  96710. getMeshByName(name: string): Nullable<AbstractMesh>;
  96711. /**
  96712. * Gets a transform node using a given name
  96713. * @param name defines the name to search for
  96714. * @return the found transform node or null if not found at all.
  96715. */
  96716. getTransformNodeByName(name: string): Nullable<TransformNode>;
  96717. /**
  96718. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  96719. * @param id defines the id to search for
  96720. * @return the found skeleton or null if not found at all.
  96721. */
  96722. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  96723. /**
  96724. * Gets a skeleton using a given auto generated unique id
  96725. * @param uniqueId defines the unique id to search for
  96726. * @return the found skeleton or null if not found at all.
  96727. */
  96728. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  96729. /**
  96730. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  96731. * @param id defines the id to search for
  96732. * @return the found skeleton or null if not found at all.
  96733. */
  96734. getSkeletonById(id: string): Nullable<Skeleton>;
  96735. /**
  96736. * Gets a skeleton using a given name
  96737. * @param name defines the name to search for
  96738. * @return the found skeleton or null if not found at all.
  96739. */
  96740. getSkeletonByName(name: string): Nullable<Skeleton>;
  96741. /**
  96742. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  96743. * @param id defines the id to search for
  96744. * @return the found morph target manager or null if not found at all.
  96745. */
  96746. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  96747. /**
  96748. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  96749. * @param id defines the id to search for
  96750. * @return the found morph target or null if not found at all.
  96751. */
  96752. getMorphTargetById(id: string): Nullable<MorphTarget>;
  96753. /**
  96754. * Gets a boolean indicating if the given mesh is active
  96755. * @param mesh defines the mesh to look for
  96756. * @returns true if the mesh is in the active list
  96757. */
  96758. isActiveMesh(mesh: AbstractMesh): boolean;
  96759. /**
  96760. * Return a unique id as a string which can serve as an identifier for the scene
  96761. */
  96762. readonly uid: string;
  96763. /**
  96764. * Add an externaly attached data from its key.
  96765. * This method call will fail and return false, if such key already exists.
  96766. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96767. * @param key the unique key that identifies the data
  96768. * @param data the data object to associate to the key for this Engine instance
  96769. * @return true if no such key were already present and the data was added successfully, false otherwise
  96770. */
  96771. addExternalData<T>(key: string, data: T): boolean;
  96772. /**
  96773. * Get an externaly attached data from its key
  96774. * @param key the unique key that identifies the data
  96775. * @return the associated data, if present (can be null), or undefined if not present
  96776. */
  96777. getExternalData<T>(key: string): Nullable<T>;
  96778. /**
  96779. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96780. * @param key the unique key that identifies the data
  96781. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96782. * @return the associated data, can be null if the factory returned null.
  96783. */
  96784. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96785. /**
  96786. * Remove an externaly attached data from the Engine instance
  96787. * @param key the unique key that identifies the data
  96788. * @return true if the data was successfully removed, false if it doesn't exist
  96789. */
  96790. removeExternalData(key: string): boolean;
  96791. private _evaluateSubMesh;
  96792. /**
  96793. * Clear the processed materials smart array preventing retention point in material dispose.
  96794. */
  96795. freeProcessedMaterials(): void;
  96796. private _preventFreeActiveMeshesAndRenderingGroups;
  96797. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96798. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96799. * when disposing several meshes in a row or a hierarchy of meshes.
  96800. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96801. */
  96802. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96803. /**
  96804. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96805. */
  96806. freeActiveMeshes(): void;
  96807. /**
  96808. * Clear the info related to rendering groups preventing retention points during dispose.
  96809. */
  96810. freeRenderingGroups(): void;
  96811. /** @hidden */
  96812. _isInIntermediateRendering(): boolean;
  96813. /**
  96814. * Lambda returning the list of potentially active meshes.
  96815. */
  96816. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96817. /**
  96818. * Lambda returning the list of potentially active sub meshes.
  96819. */
  96820. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96821. /**
  96822. * Lambda returning the list of potentially intersecting sub meshes.
  96823. */
  96824. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96825. /**
  96826. * Lambda returning the list of potentially colliding sub meshes.
  96827. */
  96828. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96829. private _activeMeshesFrozen;
  96830. /**
  96831. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96832. * @returns the current scene
  96833. */
  96834. freezeActiveMeshes(): Scene;
  96835. /**
  96836. * Use this function to restart evaluating active meshes on every frame
  96837. * @returns the current scene
  96838. */
  96839. unfreezeActiveMeshes(): Scene;
  96840. private _evaluateActiveMeshes;
  96841. private _activeMesh;
  96842. /**
  96843. * Update the transform matrix to update from the current active camera
  96844. * @param force defines a boolean used to force the update even if cache is up to date
  96845. */
  96846. updateTransformMatrix(force?: boolean): void;
  96847. private _bindFrameBuffer;
  96848. /** @hidden */
  96849. _allowPostProcessClearColor: boolean;
  96850. /** @hidden */
  96851. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96852. private _processSubCameras;
  96853. private _checkIntersections;
  96854. /** @hidden */
  96855. _advancePhysicsEngineStep(step: number): void;
  96856. /**
  96857. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96858. */
  96859. getDeterministicFrameTime: () => number;
  96860. /** @hidden */
  96861. _animate(): void;
  96862. /** Execute all animations (for a frame) */
  96863. animate(): void;
  96864. /**
  96865. * Render the scene
  96866. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96867. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96868. */
  96869. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96870. /**
  96871. * Freeze all materials
  96872. * A frozen material will not be updatable but should be faster to render
  96873. */
  96874. freezeMaterials(): void;
  96875. /**
  96876. * Unfreeze all materials
  96877. * A frozen material will not be updatable but should be faster to render
  96878. */
  96879. unfreezeMaterials(): void;
  96880. /**
  96881. * Releases all held ressources
  96882. */
  96883. dispose(): void;
  96884. /**
  96885. * Gets if the scene is already disposed
  96886. */
  96887. readonly isDisposed: boolean;
  96888. /**
  96889. * Call this function to reduce memory footprint of the scene.
  96890. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96891. */
  96892. clearCachedVertexData(): void;
  96893. /**
  96894. * This function will remove the local cached buffer data from texture.
  96895. * It will save memory but will prevent the texture from being rebuilt
  96896. */
  96897. cleanCachedTextureBuffer(): void;
  96898. /**
  96899. * Get the world extend vectors with an optional filter
  96900. *
  96901. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96902. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96903. */
  96904. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96905. min: Vector3;
  96906. max: Vector3;
  96907. };
  96908. /**
  96909. * Creates a ray that can be used to pick in the scene
  96910. * @param x defines the x coordinate of the origin (on-screen)
  96911. * @param y defines the y coordinate of the origin (on-screen)
  96912. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96913. * @param camera defines the camera to use for the picking
  96914. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96915. * @returns a Ray
  96916. */
  96917. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96918. /**
  96919. * Creates a ray that can be used to pick in the scene
  96920. * @param x defines the x coordinate of the origin (on-screen)
  96921. * @param y defines the y coordinate of the origin (on-screen)
  96922. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96923. * @param result defines the ray where to store the picking ray
  96924. * @param camera defines the camera to use for the picking
  96925. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96926. * @returns the current scene
  96927. */
  96928. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96929. /**
  96930. * Creates a ray that can be used to pick in the scene
  96931. * @param x defines the x coordinate of the origin (on-screen)
  96932. * @param y defines the y coordinate of the origin (on-screen)
  96933. * @param camera defines the camera to use for the picking
  96934. * @returns a Ray
  96935. */
  96936. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96937. /**
  96938. * Creates a ray that can be used to pick in the scene
  96939. * @param x defines the x coordinate of the origin (on-screen)
  96940. * @param y defines the y coordinate of the origin (on-screen)
  96941. * @param result defines the ray where to store the picking ray
  96942. * @param camera defines the camera to use for the picking
  96943. * @returns the current scene
  96944. */
  96945. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96946. /** Launch a ray to try to pick a mesh in the scene
  96947. * @param x position on screen
  96948. * @param y position on screen
  96949. * @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
  96950. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96951. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96952. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96953. * @returns a PickingInfo
  96954. */
  96955. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96956. /** Use the given ray to pick a mesh in the scene
  96957. * @param ray The ray to use to pick meshes
  96958. * @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
  96959. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96960. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96961. * @returns a PickingInfo
  96962. */
  96963. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96964. /**
  96965. * Launch a ray to try to pick a mesh in the scene
  96966. * @param x X position on screen
  96967. * @param y Y position on screen
  96968. * @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
  96969. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96970. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96971. * @returns an array of PickingInfo
  96972. */
  96973. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96974. /**
  96975. * Launch a ray to try to pick a mesh in the scene
  96976. * @param ray Ray to use
  96977. * @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
  96978. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96979. * @returns an array of PickingInfo
  96980. */
  96981. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96982. /**
  96983. * Force the value of meshUnderPointer
  96984. * @param mesh defines the mesh to use
  96985. */
  96986. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96987. /**
  96988. * Gets the mesh under the pointer
  96989. * @returns a Mesh or null if no mesh is under the pointer
  96990. */
  96991. getPointerOverMesh(): Nullable<AbstractMesh>;
  96992. /** @hidden */
  96993. _rebuildGeometries(): void;
  96994. /** @hidden */
  96995. _rebuildTextures(): void;
  96996. private _getByTags;
  96997. /**
  96998. * Get a list of meshes by tags
  96999. * @param tagsQuery defines the tags query to use
  97000. * @param forEach defines a predicate used to filter results
  97001. * @returns an array of Mesh
  97002. */
  97003. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  97004. /**
  97005. * Get a list of cameras by tags
  97006. * @param tagsQuery defines the tags query to use
  97007. * @param forEach defines a predicate used to filter results
  97008. * @returns an array of Camera
  97009. */
  97010. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  97011. /**
  97012. * Get a list of lights by tags
  97013. * @param tagsQuery defines the tags query to use
  97014. * @param forEach defines a predicate used to filter results
  97015. * @returns an array of Light
  97016. */
  97017. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  97018. /**
  97019. * Get a list of materials by tags
  97020. * @param tagsQuery defines the tags query to use
  97021. * @param forEach defines a predicate used to filter results
  97022. * @returns an array of Material
  97023. */
  97024. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  97025. /**
  97026. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97027. * This allowed control for front to back rendering or reversly depending of the special needs.
  97028. *
  97029. * @param renderingGroupId The rendering group id corresponding to its index
  97030. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97031. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97032. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97033. */
  97034. 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;
  97035. /**
  97036. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97037. *
  97038. * @param renderingGroupId The rendering group id corresponding to its index
  97039. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97040. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97041. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97042. */
  97043. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97044. /**
  97045. * Gets the current auto clear configuration for one rendering group of the rendering
  97046. * manager.
  97047. * @param index the rendering group index to get the information for
  97048. * @returns The auto clear setup for the requested rendering group
  97049. */
  97050. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97051. private _blockMaterialDirtyMechanism;
  97052. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  97053. blockMaterialDirtyMechanism: boolean;
  97054. /**
  97055. * Will flag all materials as dirty to trigger new shader compilation
  97056. * @param flag defines the flag used to specify which material part must be marked as dirty
  97057. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  97058. */
  97059. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97060. /** @hidden */
  97061. _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;
  97062. /** @hidden */
  97063. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97064. }
  97065. }
  97066. declare module BABYLON {
  97067. /**
  97068. * Set of assets to keep when moving a scene into an asset container.
  97069. */
  97070. export class KeepAssets extends AbstractScene {
  97071. }
  97072. /**
  97073. * Container with a set of assets that can be added or removed from a scene.
  97074. */
  97075. export class AssetContainer extends AbstractScene {
  97076. /**
  97077. * The scene the AssetContainer belongs to.
  97078. */
  97079. scene: Scene;
  97080. /**
  97081. * Instantiates an AssetContainer.
  97082. * @param scene The scene the AssetContainer belongs to.
  97083. */
  97084. constructor(scene: Scene);
  97085. /**
  97086. * Adds all the assets from the container to the scene.
  97087. */
  97088. addAllToScene(): void;
  97089. /**
  97090. * Removes all the assets in the container from the scene
  97091. */
  97092. removeAllFromScene(): void;
  97093. /**
  97094. * Disposes all the assets in the container
  97095. */
  97096. dispose(): void;
  97097. private _moveAssets;
  97098. /**
  97099. * Removes all the assets contained in the scene and adds them to the container.
  97100. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  97101. */
  97102. moveAllFromScene(keepAssets?: KeepAssets): void;
  97103. /**
  97104. * 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.
  97105. * @returns the root mesh
  97106. */
  97107. createRootMesh(): Mesh;
  97108. }
  97109. }
  97110. declare module BABYLON {
  97111. /**
  97112. * Defines how the parser contract is defined.
  97113. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  97114. */
  97115. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  97116. /**
  97117. * Defines how the individual parser contract is defined.
  97118. * These parser can parse an individual asset
  97119. */
  97120. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  97121. /**
  97122. * Base class of the scene acting as a container for the different elements composing a scene.
  97123. * This class is dynamically extended by the different components of the scene increasing
  97124. * flexibility and reducing coupling
  97125. */
  97126. export abstract class AbstractScene {
  97127. /**
  97128. * Stores the list of available parsers in the application.
  97129. */
  97130. private static _BabylonFileParsers;
  97131. /**
  97132. * Stores the list of available individual parsers in the application.
  97133. */
  97134. private static _IndividualBabylonFileParsers;
  97135. /**
  97136. * Adds a parser in the list of available ones
  97137. * @param name Defines the name of the parser
  97138. * @param parser Defines the parser to add
  97139. */
  97140. static AddParser(name: string, parser: BabylonFileParser): void;
  97141. /**
  97142. * Gets a general parser from the list of avaialble ones
  97143. * @param name Defines the name of the parser
  97144. * @returns the requested parser or null
  97145. */
  97146. static GetParser(name: string): Nullable<BabylonFileParser>;
  97147. /**
  97148. * Adds n individual parser in the list of available ones
  97149. * @param name Defines the name of the parser
  97150. * @param parser Defines the parser to add
  97151. */
  97152. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  97153. /**
  97154. * Gets an individual parser from the list of avaialble ones
  97155. * @param name Defines the name of the parser
  97156. * @returns the requested parser or null
  97157. */
  97158. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  97159. /**
  97160. * Parser json data and populate both a scene and its associated container object
  97161. * @param jsonData Defines the data to parse
  97162. * @param scene Defines the scene to parse the data for
  97163. * @param container Defines the container attached to the parsing sequence
  97164. * @param rootUrl Defines the root url of the data
  97165. */
  97166. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  97167. /**
  97168. * Gets the list of root nodes (ie. nodes with no parent)
  97169. */
  97170. rootNodes: Node[];
  97171. /** All of the cameras added to this scene
  97172. * @see http://doc.babylonjs.com/babylon101/cameras
  97173. */
  97174. cameras: Camera[];
  97175. /**
  97176. * All of the lights added to this scene
  97177. * @see http://doc.babylonjs.com/babylon101/lights
  97178. */
  97179. lights: Light[];
  97180. /**
  97181. * All of the (abstract) meshes added to this scene
  97182. */
  97183. meshes: AbstractMesh[];
  97184. /**
  97185. * The list of skeletons added to the scene
  97186. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  97187. */
  97188. skeletons: Skeleton[];
  97189. /**
  97190. * All of the particle systems added to this scene
  97191. * @see http://doc.babylonjs.com/babylon101/particles
  97192. */
  97193. particleSystems: IParticleSystem[];
  97194. /**
  97195. * Gets a list of Animations associated with the scene
  97196. */
  97197. animations: Animation[];
  97198. /**
  97199. * All of the animation groups added to this scene
  97200. * @see http://doc.babylonjs.com/how_to/group
  97201. */
  97202. animationGroups: AnimationGroup[];
  97203. /**
  97204. * All of the multi-materials added to this scene
  97205. * @see http://doc.babylonjs.com/how_to/multi_materials
  97206. */
  97207. multiMaterials: MultiMaterial[];
  97208. /**
  97209. * All of the materials added to this scene
  97210. * In the context of a Scene, it is not supposed to be modified manually.
  97211. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  97212. * Note also that the order of the Material wihin the array is not significant and might change.
  97213. * @see http://doc.babylonjs.com/babylon101/materials
  97214. */
  97215. materials: Material[];
  97216. /**
  97217. * The list of morph target managers added to the scene
  97218. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  97219. */
  97220. morphTargetManagers: MorphTargetManager[];
  97221. /**
  97222. * The list of geometries used in the scene.
  97223. */
  97224. geometries: Geometry[];
  97225. /**
  97226. * All of the tranform nodes added to this scene
  97227. * In the context of a Scene, it is not supposed to be modified manually.
  97228. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  97229. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  97230. * @see http://doc.babylonjs.com/how_to/transformnode
  97231. */
  97232. transformNodes: TransformNode[];
  97233. /**
  97234. * ActionManagers available on the scene.
  97235. */
  97236. actionManagers: AbstractActionManager[];
  97237. /**
  97238. * Textures to keep.
  97239. */
  97240. textures: BaseTexture[];
  97241. /**
  97242. * Environment texture for the scene
  97243. */
  97244. environmentTexture: Nullable<BaseTexture>;
  97245. }
  97246. }
  97247. declare module BABYLON {
  97248. /**
  97249. * Interface used to define options for Sound class
  97250. */
  97251. export interface ISoundOptions {
  97252. /**
  97253. * Does the sound autoplay once loaded.
  97254. */
  97255. autoplay?: boolean;
  97256. /**
  97257. * Does the sound loop after it finishes playing once.
  97258. */
  97259. loop?: boolean;
  97260. /**
  97261. * Sound's volume
  97262. */
  97263. volume?: number;
  97264. /**
  97265. * Is it a spatial sound?
  97266. */
  97267. spatialSound?: boolean;
  97268. /**
  97269. * Maximum distance to hear that sound
  97270. */
  97271. maxDistance?: number;
  97272. /**
  97273. * Uses user defined attenuation function
  97274. */
  97275. useCustomAttenuation?: boolean;
  97276. /**
  97277. * Define the roll off factor of spatial sounds.
  97278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97279. */
  97280. rolloffFactor?: number;
  97281. /**
  97282. * Define the reference distance the sound should be heard perfectly.
  97283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97284. */
  97285. refDistance?: number;
  97286. /**
  97287. * Define the distance attenuation model the sound will follow.
  97288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97289. */
  97290. distanceModel?: string;
  97291. /**
  97292. * Defines the playback speed (1 by default)
  97293. */
  97294. playbackRate?: number;
  97295. /**
  97296. * Defines if the sound is from a streaming source
  97297. */
  97298. streaming?: boolean;
  97299. /**
  97300. * Defines an optional length (in seconds) inside the sound file
  97301. */
  97302. length?: number;
  97303. /**
  97304. * Defines an optional offset (in seconds) inside the sound file
  97305. */
  97306. offset?: number;
  97307. /**
  97308. * If true, URLs will not be required to state the audio file codec to use.
  97309. */
  97310. skipCodecCheck?: boolean;
  97311. }
  97312. /**
  97313. * Defines a sound that can be played in the application.
  97314. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  97315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97316. */
  97317. export class Sound {
  97318. /**
  97319. * The name of the sound in the scene.
  97320. */
  97321. name: string;
  97322. /**
  97323. * Does the sound autoplay once loaded.
  97324. */
  97325. autoplay: boolean;
  97326. /**
  97327. * Does the sound loop after it finishes playing once.
  97328. */
  97329. loop: boolean;
  97330. /**
  97331. * Does the sound use a custom attenuation curve to simulate the falloff
  97332. * happening when the source gets further away from the camera.
  97333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97334. */
  97335. useCustomAttenuation: boolean;
  97336. /**
  97337. * The sound track id this sound belongs to.
  97338. */
  97339. soundTrackId: number;
  97340. /**
  97341. * Is this sound currently played.
  97342. */
  97343. isPlaying: boolean;
  97344. /**
  97345. * Is this sound currently paused.
  97346. */
  97347. isPaused: boolean;
  97348. /**
  97349. * Does this sound enables spatial sound.
  97350. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97351. */
  97352. spatialSound: boolean;
  97353. /**
  97354. * Define the reference distance the sound should be heard perfectly.
  97355. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97356. */
  97357. refDistance: number;
  97358. /**
  97359. * Define the roll off factor of spatial sounds.
  97360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97361. */
  97362. rolloffFactor: number;
  97363. /**
  97364. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  97365. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97366. */
  97367. maxDistance: number;
  97368. /**
  97369. * Define the distance attenuation model the sound will follow.
  97370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97371. */
  97372. distanceModel: string;
  97373. /**
  97374. * @hidden
  97375. * Back Compat
  97376. **/
  97377. onended: () => any;
  97378. /**
  97379. * Observable event when the current playing sound finishes.
  97380. */
  97381. onEndedObservable: Observable<Sound>;
  97382. private _panningModel;
  97383. private _playbackRate;
  97384. private _streaming;
  97385. private _startTime;
  97386. private _startOffset;
  97387. private _position;
  97388. /** @hidden */
  97389. _positionInEmitterSpace: boolean;
  97390. private _localDirection;
  97391. private _volume;
  97392. private _isReadyToPlay;
  97393. private _isDirectional;
  97394. private _readyToPlayCallback;
  97395. private _audioBuffer;
  97396. private _soundSource;
  97397. private _streamingSource;
  97398. private _soundPanner;
  97399. private _soundGain;
  97400. private _inputAudioNode;
  97401. private _outputAudioNode;
  97402. private _coneInnerAngle;
  97403. private _coneOuterAngle;
  97404. private _coneOuterGain;
  97405. private _scene;
  97406. private _connectedTransformNode;
  97407. private _customAttenuationFunction;
  97408. private _registerFunc;
  97409. private _isOutputConnected;
  97410. private _htmlAudioElement;
  97411. private _urlType;
  97412. private _length?;
  97413. private _offset?;
  97414. /** @hidden */
  97415. static _SceneComponentInitialization: (scene: Scene) => void;
  97416. /**
  97417. * Create a sound and attach it to a scene
  97418. * @param name Name of your sound
  97419. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  97420. * @param scene defines the scene the sound belongs to
  97421. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  97422. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  97423. */
  97424. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  97425. /**
  97426. * Release the sound and its associated resources
  97427. */
  97428. dispose(): void;
  97429. /**
  97430. * Gets if the sounds is ready to be played or not.
  97431. * @returns true if ready, otherwise false
  97432. */
  97433. isReady(): boolean;
  97434. private _soundLoaded;
  97435. /**
  97436. * Sets the data of the sound from an audiobuffer
  97437. * @param audioBuffer The audioBuffer containing the data
  97438. */
  97439. setAudioBuffer(audioBuffer: AudioBuffer): void;
  97440. /**
  97441. * Updates the current sounds options such as maxdistance, loop...
  97442. * @param options A JSON object containing values named as the object properties
  97443. */
  97444. updateOptions(options: ISoundOptions): void;
  97445. private _createSpatialParameters;
  97446. private _updateSpatialParameters;
  97447. /**
  97448. * Switch the panning model to HRTF:
  97449. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97451. */
  97452. switchPanningModelToHRTF(): void;
  97453. /**
  97454. * Switch the panning model to Equal Power:
  97455. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97457. */
  97458. switchPanningModelToEqualPower(): void;
  97459. private _switchPanningModel;
  97460. /**
  97461. * Connect this sound to a sound track audio node like gain...
  97462. * @param soundTrackAudioNode the sound track audio node to connect to
  97463. */
  97464. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  97465. /**
  97466. * Transform this sound into a directional source
  97467. * @param coneInnerAngle Size of the inner cone in degree
  97468. * @param coneOuterAngle Size of the outer cone in degree
  97469. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  97470. */
  97471. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  97472. /**
  97473. * Gets or sets the inner angle for the directional cone.
  97474. */
  97475. /**
  97476. * Gets or sets the inner angle for the directional cone.
  97477. */
  97478. directionalConeInnerAngle: number;
  97479. /**
  97480. * Gets or sets the outer angle for the directional cone.
  97481. */
  97482. /**
  97483. * Gets or sets the outer angle for the directional cone.
  97484. */
  97485. directionalConeOuterAngle: number;
  97486. /**
  97487. * Sets the position of the emitter if spatial sound is enabled
  97488. * @param newPosition Defines the new posisiton
  97489. */
  97490. setPosition(newPosition: Vector3): void;
  97491. /**
  97492. * Sets the local direction of the emitter if spatial sound is enabled
  97493. * @param newLocalDirection Defines the new local direction
  97494. */
  97495. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  97496. private _updateDirection;
  97497. /** @hidden */
  97498. updateDistanceFromListener(): void;
  97499. /**
  97500. * Sets a new custom attenuation function for the sound.
  97501. * @param callback Defines the function used for the attenuation
  97502. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97503. */
  97504. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  97505. /**
  97506. * Play the sound
  97507. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  97508. * @param offset (optional) Start the sound at a specific time in seconds
  97509. * @param length (optional) Sound duration (in seconds)
  97510. */
  97511. play(time?: number, offset?: number, length?: number): void;
  97512. private _onended;
  97513. /**
  97514. * Stop the sound
  97515. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  97516. */
  97517. stop(time?: number): void;
  97518. /**
  97519. * Put the sound in pause
  97520. */
  97521. pause(): void;
  97522. /**
  97523. * Sets a dedicated volume for this sounds
  97524. * @param newVolume Define the new volume of the sound
  97525. * @param time Define time for gradual change to new volume
  97526. */
  97527. setVolume(newVolume: number, time?: number): void;
  97528. /**
  97529. * Set the sound play back rate
  97530. * @param newPlaybackRate Define the playback rate the sound should be played at
  97531. */
  97532. setPlaybackRate(newPlaybackRate: number): void;
  97533. /**
  97534. * Gets the volume of the sound.
  97535. * @returns the volume of the sound
  97536. */
  97537. getVolume(): number;
  97538. /**
  97539. * Attach the sound to a dedicated mesh
  97540. * @param transformNode The transform node to connect the sound with
  97541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97542. */
  97543. attachToMesh(transformNode: TransformNode): void;
  97544. /**
  97545. * Detach the sound from the previously attached mesh
  97546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97547. */
  97548. detachFromMesh(): void;
  97549. private _onRegisterAfterWorldMatrixUpdate;
  97550. /**
  97551. * Clone the current sound in the scene.
  97552. * @returns the new sound clone
  97553. */
  97554. clone(): Nullable<Sound>;
  97555. /**
  97556. * Gets the current underlying audio buffer containing the data
  97557. * @returns the audio buffer
  97558. */
  97559. getAudioBuffer(): Nullable<AudioBuffer>;
  97560. /**
  97561. * Serializes the Sound in a JSON representation
  97562. * @returns the JSON representation of the sound
  97563. */
  97564. serialize(): any;
  97565. /**
  97566. * Parse a JSON representation of a sound to innstantiate in a given scene
  97567. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  97568. * @param scene Define the scene the new parsed sound should be created in
  97569. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  97570. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  97571. * @returns the newly parsed sound
  97572. */
  97573. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  97574. }
  97575. }
  97576. declare module BABYLON {
  97577. /**
  97578. * This defines an action helpful to play a defined sound on a triggered action.
  97579. */
  97580. export class PlaySoundAction extends Action {
  97581. private _sound;
  97582. /**
  97583. * Instantiate the action
  97584. * @param triggerOptions defines the trigger options
  97585. * @param sound defines the sound to play
  97586. * @param condition defines the trigger related conditions
  97587. */
  97588. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97589. /** @hidden */
  97590. _prepare(): void;
  97591. /**
  97592. * Execute the action and play the sound.
  97593. */
  97594. execute(): void;
  97595. /**
  97596. * Serializes the actions and its related information.
  97597. * @param parent defines the object to serialize in
  97598. * @returns the serialized object
  97599. */
  97600. serialize(parent: any): any;
  97601. }
  97602. /**
  97603. * This defines an action helpful to stop a defined sound on a triggered action.
  97604. */
  97605. export class StopSoundAction extends Action {
  97606. private _sound;
  97607. /**
  97608. * Instantiate the action
  97609. * @param triggerOptions defines the trigger options
  97610. * @param sound defines the sound to stop
  97611. * @param condition defines the trigger related conditions
  97612. */
  97613. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97614. /** @hidden */
  97615. _prepare(): void;
  97616. /**
  97617. * Execute the action and stop the sound.
  97618. */
  97619. execute(): void;
  97620. /**
  97621. * Serializes the actions and its related information.
  97622. * @param parent defines the object to serialize in
  97623. * @returns the serialized object
  97624. */
  97625. serialize(parent: any): any;
  97626. }
  97627. }
  97628. declare module BABYLON {
  97629. /**
  97630. * This defines an action responsible to change the value of a property
  97631. * by interpolating between its current value and the newly set one once triggered.
  97632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97633. */
  97634. export class InterpolateValueAction extends Action {
  97635. /**
  97636. * Defines the path of the property where the value should be interpolated
  97637. */
  97638. propertyPath: string;
  97639. /**
  97640. * Defines the target value at the end of the interpolation.
  97641. */
  97642. value: any;
  97643. /**
  97644. * Defines the time it will take for the property to interpolate to the value.
  97645. */
  97646. duration: number;
  97647. /**
  97648. * Defines if the other scene animations should be stopped when the action has been triggered
  97649. */
  97650. stopOtherAnimations?: boolean;
  97651. /**
  97652. * Defines a callback raised once the interpolation animation has been done.
  97653. */
  97654. onInterpolationDone?: () => void;
  97655. /**
  97656. * Observable triggered once the interpolation animation has been done.
  97657. */
  97658. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  97659. private _target;
  97660. private _effectiveTarget;
  97661. private _property;
  97662. /**
  97663. * Instantiate the action
  97664. * @param triggerOptions defines the trigger options
  97665. * @param target defines the object containing the value to interpolate
  97666. * @param propertyPath defines the path to the property in the target object
  97667. * @param value defines the target value at the end of the interpolation
  97668. * @param duration deines the time it will take for the property to interpolate to the value.
  97669. * @param condition defines the trigger related conditions
  97670. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  97671. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  97672. */
  97673. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  97674. /** @hidden */
  97675. _prepare(): void;
  97676. /**
  97677. * Execute the action starts the value interpolation.
  97678. */
  97679. execute(): void;
  97680. /**
  97681. * Serializes the actions and its related information.
  97682. * @param parent defines the object to serialize in
  97683. * @returns the serialized object
  97684. */
  97685. serialize(parent: any): any;
  97686. }
  97687. }
  97688. declare module BABYLON {
  97689. /**
  97690. * Options allowed during the creation of a sound track.
  97691. */
  97692. export interface ISoundTrackOptions {
  97693. /**
  97694. * The volume the sound track should take during creation
  97695. */
  97696. volume?: number;
  97697. /**
  97698. * Define if the sound track is the main sound track of the scene
  97699. */
  97700. mainTrack?: boolean;
  97701. }
  97702. /**
  97703. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  97704. * It will be also used in a future release to apply effects on a specific track.
  97705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97706. */
  97707. export class SoundTrack {
  97708. /**
  97709. * The unique identifier of the sound track in the scene.
  97710. */
  97711. id: number;
  97712. /**
  97713. * The list of sounds included in the sound track.
  97714. */
  97715. soundCollection: Array<Sound>;
  97716. private _outputAudioNode;
  97717. private _scene;
  97718. private _isMainTrack;
  97719. private _connectedAnalyser;
  97720. private _options;
  97721. private _isInitialized;
  97722. /**
  97723. * Creates a new sound track.
  97724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97725. * @param scene Define the scene the sound track belongs to
  97726. * @param options
  97727. */
  97728. constructor(scene: Scene, options?: ISoundTrackOptions);
  97729. private _initializeSoundTrackAudioGraph;
  97730. /**
  97731. * Release the sound track and its associated resources
  97732. */
  97733. dispose(): void;
  97734. /**
  97735. * Adds a sound to this sound track
  97736. * @param sound define the cound to add
  97737. * @ignoreNaming
  97738. */
  97739. AddSound(sound: Sound): void;
  97740. /**
  97741. * Removes a sound to this sound track
  97742. * @param sound define the cound to remove
  97743. * @ignoreNaming
  97744. */
  97745. RemoveSound(sound: Sound): void;
  97746. /**
  97747. * Set a global volume for the full sound track.
  97748. * @param newVolume Define the new volume of the sound track
  97749. */
  97750. setVolume(newVolume: number): void;
  97751. /**
  97752. * Switch the panning model to HRTF:
  97753. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97755. */
  97756. switchPanningModelToHRTF(): void;
  97757. /**
  97758. * Switch the panning model to Equal Power:
  97759. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97761. */
  97762. switchPanningModelToEqualPower(): void;
  97763. /**
  97764. * Connect the sound track to an audio analyser allowing some amazing
  97765. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97767. * @param analyser The analyser to connect to the engine
  97768. */
  97769. connectToAnalyser(analyser: Analyser): void;
  97770. }
  97771. }
  97772. declare module BABYLON {
  97773. interface AbstractScene {
  97774. /**
  97775. * The list of sounds used in the scene.
  97776. */
  97777. sounds: Nullable<Array<Sound>>;
  97778. }
  97779. interface Scene {
  97780. /**
  97781. * @hidden
  97782. * Backing field
  97783. */
  97784. _mainSoundTrack: SoundTrack;
  97785. /**
  97786. * The main sound track played by the scene.
  97787. * It cotains your primary collection of sounds.
  97788. */
  97789. mainSoundTrack: SoundTrack;
  97790. /**
  97791. * The list of sound tracks added to the scene
  97792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97793. */
  97794. soundTracks: Nullable<Array<SoundTrack>>;
  97795. /**
  97796. * Gets a sound using a given name
  97797. * @param name defines the name to search for
  97798. * @return the found sound or null if not found at all.
  97799. */
  97800. getSoundByName(name: string): Nullable<Sound>;
  97801. /**
  97802. * Gets or sets if audio support is enabled
  97803. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97804. */
  97805. audioEnabled: boolean;
  97806. /**
  97807. * Gets or sets if audio will be output to headphones
  97808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97809. */
  97810. headphone: boolean;
  97811. }
  97812. /**
  97813. * Defines the sound scene component responsible to manage any sounds
  97814. * in a given scene.
  97815. */
  97816. export class AudioSceneComponent implements ISceneSerializableComponent {
  97817. /**
  97818. * The component name helpfull to identify the component in the list of scene components.
  97819. */
  97820. readonly name: string;
  97821. /**
  97822. * The scene the component belongs to.
  97823. */
  97824. scene: Scene;
  97825. private _audioEnabled;
  97826. /**
  97827. * Gets whether audio is enabled or not.
  97828. * Please use related enable/disable method to switch state.
  97829. */
  97830. readonly audioEnabled: boolean;
  97831. private _headphone;
  97832. /**
  97833. * Gets whether audio is outputing to headphone or not.
  97834. * Please use the according Switch methods to change output.
  97835. */
  97836. readonly headphone: boolean;
  97837. /**
  97838. * Creates a new instance of the component for the given scene
  97839. * @param scene Defines the scene to register the component in
  97840. */
  97841. constructor(scene: Scene);
  97842. /**
  97843. * Registers the component in a given scene
  97844. */
  97845. register(): void;
  97846. /**
  97847. * Rebuilds the elements related to this component in case of
  97848. * context lost for instance.
  97849. */
  97850. rebuild(): void;
  97851. /**
  97852. * Serializes the component data to the specified json object
  97853. * @param serializationObject The object to serialize to
  97854. */
  97855. serialize(serializationObject: any): void;
  97856. /**
  97857. * Adds all the elements from the container to the scene
  97858. * @param container the container holding the elements
  97859. */
  97860. addFromContainer(container: AbstractScene): void;
  97861. /**
  97862. * Removes all the elements in the container from the scene
  97863. * @param container contains the elements to remove
  97864. * @param dispose if the removed element should be disposed (default: false)
  97865. */
  97866. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97867. /**
  97868. * Disposes the component and the associated ressources.
  97869. */
  97870. dispose(): void;
  97871. /**
  97872. * Disables audio in the associated scene.
  97873. */
  97874. disableAudio(): void;
  97875. /**
  97876. * Enables audio in the associated scene.
  97877. */
  97878. enableAudio(): void;
  97879. /**
  97880. * Switch audio to headphone output.
  97881. */
  97882. switchAudioModeForHeadphones(): void;
  97883. /**
  97884. * Switch audio to normal speakers.
  97885. */
  97886. switchAudioModeForNormalSpeakers(): void;
  97887. private _afterRender;
  97888. }
  97889. }
  97890. declare module BABYLON {
  97891. /**
  97892. * Wraps one or more Sound objects and selects one with random weight for playback.
  97893. */
  97894. export class WeightedSound {
  97895. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97896. loop: boolean;
  97897. private _coneInnerAngle;
  97898. private _coneOuterAngle;
  97899. private _volume;
  97900. /** A Sound is currently playing. */
  97901. isPlaying: boolean;
  97902. /** A Sound is currently paused. */
  97903. isPaused: boolean;
  97904. private _sounds;
  97905. private _weights;
  97906. private _currentIndex?;
  97907. /**
  97908. * Creates a new WeightedSound from the list of sounds given.
  97909. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97910. * @param sounds Array of Sounds that will be selected from.
  97911. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97912. */
  97913. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97914. /**
  97915. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97916. */
  97917. /**
  97918. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97919. */
  97920. directionalConeInnerAngle: number;
  97921. /**
  97922. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97923. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97924. */
  97925. /**
  97926. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97927. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97928. */
  97929. directionalConeOuterAngle: number;
  97930. /**
  97931. * Playback volume.
  97932. */
  97933. /**
  97934. * Playback volume.
  97935. */
  97936. volume: number;
  97937. private _onended;
  97938. /**
  97939. * Suspend playback
  97940. */
  97941. pause(): void;
  97942. /**
  97943. * Stop playback
  97944. */
  97945. stop(): void;
  97946. /**
  97947. * Start playback.
  97948. * @param startOffset Position the clip head at a specific time in seconds.
  97949. */
  97950. play(startOffset?: number): void;
  97951. }
  97952. }
  97953. declare module BABYLON {
  97954. /**
  97955. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97956. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97957. */
  97958. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97959. /**
  97960. * Gets the name of the behavior.
  97961. */
  97962. readonly name: string;
  97963. /**
  97964. * The easing function used by animations
  97965. */
  97966. static EasingFunction: BackEase;
  97967. /**
  97968. * The easing mode used by animations
  97969. */
  97970. static EasingMode: number;
  97971. /**
  97972. * The duration of the animation, in milliseconds
  97973. */
  97974. transitionDuration: number;
  97975. /**
  97976. * Length of the distance animated by the transition when lower radius is reached
  97977. */
  97978. lowerRadiusTransitionRange: number;
  97979. /**
  97980. * Length of the distance animated by the transition when upper radius is reached
  97981. */
  97982. upperRadiusTransitionRange: number;
  97983. private _autoTransitionRange;
  97984. /**
  97985. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97986. */
  97987. /**
  97988. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97989. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97990. */
  97991. autoTransitionRange: boolean;
  97992. private _attachedCamera;
  97993. private _onAfterCheckInputsObserver;
  97994. private _onMeshTargetChangedObserver;
  97995. /**
  97996. * Initializes the behavior.
  97997. */
  97998. init(): void;
  97999. /**
  98000. * Attaches the behavior to its arc rotate camera.
  98001. * @param camera Defines the camera to attach the behavior to
  98002. */
  98003. attach(camera: ArcRotateCamera): void;
  98004. /**
  98005. * Detaches the behavior from its current arc rotate camera.
  98006. */
  98007. detach(): void;
  98008. private _radiusIsAnimating;
  98009. private _radiusBounceTransition;
  98010. private _animatables;
  98011. private _cachedWheelPrecision;
  98012. /**
  98013. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  98014. * @param radiusLimit The limit to check against.
  98015. * @return Bool to indicate if at limit.
  98016. */
  98017. private _isRadiusAtLimit;
  98018. /**
  98019. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  98020. * @param radiusDelta The delta by which to animate to. Can be negative.
  98021. */
  98022. private _applyBoundRadiusAnimation;
  98023. /**
  98024. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  98025. */
  98026. protected _clearAnimationLocks(): void;
  98027. /**
  98028. * Stops and removes all animations that have been applied to the camera
  98029. */
  98030. stopAllAnimations(): void;
  98031. }
  98032. }
  98033. declare module BABYLON {
  98034. /**
  98035. * 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.
  98036. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98037. */
  98038. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  98039. /**
  98040. * Gets the name of the behavior.
  98041. */
  98042. readonly name: string;
  98043. private _mode;
  98044. private _radiusScale;
  98045. private _positionScale;
  98046. private _defaultElevation;
  98047. private _elevationReturnTime;
  98048. private _elevationReturnWaitTime;
  98049. private _zoomStopsAnimation;
  98050. private _framingTime;
  98051. /**
  98052. * The easing function used by animations
  98053. */
  98054. static EasingFunction: ExponentialEase;
  98055. /**
  98056. * The easing mode used by animations
  98057. */
  98058. static EasingMode: number;
  98059. /**
  98060. * Sets the current mode used by the behavior
  98061. */
  98062. /**
  98063. * Gets current mode used by the behavior.
  98064. */
  98065. mode: number;
  98066. /**
  98067. * Sets the scale applied to the radius (1 by default)
  98068. */
  98069. /**
  98070. * Gets the scale applied to the radius
  98071. */
  98072. radiusScale: number;
  98073. /**
  98074. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  98075. */
  98076. /**
  98077. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  98078. */
  98079. positionScale: number;
  98080. /**
  98081. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  98082. * behaviour is triggered, in radians.
  98083. */
  98084. /**
  98085. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  98086. * behaviour is triggered, in radians.
  98087. */
  98088. defaultElevation: number;
  98089. /**
  98090. * Sets the time (in milliseconds) taken to return to the default beta position.
  98091. * Negative value indicates camera should not return to default.
  98092. */
  98093. /**
  98094. * Gets the time (in milliseconds) taken to return to the default beta position.
  98095. * Negative value indicates camera should not return to default.
  98096. */
  98097. elevationReturnTime: number;
  98098. /**
  98099. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  98100. */
  98101. /**
  98102. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  98103. */
  98104. elevationReturnWaitTime: number;
  98105. /**
  98106. * Sets the flag that indicates if user zooming should stop animation.
  98107. */
  98108. /**
  98109. * Gets the flag that indicates if user zooming should stop animation.
  98110. */
  98111. zoomStopsAnimation: boolean;
  98112. /**
  98113. * Sets the transition time when framing the mesh, in milliseconds
  98114. */
  98115. /**
  98116. * Gets the transition time when framing the mesh, in milliseconds
  98117. */
  98118. framingTime: number;
  98119. /**
  98120. * Define if the behavior should automatically change the configured
  98121. * camera limits and sensibilities.
  98122. */
  98123. autoCorrectCameraLimitsAndSensibility: boolean;
  98124. private _onPrePointerObservableObserver;
  98125. private _onAfterCheckInputsObserver;
  98126. private _onMeshTargetChangedObserver;
  98127. private _attachedCamera;
  98128. private _isPointerDown;
  98129. private _lastInteractionTime;
  98130. /**
  98131. * Initializes the behavior.
  98132. */
  98133. init(): void;
  98134. /**
  98135. * Attaches the behavior to its arc rotate camera.
  98136. * @param camera Defines the camera to attach the behavior to
  98137. */
  98138. attach(camera: ArcRotateCamera): void;
  98139. /**
  98140. * Detaches the behavior from its current arc rotate camera.
  98141. */
  98142. detach(): void;
  98143. private _animatables;
  98144. private _betaIsAnimating;
  98145. private _betaTransition;
  98146. private _radiusTransition;
  98147. private _vectorTransition;
  98148. /**
  98149. * Targets the given mesh and updates zoom level accordingly.
  98150. * @param mesh The mesh to target.
  98151. * @param radius Optional. If a cached radius position already exists, overrides default.
  98152. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98153. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98154. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98155. */
  98156. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98157. /**
  98158. * Targets the given mesh with its children and updates zoom level accordingly.
  98159. * @param mesh The mesh to target.
  98160. * @param radius Optional. If a cached radius position already exists, overrides default.
  98161. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98162. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98163. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98164. */
  98165. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98166. /**
  98167. * Targets the given meshes with their children and updates zoom level accordingly.
  98168. * @param meshes The mesh to target.
  98169. * @param radius Optional. If a cached radius position already exists, overrides default.
  98170. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98171. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98172. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98173. */
  98174. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98175. /**
  98176. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  98177. * @param minimumWorld Determines the smaller position of the bounding box extend
  98178. * @param maximumWorld Determines the bigger position of the bounding box extend
  98179. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98180. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98181. */
  98182. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98183. /**
  98184. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  98185. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  98186. * frustum width.
  98187. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  98188. * to fully enclose the mesh in the viewing frustum.
  98189. */
  98190. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  98191. /**
  98192. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  98193. * is automatically returned to its default position (expected to be above ground plane).
  98194. */
  98195. private _maintainCameraAboveGround;
  98196. /**
  98197. * Returns the frustum slope based on the canvas ratio and camera FOV
  98198. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  98199. */
  98200. private _getFrustumSlope;
  98201. /**
  98202. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  98203. */
  98204. private _clearAnimationLocks;
  98205. /**
  98206. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98207. */
  98208. private _applyUserInteraction;
  98209. /**
  98210. * Stops and removes all animations that have been applied to the camera
  98211. */
  98212. stopAllAnimations(): void;
  98213. /**
  98214. * Gets a value indicating if the user is moving the camera
  98215. */
  98216. readonly isUserIsMoving: boolean;
  98217. /**
  98218. * The camera can move all the way towards the mesh.
  98219. */
  98220. static IgnoreBoundsSizeMode: number;
  98221. /**
  98222. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  98223. */
  98224. static FitFrustumSidesMode: number;
  98225. }
  98226. }
  98227. declare module BABYLON {
  98228. /**
  98229. * Base class for Camera Pointer Inputs.
  98230. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  98231. * for example usage.
  98232. */
  98233. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  98234. /**
  98235. * Defines the camera the input is attached to.
  98236. */
  98237. abstract camera: Camera;
  98238. /**
  98239. * Whether keyboard modifier keys are pressed at time of last mouse event.
  98240. */
  98241. protected _altKey: boolean;
  98242. protected _ctrlKey: boolean;
  98243. protected _metaKey: boolean;
  98244. protected _shiftKey: boolean;
  98245. /**
  98246. * Which mouse buttons were pressed at time of last mouse event.
  98247. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  98248. */
  98249. protected _buttonsPressed: number;
  98250. /**
  98251. * Defines the buttons associated with the input to handle camera move.
  98252. */
  98253. buttons: number[];
  98254. /**
  98255. * Attach the input controls to a specific dom element to get the input from.
  98256. * @param element Defines the element the controls should be listened from
  98257. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98258. */
  98259. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98260. /**
  98261. * Detach the current controls from the specified dom element.
  98262. * @param element Defines the element to stop listening the inputs from
  98263. */
  98264. detachControl(element: Nullable<HTMLElement>): void;
  98265. /**
  98266. * Gets the class name of the current input.
  98267. * @returns the class name
  98268. */
  98269. getClassName(): string;
  98270. /**
  98271. * Get the friendly name associated with the input class.
  98272. * @returns the input friendly name
  98273. */
  98274. getSimpleName(): string;
  98275. /**
  98276. * Called on pointer POINTERDOUBLETAP event.
  98277. * Override this method to provide functionality on POINTERDOUBLETAP event.
  98278. */
  98279. protected onDoubleTap(type: string): void;
  98280. /**
  98281. * Called on pointer POINTERMOVE event if only a single touch is active.
  98282. * Override this method to provide functionality.
  98283. */
  98284. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98285. /**
  98286. * Called on pointer POINTERMOVE event if multiple touches are active.
  98287. * Override this method to provide functionality.
  98288. */
  98289. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98290. /**
  98291. * Called on JS contextmenu event.
  98292. * Override this method to provide functionality.
  98293. */
  98294. protected onContextMenu(evt: PointerEvent): void;
  98295. /**
  98296. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98297. * press.
  98298. * Override this method to provide functionality.
  98299. */
  98300. protected onButtonDown(evt: PointerEvent): void;
  98301. /**
  98302. * Called each time a new POINTERUP event occurs. Ie, for each button
  98303. * release.
  98304. * Override this method to provide functionality.
  98305. */
  98306. protected onButtonUp(evt: PointerEvent): void;
  98307. /**
  98308. * Called when window becomes inactive.
  98309. * Override this method to provide functionality.
  98310. */
  98311. protected onLostFocus(): void;
  98312. private _pointerInput;
  98313. private _observer;
  98314. private _onLostFocus;
  98315. private pointA;
  98316. private pointB;
  98317. }
  98318. }
  98319. declare module BABYLON {
  98320. /**
  98321. * Manage the pointers inputs to control an arc rotate camera.
  98322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98323. */
  98324. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  98325. /**
  98326. * Defines the camera the input is attached to.
  98327. */
  98328. camera: ArcRotateCamera;
  98329. /**
  98330. * Gets the class name of the current input.
  98331. * @returns the class name
  98332. */
  98333. getClassName(): string;
  98334. /**
  98335. * Defines the buttons associated with the input to handle camera move.
  98336. */
  98337. buttons: number[];
  98338. /**
  98339. * Defines the pointer angular sensibility along the X axis or how fast is
  98340. * the camera rotating.
  98341. */
  98342. angularSensibilityX: number;
  98343. /**
  98344. * Defines the pointer angular sensibility along the Y axis or how fast is
  98345. * the camera rotating.
  98346. */
  98347. angularSensibilityY: number;
  98348. /**
  98349. * Defines the pointer pinch precision or how fast is the camera zooming.
  98350. */
  98351. pinchPrecision: number;
  98352. /**
  98353. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  98354. * from 0.
  98355. * It defines the percentage of current camera.radius to use as delta when
  98356. * pinch zoom is used.
  98357. */
  98358. pinchDeltaPercentage: number;
  98359. /**
  98360. * Defines the pointer panning sensibility or how fast is the camera moving.
  98361. */
  98362. panningSensibility: number;
  98363. /**
  98364. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  98365. */
  98366. multiTouchPanning: boolean;
  98367. /**
  98368. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  98369. * zoom (pinch) through multitouch.
  98370. */
  98371. multiTouchPanAndZoom: boolean;
  98372. /**
  98373. * Revers pinch action direction.
  98374. */
  98375. pinchInwards: boolean;
  98376. private _isPanClick;
  98377. private _twoFingerActivityCount;
  98378. private _isPinching;
  98379. /**
  98380. * Called on pointer POINTERMOVE event if only a single touch is active.
  98381. */
  98382. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98383. /**
  98384. * Called on pointer POINTERDOUBLETAP event.
  98385. */
  98386. protected onDoubleTap(type: string): void;
  98387. /**
  98388. * Called on pointer POINTERMOVE event if multiple touches are active.
  98389. */
  98390. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98391. /**
  98392. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98393. * press.
  98394. */
  98395. protected onButtonDown(evt: PointerEvent): void;
  98396. /**
  98397. * Called each time a new POINTERUP event occurs. Ie, for each button
  98398. * release.
  98399. */
  98400. protected onButtonUp(evt: PointerEvent): void;
  98401. /**
  98402. * Called when window becomes inactive.
  98403. */
  98404. protected onLostFocus(): void;
  98405. }
  98406. }
  98407. declare module BABYLON {
  98408. /**
  98409. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  98410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98411. */
  98412. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  98413. /**
  98414. * Defines the camera the input is attached to.
  98415. */
  98416. camera: ArcRotateCamera;
  98417. /**
  98418. * Defines the list of key codes associated with the up action (increase alpha)
  98419. */
  98420. keysUp: number[];
  98421. /**
  98422. * Defines the list of key codes associated with the down action (decrease alpha)
  98423. */
  98424. keysDown: number[];
  98425. /**
  98426. * Defines the list of key codes associated with the left action (increase beta)
  98427. */
  98428. keysLeft: number[];
  98429. /**
  98430. * Defines the list of key codes associated with the right action (decrease beta)
  98431. */
  98432. keysRight: number[];
  98433. /**
  98434. * Defines the list of key codes associated with the reset action.
  98435. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  98436. */
  98437. keysReset: number[];
  98438. /**
  98439. * Defines the panning sensibility of the inputs.
  98440. * (How fast is the camera paning)
  98441. */
  98442. panningSensibility: number;
  98443. /**
  98444. * Defines the zooming sensibility of the inputs.
  98445. * (How fast is the camera zooming)
  98446. */
  98447. zoomingSensibility: number;
  98448. /**
  98449. * Defines wether maintaining the alt key down switch the movement mode from
  98450. * orientation to zoom.
  98451. */
  98452. useAltToZoom: boolean;
  98453. /**
  98454. * Rotation speed of the camera
  98455. */
  98456. angularSpeed: number;
  98457. private _keys;
  98458. private _ctrlPressed;
  98459. private _altPressed;
  98460. private _onCanvasBlurObserver;
  98461. private _onKeyboardObserver;
  98462. private _engine;
  98463. private _scene;
  98464. /**
  98465. * Attach the input controls to a specific dom element to get the input from.
  98466. * @param element Defines the element the controls should be listened from
  98467. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98468. */
  98469. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98470. /**
  98471. * Detach the current controls from the specified dom element.
  98472. * @param element Defines the element to stop listening the inputs from
  98473. */
  98474. detachControl(element: Nullable<HTMLElement>): void;
  98475. /**
  98476. * Update the current camera state depending on the inputs that have been used this frame.
  98477. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98478. */
  98479. checkInputs(): void;
  98480. /**
  98481. * Gets the class name of the current intput.
  98482. * @returns the class name
  98483. */
  98484. getClassName(): string;
  98485. /**
  98486. * Get the friendly name associated with the input class.
  98487. * @returns the input friendly name
  98488. */
  98489. getSimpleName(): string;
  98490. }
  98491. }
  98492. declare module BABYLON {
  98493. /**
  98494. * Manage the mouse wheel inputs to control an arc rotate camera.
  98495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98496. */
  98497. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  98498. /**
  98499. * Defines the camera the input is attached to.
  98500. */
  98501. camera: ArcRotateCamera;
  98502. /**
  98503. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98504. */
  98505. wheelPrecision: number;
  98506. /**
  98507. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  98508. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  98509. */
  98510. wheelDeltaPercentage: number;
  98511. private _wheel;
  98512. private _observer;
  98513. private computeDeltaFromMouseWheelLegacyEvent;
  98514. /**
  98515. * Attach the input controls to a specific dom element to get the input from.
  98516. * @param element Defines the element the controls should be listened from
  98517. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98518. */
  98519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98520. /**
  98521. * Detach the current controls from the specified dom element.
  98522. * @param element Defines the element to stop listening the inputs from
  98523. */
  98524. detachControl(element: Nullable<HTMLElement>): void;
  98525. /**
  98526. * Gets the class name of the current intput.
  98527. * @returns the class name
  98528. */
  98529. getClassName(): string;
  98530. /**
  98531. * Get the friendly name associated with the input class.
  98532. * @returns the input friendly name
  98533. */
  98534. getSimpleName(): string;
  98535. }
  98536. }
  98537. declare module BABYLON {
  98538. /**
  98539. * Default Inputs manager for the ArcRotateCamera.
  98540. * It groups all the default supported inputs for ease of use.
  98541. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98542. */
  98543. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  98544. /**
  98545. * Instantiates a new ArcRotateCameraInputsManager.
  98546. * @param camera Defines the camera the inputs belong to
  98547. */
  98548. constructor(camera: ArcRotateCamera);
  98549. /**
  98550. * Add mouse wheel input support to the input manager.
  98551. * @returns the current input manager
  98552. */
  98553. addMouseWheel(): ArcRotateCameraInputsManager;
  98554. /**
  98555. * Add pointers input support to the input manager.
  98556. * @returns the current input manager
  98557. */
  98558. addPointers(): ArcRotateCameraInputsManager;
  98559. /**
  98560. * Add keyboard input support to the input manager.
  98561. * @returns the current input manager
  98562. */
  98563. addKeyboard(): ArcRotateCameraInputsManager;
  98564. }
  98565. }
  98566. declare module BABYLON {
  98567. /**
  98568. * This represents an orbital type of camera.
  98569. *
  98570. * 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.
  98571. * 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.
  98572. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  98573. */
  98574. export class ArcRotateCamera extends TargetCamera {
  98575. /**
  98576. * Defines the rotation angle of the camera along the longitudinal axis.
  98577. */
  98578. alpha: number;
  98579. /**
  98580. * Defines the rotation angle of the camera along the latitudinal axis.
  98581. */
  98582. beta: number;
  98583. /**
  98584. * Defines the radius of the camera from it s target point.
  98585. */
  98586. radius: number;
  98587. protected _target: Vector3;
  98588. protected _targetHost: Nullable<AbstractMesh>;
  98589. /**
  98590. * Defines the target point of the camera.
  98591. * The camera looks towards it form the radius distance.
  98592. */
  98593. target: Vector3;
  98594. /**
  98595. * Define the current local position of the camera in the scene
  98596. */
  98597. position: Vector3;
  98598. protected _upVector: Vector3;
  98599. protected _upToYMatrix: Matrix;
  98600. protected _YToUpMatrix: Matrix;
  98601. /**
  98602. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  98603. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  98604. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  98605. */
  98606. upVector: Vector3;
  98607. /**
  98608. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  98609. */
  98610. setMatUp(): void;
  98611. /**
  98612. * Current inertia value on the longitudinal axis.
  98613. * The bigger this number the longer it will take for the camera to stop.
  98614. */
  98615. inertialAlphaOffset: number;
  98616. /**
  98617. * Current inertia value on the latitudinal axis.
  98618. * The bigger this number the longer it will take for the camera to stop.
  98619. */
  98620. inertialBetaOffset: number;
  98621. /**
  98622. * Current inertia value on the radius axis.
  98623. * The bigger this number the longer it will take for the camera to stop.
  98624. */
  98625. inertialRadiusOffset: number;
  98626. /**
  98627. * Minimum allowed angle on the longitudinal axis.
  98628. * This can help limiting how the Camera is able to move in the scene.
  98629. */
  98630. lowerAlphaLimit: Nullable<number>;
  98631. /**
  98632. * Maximum allowed angle on the longitudinal axis.
  98633. * This can help limiting how the Camera is able to move in the scene.
  98634. */
  98635. upperAlphaLimit: Nullable<number>;
  98636. /**
  98637. * Minimum allowed angle on the latitudinal axis.
  98638. * This can help limiting how the Camera is able to move in the scene.
  98639. */
  98640. lowerBetaLimit: number;
  98641. /**
  98642. * Maximum allowed angle on the latitudinal axis.
  98643. * This can help limiting how the Camera is able to move in the scene.
  98644. */
  98645. upperBetaLimit: number;
  98646. /**
  98647. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  98648. * This can help limiting how the Camera is able to move in the scene.
  98649. */
  98650. lowerRadiusLimit: Nullable<number>;
  98651. /**
  98652. * Maximum allowed distance of the camera to the target (The camera can not get further).
  98653. * This can help limiting how the Camera is able to move in the scene.
  98654. */
  98655. upperRadiusLimit: Nullable<number>;
  98656. /**
  98657. * Defines the current inertia value used during panning of the camera along the X axis.
  98658. */
  98659. inertialPanningX: number;
  98660. /**
  98661. * Defines the current inertia value used during panning of the camera along the Y axis.
  98662. */
  98663. inertialPanningY: number;
  98664. /**
  98665. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  98666. * Basically if your fingers moves away from more than this distance you will be considered
  98667. * in pinch mode.
  98668. */
  98669. pinchToPanMaxDistance: number;
  98670. /**
  98671. * Defines the maximum distance the camera can pan.
  98672. * This could help keeping the cammera always in your scene.
  98673. */
  98674. panningDistanceLimit: Nullable<number>;
  98675. /**
  98676. * Defines the target of the camera before paning.
  98677. */
  98678. panningOriginTarget: Vector3;
  98679. /**
  98680. * Defines the value of the inertia used during panning.
  98681. * 0 would mean stop inertia and one would mean no decelleration at all.
  98682. */
  98683. panningInertia: number;
  98684. /**
  98685. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  98686. */
  98687. angularSensibilityX: number;
  98688. /**
  98689. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  98690. */
  98691. angularSensibilityY: number;
  98692. /**
  98693. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  98694. */
  98695. pinchPrecision: number;
  98696. /**
  98697. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  98698. * It will be used instead of pinchDeltaPrecision if different from 0.
  98699. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98700. */
  98701. pinchDeltaPercentage: number;
  98702. /**
  98703. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  98704. */
  98705. panningSensibility: number;
  98706. /**
  98707. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  98708. */
  98709. keysUp: number[];
  98710. /**
  98711. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  98712. */
  98713. keysDown: number[];
  98714. /**
  98715. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  98716. */
  98717. keysLeft: number[];
  98718. /**
  98719. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  98720. */
  98721. keysRight: number[];
  98722. /**
  98723. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98724. */
  98725. wheelPrecision: number;
  98726. /**
  98727. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  98728. * It will be used instead of pinchDeltaPrecision if different from 0.
  98729. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98730. */
  98731. wheelDeltaPercentage: number;
  98732. /**
  98733. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  98734. */
  98735. zoomOnFactor: number;
  98736. /**
  98737. * Defines a screen offset for the camera position.
  98738. */
  98739. targetScreenOffset: Vector2;
  98740. /**
  98741. * Allows the camera to be completely reversed.
  98742. * If false the camera can not arrive upside down.
  98743. */
  98744. allowUpsideDown: boolean;
  98745. /**
  98746. * Define if double tap/click is used to restore the previously saved state of the camera.
  98747. */
  98748. useInputToRestoreState: boolean;
  98749. /** @hidden */
  98750. _viewMatrix: Matrix;
  98751. /** @hidden */
  98752. _useCtrlForPanning: boolean;
  98753. /** @hidden */
  98754. _panningMouseButton: number;
  98755. /**
  98756. * Defines the input associated to the camera.
  98757. */
  98758. inputs: ArcRotateCameraInputsManager;
  98759. /** @hidden */
  98760. _reset: () => void;
  98761. /**
  98762. * Defines the allowed panning axis.
  98763. */
  98764. panningAxis: Vector3;
  98765. protected _localDirection: Vector3;
  98766. protected _transformedDirection: Vector3;
  98767. private _bouncingBehavior;
  98768. /**
  98769. * Gets the bouncing behavior of the camera if it has been enabled.
  98770. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98771. */
  98772. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  98773. /**
  98774. * Defines if the bouncing behavior of the camera is enabled on the camera.
  98775. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98776. */
  98777. useBouncingBehavior: boolean;
  98778. private _framingBehavior;
  98779. /**
  98780. * Gets the framing behavior of the camera if it has been enabled.
  98781. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98782. */
  98783. readonly framingBehavior: Nullable<FramingBehavior>;
  98784. /**
  98785. * Defines if the framing behavior of the camera is enabled on the camera.
  98786. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98787. */
  98788. useFramingBehavior: boolean;
  98789. private _autoRotationBehavior;
  98790. /**
  98791. * Gets the auto rotation behavior of the camera if it has been enabled.
  98792. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98793. */
  98794. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  98795. /**
  98796. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  98797. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98798. */
  98799. useAutoRotationBehavior: boolean;
  98800. /**
  98801. * Observable triggered when the mesh target has been changed on the camera.
  98802. */
  98803. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  98804. /**
  98805. * Event raised when the camera is colliding with a mesh.
  98806. */
  98807. onCollide: (collidedMesh: AbstractMesh) => void;
  98808. /**
  98809. * Defines whether the camera should check collision with the objects oh the scene.
  98810. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  98811. */
  98812. checkCollisions: boolean;
  98813. /**
  98814. * Defines the collision radius of the camera.
  98815. * This simulates a sphere around the camera.
  98816. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98817. */
  98818. collisionRadius: Vector3;
  98819. protected _collider: Collider;
  98820. protected _previousPosition: Vector3;
  98821. protected _collisionVelocity: Vector3;
  98822. protected _newPosition: Vector3;
  98823. protected _previousAlpha: number;
  98824. protected _previousBeta: number;
  98825. protected _previousRadius: number;
  98826. protected _collisionTriggered: boolean;
  98827. protected _targetBoundingCenter: Nullable<Vector3>;
  98828. private _computationVector;
  98829. /**
  98830. * Instantiates a new ArcRotateCamera in a given scene
  98831. * @param name Defines the name of the camera
  98832. * @param alpha Defines the camera rotation along the logitudinal axis
  98833. * @param beta Defines the camera rotation along the latitudinal axis
  98834. * @param radius Defines the camera distance from its target
  98835. * @param target Defines the camera target
  98836. * @param scene Defines the scene the camera belongs to
  98837. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98838. */
  98839. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98840. /** @hidden */
  98841. _initCache(): void;
  98842. /** @hidden */
  98843. _updateCache(ignoreParentClass?: boolean): void;
  98844. protected _getTargetPosition(): Vector3;
  98845. private _storedAlpha;
  98846. private _storedBeta;
  98847. private _storedRadius;
  98848. private _storedTarget;
  98849. /**
  98850. * Stores the current state of the camera (alpha, beta, radius and target)
  98851. * @returns the camera itself
  98852. */
  98853. storeState(): Camera;
  98854. /**
  98855. * @hidden
  98856. * Restored camera state. You must call storeState() first
  98857. */
  98858. _restoreStateValues(): boolean;
  98859. /** @hidden */
  98860. _isSynchronizedViewMatrix(): boolean;
  98861. /**
  98862. * Attached controls to the current camera.
  98863. * @param element Defines the element the controls should be listened from
  98864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98865. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98866. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98867. */
  98868. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98869. /**
  98870. * Detach the current controls from the camera.
  98871. * The camera will stop reacting to inputs.
  98872. * @param element Defines the element to stop listening the inputs from
  98873. */
  98874. detachControl(element: HTMLElement): void;
  98875. /** @hidden */
  98876. _checkInputs(): void;
  98877. protected _checkLimits(): void;
  98878. /**
  98879. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98880. */
  98881. rebuildAnglesAndRadius(): void;
  98882. /**
  98883. * Use a position to define the current camera related information like aplha, beta and radius
  98884. * @param position Defines the position to set the camera at
  98885. */
  98886. setPosition(position: Vector3): void;
  98887. /**
  98888. * Defines the target the camera should look at.
  98889. * This will automatically adapt alpha beta and radius to fit within the new target.
  98890. * @param target Defines the new target as a Vector or a mesh
  98891. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98892. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98893. */
  98894. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98895. /** @hidden */
  98896. _getViewMatrix(): Matrix;
  98897. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98898. /**
  98899. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98900. * @param meshes Defines the mesh to zoom on
  98901. * @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)
  98902. */
  98903. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98904. /**
  98905. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98906. * The target will be changed but the radius
  98907. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98908. * @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)
  98909. */
  98910. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98911. min: Vector3;
  98912. max: Vector3;
  98913. distance: number;
  98914. }, doNotUpdateMaxZ?: boolean): void;
  98915. /**
  98916. * @override
  98917. * Override Camera.createRigCamera
  98918. */
  98919. createRigCamera(name: string, cameraIndex: number): Camera;
  98920. /**
  98921. * @hidden
  98922. * @override
  98923. * Override Camera._updateRigCameras
  98924. */
  98925. _updateRigCameras(): void;
  98926. /**
  98927. * Destroy the camera and release the current resources hold by it.
  98928. */
  98929. dispose(): void;
  98930. /**
  98931. * Gets the current object class name.
  98932. * @return the class name
  98933. */
  98934. getClassName(): string;
  98935. }
  98936. }
  98937. declare module BABYLON {
  98938. /**
  98939. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98940. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98941. */
  98942. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98943. /**
  98944. * Gets the name of the behavior.
  98945. */
  98946. readonly name: string;
  98947. private _zoomStopsAnimation;
  98948. private _idleRotationSpeed;
  98949. private _idleRotationWaitTime;
  98950. private _idleRotationSpinupTime;
  98951. /**
  98952. * Sets the flag that indicates if user zooming should stop animation.
  98953. */
  98954. /**
  98955. * Gets the flag that indicates if user zooming should stop animation.
  98956. */
  98957. zoomStopsAnimation: boolean;
  98958. /**
  98959. * Sets the default speed at which the camera rotates around the model.
  98960. */
  98961. /**
  98962. * Gets the default speed at which the camera rotates around the model.
  98963. */
  98964. idleRotationSpeed: number;
  98965. /**
  98966. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98967. */
  98968. /**
  98969. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98970. */
  98971. idleRotationWaitTime: number;
  98972. /**
  98973. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98974. */
  98975. /**
  98976. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98977. */
  98978. idleRotationSpinupTime: number;
  98979. /**
  98980. * Gets a value indicating if the camera is currently rotating because of this behavior
  98981. */
  98982. readonly rotationInProgress: boolean;
  98983. private _onPrePointerObservableObserver;
  98984. private _onAfterCheckInputsObserver;
  98985. private _attachedCamera;
  98986. private _isPointerDown;
  98987. private _lastFrameTime;
  98988. private _lastInteractionTime;
  98989. private _cameraRotationSpeed;
  98990. /**
  98991. * Initializes the behavior.
  98992. */
  98993. init(): void;
  98994. /**
  98995. * Attaches the behavior to its arc rotate camera.
  98996. * @param camera Defines the camera to attach the behavior to
  98997. */
  98998. attach(camera: ArcRotateCamera): void;
  98999. /**
  99000. * Detaches the behavior from its current arc rotate camera.
  99001. */
  99002. detach(): void;
  99003. /**
  99004. * Returns true if user is scrolling.
  99005. * @return true if user is scrolling.
  99006. */
  99007. private _userIsZooming;
  99008. private _lastFrameRadius;
  99009. private _shouldAnimationStopForInteraction;
  99010. /**
  99011. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  99012. */
  99013. private _applyUserInteraction;
  99014. private _userIsMoving;
  99015. }
  99016. }
  99017. declare module BABYLON {
  99018. /**
  99019. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  99020. */
  99021. export class AttachToBoxBehavior implements Behavior<Mesh> {
  99022. private ui;
  99023. /**
  99024. * The name of the behavior
  99025. */
  99026. name: string;
  99027. /**
  99028. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  99029. */
  99030. distanceAwayFromFace: number;
  99031. /**
  99032. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  99033. */
  99034. distanceAwayFromBottomOfFace: number;
  99035. private _faceVectors;
  99036. private _target;
  99037. private _scene;
  99038. private _onRenderObserver;
  99039. private _tmpMatrix;
  99040. private _tmpVector;
  99041. /**
  99042. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  99043. * @param ui The transform node that should be attched to the mesh
  99044. */
  99045. constructor(ui: TransformNode);
  99046. /**
  99047. * Initializes the behavior
  99048. */
  99049. init(): void;
  99050. private _closestFace;
  99051. private _zeroVector;
  99052. private _lookAtTmpMatrix;
  99053. private _lookAtToRef;
  99054. /**
  99055. * Attaches the AttachToBoxBehavior to the passed in mesh
  99056. * @param target The mesh that the specified node will be attached to
  99057. */
  99058. attach(target: Mesh): void;
  99059. /**
  99060. * Detaches the behavior from the mesh
  99061. */
  99062. detach(): void;
  99063. }
  99064. }
  99065. declare module BABYLON {
  99066. /**
  99067. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  99068. */
  99069. export class FadeInOutBehavior implements Behavior<Mesh> {
  99070. /**
  99071. * Time in milliseconds to delay before fading in (Default: 0)
  99072. */
  99073. delay: number;
  99074. /**
  99075. * Time in milliseconds for the mesh to fade in (Default: 300)
  99076. */
  99077. fadeInTime: number;
  99078. private _millisecondsPerFrame;
  99079. private _hovered;
  99080. private _hoverValue;
  99081. private _ownerNode;
  99082. /**
  99083. * Instatiates the FadeInOutBehavior
  99084. */
  99085. constructor();
  99086. /**
  99087. * The name of the behavior
  99088. */
  99089. readonly name: string;
  99090. /**
  99091. * Initializes the behavior
  99092. */
  99093. init(): void;
  99094. /**
  99095. * Attaches the fade behavior on the passed in mesh
  99096. * @param ownerNode The mesh that will be faded in/out once attached
  99097. */
  99098. attach(ownerNode: Mesh): void;
  99099. /**
  99100. * Detaches the behavior from the mesh
  99101. */
  99102. detach(): void;
  99103. /**
  99104. * Triggers the mesh to begin fading in or out
  99105. * @param value if the object should fade in or out (true to fade in)
  99106. */
  99107. fadeIn(value: boolean): void;
  99108. private _update;
  99109. private _setAllVisibility;
  99110. }
  99111. }
  99112. declare module BABYLON {
  99113. /**
  99114. * Class containing a set of static utilities functions for managing Pivots
  99115. * @hidden
  99116. */
  99117. export class PivotTools {
  99118. private static _PivotCached;
  99119. private static _OldPivotPoint;
  99120. private static _PivotTranslation;
  99121. private static _PivotTmpVector;
  99122. /** @hidden */
  99123. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  99124. /** @hidden */
  99125. static _RestorePivotPoint(mesh: AbstractMesh): void;
  99126. }
  99127. }
  99128. declare module BABYLON {
  99129. /**
  99130. * Class containing static functions to help procedurally build meshes
  99131. */
  99132. export class PlaneBuilder {
  99133. /**
  99134. * Creates a plane mesh
  99135. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  99136. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  99137. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  99138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99141. * @param name defines the name of the mesh
  99142. * @param options defines the options used to create the mesh
  99143. * @param scene defines the hosting scene
  99144. * @returns the plane mesh
  99145. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  99146. */
  99147. static CreatePlane(name: string, options: {
  99148. size?: number;
  99149. width?: number;
  99150. height?: number;
  99151. sideOrientation?: number;
  99152. frontUVs?: Vector4;
  99153. backUVs?: Vector4;
  99154. updatable?: boolean;
  99155. sourcePlane?: Plane;
  99156. }, scene?: Nullable<Scene>): Mesh;
  99157. }
  99158. }
  99159. declare module BABYLON {
  99160. /**
  99161. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  99162. */
  99163. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  99164. private static _AnyMouseID;
  99165. /**
  99166. * Abstract mesh the behavior is set on
  99167. */
  99168. attachedNode: AbstractMesh;
  99169. private _dragPlane;
  99170. private _scene;
  99171. private _pointerObserver;
  99172. private _beforeRenderObserver;
  99173. private static _planeScene;
  99174. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  99175. /**
  99176. * 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)
  99177. */
  99178. maxDragAngle: number;
  99179. /**
  99180. * @hidden
  99181. */
  99182. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  99183. /**
  99184. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99185. */
  99186. currentDraggingPointerID: number;
  99187. /**
  99188. * The last position where the pointer hit the drag plane in world space
  99189. */
  99190. lastDragPosition: Vector3;
  99191. /**
  99192. * If the behavior is currently in a dragging state
  99193. */
  99194. dragging: boolean;
  99195. /**
  99196. * 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)
  99197. */
  99198. dragDeltaRatio: number;
  99199. /**
  99200. * If the drag plane orientation should be updated during the dragging (Default: true)
  99201. */
  99202. updateDragPlane: boolean;
  99203. private _debugMode;
  99204. private _moving;
  99205. /**
  99206. * Fires each time the attached mesh is dragged with the pointer
  99207. * * delta between last drag position and current drag position in world space
  99208. * * dragDistance along the drag axis
  99209. * * dragPlaneNormal normal of the current drag plane used during the drag
  99210. * * dragPlanePoint in world space where the drag intersects the drag plane
  99211. */
  99212. onDragObservable: Observable<{
  99213. delta: Vector3;
  99214. dragPlanePoint: Vector3;
  99215. dragPlaneNormal: Vector3;
  99216. dragDistance: number;
  99217. pointerId: number;
  99218. }>;
  99219. /**
  99220. * Fires each time a drag begins (eg. mouse down on mesh)
  99221. */
  99222. onDragStartObservable: Observable<{
  99223. dragPlanePoint: Vector3;
  99224. pointerId: number;
  99225. }>;
  99226. /**
  99227. * Fires each time a drag ends (eg. mouse release after drag)
  99228. */
  99229. onDragEndObservable: Observable<{
  99230. dragPlanePoint: Vector3;
  99231. pointerId: number;
  99232. }>;
  99233. /**
  99234. * If the attached mesh should be moved when dragged
  99235. */
  99236. moveAttached: boolean;
  99237. /**
  99238. * If the drag behavior will react to drag events (Default: true)
  99239. */
  99240. enabled: boolean;
  99241. /**
  99242. * If pointer events should start and release the drag (Default: true)
  99243. */
  99244. startAndReleaseDragOnPointerEvents: boolean;
  99245. /**
  99246. * If camera controls should be detached during the drag
  99247. */
  99248. detachCameraControls: boolean;
  99249. /**
  99250. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  99251. */
  99252. useObjectOrienationForDragging: boolean;
  99253. private _options;
  99254. /**
  99255. * Creates a pointer drag behavior that can be attached to a mesh
  99256. * @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)
  99257. */
  99258. constructor(options?: {
  99259. dragAxis?: Vector3;
  99260. dragPlaneNormal?: Vector3;
  99261. });
  99262. /**
  99263. * Predicate to determine if it is valid to move the object to a new position when it is moved
  99264. */
  99265. validateDrag: (targetPosition: Vector3) => boolean;
  99266. /**
  99267. * The name of the behavior
  99268. */
  99269. readonly name: string;
  99270. /**
  99271. * Initializes the behavior
  99272. */
  99273. init(): void;
  99274. private _tmpVector;
  99275. private _alternatePickedPoint;
  99276. private _worldDragAxis;
  99277. private _targetPosition;
  99278. private _attachedElement;
  99279. /**
  99280. * Attaches the drag behavior the passed in mesh
  99281. * @param ownerNode The mesh that will be dragged around once attached
  99282. */
  99283. attach(ownerNode: AbstractMesh): void;
  99284. /**
  99285. * Force relase the drag action by code.
  99286. */
  99287. releaseDrag(): void;
  99288. private _startDragRay;
  99289. private _lastPointerRay;
  99290. /**
  99291. * Simulates the start of a pointer drag event on the behavior
  99292. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  99293. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  99294. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  99295. */
  99296. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  99297. private _startDrag;
  99298. private _dragDelta;
  99299. private _moveDrag;
  99300. private _pickWithRayOnDragPlane;
  99301. private _pointA;
  99302. private _pointB;
  99303. private _pointC;
  99304. private _lineA;
  99305. private _lineB;
  99306. private _localAxis;
  99307. private _lookAt;
  99308. private _updateDragPlanePosition;
  99309. /**
  99310. * Detaches the behavior from the mesh
  99311. */
  99312. detach(): void;
  99313. }
  99314. }
  99315. declare module BABYLON {
  99316. /**
  99317. * A behavior that when attached to a mesh will allow the mesh to be scaled
  99318. */
  99319. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  99320. private _dragBehaviorA;
  99321. private _dragBehaviorB;
  99322. private _startDistance;
  99323. private _initialScale;
  99324. private _targetScale;
  99325. private _ownerNode;
  99326. private _sceneRenderObserver;
  99327. /**
  99328. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  99329. */
  99330. constructor();
  99331. /**
  99332. * The name of the behavior
  99333. */
  99334. readonly name: string;
  99335. /**
  99336. * Initializes the behavior
  99337. */
  99338. init(): void;
  99339. private _getCurrentDistance;
  99340. /**
  99341. * Attaches the scale behavior the passed in mesh
  99342. * @param ownerNode The mesh that will be scaled around once attached
  99343. */
  99344. attach(ownerNode: Mesh): void;
  99345. /**
  99346. * Detaches the behavior from the mesh
  99347. */
  99348. detach(): void;
  99349. }
  99350. }
  99351. declare module BABYLON {
  99352. /**
  99353. * 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
  99354. */
  99355. export class SixDofDragBehavior implements Behavior<Mesh> {
  99356. private static _virtualScene;
  99357. private _ownerNode;
  99358. private _sceneRenderObserver;
  99359. private _scene;
  99360. private _targetPosition;
  99361. private _virtualOriginMesh;
  99362. private _virtualDragMesh;
  99363. private _pointerObserver;
  99364. private _moving;
  99365. private _startingOrientation;
  99366. /**
  99367. * 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)
  99368. */
  99369. private zDragFactor;
  99370. /**
  99371. * If the object should rotate to face the drag origin
  99372. */
  99373. rotateDraggedObject: boolean;
  99374. /**
  99375. * If the behavior is currently in a dragging state
  99376. */
  99377. dragging: boolean;
  99378. /**
  99379. * 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)
  99380. */
  99381. dragDeltaRatio: number;
  99382. /**
  99383. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99384. */
  99385. currentDraggingPointerID: number;
  99386. /**
  99387. * If camera controls should be detached during the drag
  99388. */
  99389. detachCameraControls: boolean;
  99390. /**
  99391. * Fires each time a drag starts
  99392. */
  99393. onDragStartObservable: Observable<{}>;
  99394. /**
  99395. * Fires each time a drag ends (eg. mouse release after drag)
  99396. */
  99397. onDragEndObservable: Observable<{}>;
  99398. /**
  99399. * 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
  99400. */
  99401. constructor();
  99402. /**
  99403. * The name of the behavior
  99404. */
  99405. readonly name: string;
  99406. /**
  99407. * Initializes the behavior
  99408. */
  99409. init(): void;
  99410. /**
  99411. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  99412. */
  99413. private readonly _pointerCamera;
  99414. /**
  99415. * Attaches the scale behavior the passed in mesh
  99416. * @param ownerNode The mesh that will be scaled around once attached
  99417. */
  99418. attach(ownerNode: Mesh): void;
  99419. /**
  99420. * Detaches the behavior from the mesh
  99421. */
  99422. detach(): void;
  99423. }
  99424. }
  99425. declare module BABYLON {
  99426. /**
  99427. * Class used to apply inverse kinematics to bones
  99428. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  99429. */
  99430. export class BoneIKController {
  99431. private static _tmpVecs;
  99432. private static _tmpQuat;
  99433. private static _tmpMats;
  99434. /**
  99435. * Gets or sets the target mesh
  99436. */
  99437. targetMesh: AbstractMesh;
  99438. /** Gets or sets the mesh used as pole */
  99439. poleTargetMesh: AbstractMesh;
  99440. /**
  99441. * Gets or sets the bone used as pole
  99442. */
  99443. poleTargetBone: Nullable<Bone>;
  99444. /**
  99445. * Gets or sets the target position
  99446. */
  99447. targetPosition: Vector3;
  99448. /**
  99449. * Gets or sets the pole target position
  99450. */
  99451. poleTargetPosition: Vector3;
  99452. /**
  99453. * Gets or sets the pole target local offset
  99454. */
  99455. poleTargetLocalOffset: Vector3;
  99456. /**
  99457. * Gets or sets the pole angle
  99458. */
  99459. poleAngle: number;
  99460. /**
  99461. * Gets or sets the mesh associated with the controller
  99462. */
  99463. mesh: AbstractMesh;
  99464. /**
  99465. * 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)
  99466. */
  99467. slerpAmount: number;
  99468. private _bone1Quat;
  99469. private _bone1Mat;
  99470. private _bone2Ang;
  99471. private _bone1;
  99472. private _bone2;
  99473. private _bone1Length;
  99474. private _bone2Length;
  99475. private _maxAngle;
  99476. private _maxReach;
  99477. private _rightHandedSystem;
  99478. private _bendAxis;
  99479. private _slerping;
  99480. private _adjustRoll;
  99481. /**
  99482. * Gets or sets maximum allowed angle
  99483. */
  99484. maxAngle: number;
  99485. /**
  99486. * Creates a new BoneIKController
  99487. * @param mesh defines the mesh to control
  99488. * @param bone defines the bone to control
  99489. * @param options defines options to set up the controller
  99490. */
  99491. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  99492. targetMesh?: AbstractMesh;
  99493. poleTargetMesh?: AbstractMesh;
  99494. poleTargetBone?: Bone;
  99495. poleTargetLocalOffset?: Vector3;
  99496. poleAngle?: number;
  99497. bendAxis?: Vector3;
  99498. maxAngle?: number;
  99499. slerpAmount?: number;
  99500. });
  99501. private _setMaxAngle;
  99502. /**
  99503. * Force the controller to update the bones
  99504. */
  99505. update(): void;
  99506. }
  99507. }
  99508. declare module BABYLON {
  99509. /**
  99510. * Class used to make a bone look toward a point in space
  99511. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  99512. */
  99513. export class BoneLookController {
  99514. private static _tmpVecs;
  99515. private static _tmpQuat;
  99516. private static _tmpMats;
  99517. /**
  99518. * The target Vector3 that the bone will look at
  99519. */
  99520. target: Vector3;
  99521. /**
  99522. * The mesh that the bone is attached to
  99523. */
  99524. mesh: AbstractMesh;
  99525. /**
  99526. * The bone that will be looking to the target
  99527. */
  99528. bone: Bone;
  99529. /**
  99530. * The up axis of the coordinate system that is used when the bone is rotated
  99531. */
  99532. upAxis: Vector3;
  99533. /**
  99534. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  99535. */
  99536. upAxisSpace: Space;
  99537. /**
  99538. * Used to make an adjustment to the yaw of the bone
  99539. */
  99540. adjustYaw: number;
  99541. /**
  99542. * Used to make an adjustment to the pitch of the bone
  99543. */
  99544. adjustPitch: number;
  99545. /**
  99546. * Used to make an adjustment to the roll of the bone
  99547. */
  99548. adjustRoll: number;
  99549. /**
  99550. * 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)
  99551. */
  99552. slerpAmount: number;
  99553. private _minYaw;
  99554. private _maxYaw;
  99555. private _minPitch;
  99556. private _maxPitch;
  99557. private _minYawSin;
  99558. private _minYawCos;
  99559. private _maxYawSin;
  99560. private _maxYawCos;
  99561. private _midYawConstraint;
  99562. private _minPitchTan;
  99563. private _maxPitchTan;
  99564. private _boneQuat;
  99565. private _slerping;
  99566. private _transformYawPitch;
  99567. private _transformYawPitchInv;
  99568. private _firstFrameSkipped;
  99569. private _yawRange;
  99570. private _fowardAxis;
  99571. /**
  99572. * Gets or sets the minimum yaw angle that the bone can look to
  99573. */
  99574. minYaw: number;
  99575. /**
  99576. * Gets or sets the maximum yaw angle that the bone can look to
  99577. */
  99578. maxYaw: number;
  99579. /**
  99580. * Gets or sets the minimum pitch angle that the bone can look to
  99581. */
  99582. minPitch: number;
  99583. /**
  99584. * Gets or sets the maximum pitch angle that the bone can look to
  99585. */
  99586. maxPitch: number;
  99587. /**
  99588. * Create a BoneLookController
  99589. * @param mesh the mesh that the bone belongs to
  99590. * @param bone the bone that will be looking to the target
  99591. * @param target the target Vector3 to look at
  99592. * @param options optional settings:
  99593. * * maxYaw: the maximum angle the bone will yaw to
  99594. * * minYaw: the minimum angle the bone will yaw to
  99595. * * maxPitch: the maximum angle the bone will pitch to
  99596. * * minPitch: the minimum angle the bone will yaw to
  99597. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  99598. * * upAxis: the up axis of the coordinate system
  99599. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  99600. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  99601. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  99602. * * adjustYaw: used to make an adjustment to the yaw of the bone
  99603. * * adjustPitch: used to make an adjustment to the pitch of the bone
  99604. * * adjustRoll: used to make an adjustment to the roll of the bone
  99605. **/
  99606. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  99607. maxYaw?: number;
  99608. minYaw?: number;
  99609. maxPitch?: number;
  99610. minPitch?: number;
  99611. slerpAmount?: number;
  99612. upAxis?: Vector3;
  99613. upAxisSpace?: Space;
  99614. yawAxis?: Vector3;
  99615. pitchAxis?: Vector3;
  99616. adjustYaw?: number;
  99617. adjustPitch?: number;
  99618. adjustRoll?: number;
  99619. });
  99620. /**
  99621. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  99622. */
  99623. update(): void;
  99624. private _getAngleDiff;
  99625. private _getAngleBetween;
  99626. private _isAngleBetween;
  99627. }
  99628. }
  99629. declare module BABYLON {
  99630. /**
  99631. * Manage the gamepad inputs to control an arc rotate camera.
  99632. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99633. */
  99634. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  99635. /**
  99636. * Defines the camera the input is attached to.
  99637. */
  99638. camera: ArcRotateCamera;
  99639. /**
  99640. * Defines the gamepad the input is gathering event from.
  99641. */
  99642. gamepad: Nullable<Gamepad>;
  99643. /**
  99644. * Defines the gamepad rotation sensiblity.
  99645. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99646. */
  99647. gamepadRotationSensibility: number;
  99648. /**
  99649. * Defines the gamepad move sensiblity.
  99650. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99651. */
  99652. gamepadMoveSensibility: number;
  99653. private _onGamepadConnectedObserver;
  99654. private _onGamepadDisconnectedObserver;
  99655. /**
  99656. * Attach the input controls to a specific dom element to get the input from.
  99657. * @param element Defines the element the controls should be listened from
  99658. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99659. */
  99660. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99661. /**
  99662. * Detach the current controls from the specified dom element.
  99663. * @param element Defines the element to stop listening the inputs from
  99664. */
  99665. detachControl(element: Nullable<HTMLElement>): void;
  99666. /**
  99667. * Update the current camera state depending on the inputs that have been used this frame.
  99668. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99669. */
  99670. checkInputs(): void;
  99671. /**
  99672. * Gets the class name of the current intput.
  99673. * @returns the class name
  99674. */
  99675. getClassName(): string;
  99676. /**
  99677. * Get the friendly name associated with the input class.
  99678. * @returns the input friendly name
  99679. */
  99680. getSimpleName(): string;
  99681. }
  99682. }
  99683. declare module BABYLON {
  99684. interface ArcRotateCameraInputsManager {
  99685. /**
  99686. * Add orientation input support to the input manager.
  99687. * @returns the current input manager
  99688. */
  99689. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  99690. }
  99691. /**
  99692. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  99693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99694. */
  99695. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  99696. /**
  99697. * Defines the camera the input is attached to.
  99698. */
  99699. camera: ArcRotateCamera;
  99700. /**
  99701. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  99702. */
  99703. alphaCorrection: number;
  99704. /**
  99705. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  99706. */
  99707. gammaCorrection: number;
  99708. private _alpha;
  99709. private _gamma;
  99710. private _dirty;
  99711. private _deviceOrientationHandler;
  99712. /**
  99713. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  99714. */
  99715. constructor();
  99716. /**
  99717. * Attach the input controls to a specific dom element to get the input from.
  99718. * @param element Defines the element the controls should be listened from
  99719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99720. */
  99721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99722. /** @hidden */
  99723. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  99724. /**
  99725. * Update the current camera state depending on the inputs that have been used this frame.
  99726. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99727. */
  99728. checkInputs(): void;
  99729. /**
  99730. * Detach the current controls from the specified dom element.
  99731. * @param element Defines the element to stop listening the inputs from
  99732. */
  99733. detachControl(element: Nullable<HTMLElement>): void;
  99734. /**
  99735. * Gets the class name of the current intput.
  99736. * @returns the class name
  99737. */
  99738. getClassName(): string;
  99739. /**
  99740. * Get the friendly name associated with the input class.
  99741. * @returns the input friendly name
  99742. */
  99743. getSimpleName(): string;
  99744. }
  99745. }
  99746. declare module BABYLON {
  99747. /**
  99748. * Listen to mouse events to control the camera.
  99749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99750. */
  99751. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  99752. /**
  99753. * Defines the camera the input is attached to.
  99754. */
  99755. camera: FlyCamera;
  99756. /**
  99757. * Defines if touch is enabled. (Default is true.)
  99758. */
  99759. touchEnabled: boolean;
  99760. /**
  99761. * Defines the buttons associated with the input to handle camera rotation.
  99762. */
  99763. buttons: number[];
  99764. /**
  99765. * Assign buttons for Yaw control.
  99766. */
  99767. buttonsYaw: number[];
  99768. /**
  99769. * Assign buttons for Pitch control.
  99770. */
  99771. buttonsPitch: number[];
  99772. /**
  99773. * Assign buttons for Roll control.
  99774. */
  99775. buttonsRoll: number[];
  99776. /**
  99777. * Detect if any button is being pressed while mouse is moved.
  99778. * -1 = Mouse locked.
  99779. * 0 = Left button.
  99780. * 1 = Middle Button.
  99781. * 2 = Right Button.
  99782. */
  99783. activeButton: number;
  99784. /**
  99785. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  99786. * Higher values reduce its sensitivity.
  99787. */
  99788. angularSensibility: number;
  99789. private _mousemoveCallback;
  99790. private _observer;
  99791. private _rollObserver;
  99792. private previousPosition;
  99793. private noPreventDefault;
  99794. private element;
  99795. /**
  99796. * Listen to mouse events to control the camera.
  99797. * @param touchEnabled Define if touch is enabled. (Default is true.)
  99798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99799. */
  99800. constructor(touchEnabled?: boolean);
  99801. /**
  99802. * Attach the mouse control to the HTML DOM element.
  99803. * @param element Defines the element that listens to the input events.
  99804. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  99805. */
  99806. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99807. /**
  99808. * Detach the current controls from the specified dom element.
  99809. * @param element Defines the element to stop listening the inputs from
  99810. */
  99811. detachControl(element: Nullable<HTMLElement>): void;
  99812. /**
  99813. * Gets the class name of the current input.
  99814. * @returns the class name.
  99815. */
  99816. getClassName(): string;
  99817. /**
  99818. * Get the friendly name associated with the input class.
  99819. * @returns the input's friendly name.
  99820. */
  99821. getSimpleName(): string;
  99822. private _pointerInput;
  99823. private _onMouseMove;
  99824. /**
  99825. * Rotate camera by mouse offset.
  99826. */
  99827. private rotateCamera;
  99828. }
  99829. }
  99830. declare module BABYLON {
  99831. /**
  99832. * Default Inputs manager for the FlyCamera.
  99833. * It groups all the default supported inputs for ease of use.
  99834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99835. */
  99836. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  99837. /**
  99838. * Instantiates a new FlyCameraInputsManager.
  99839. * @param camera Defines the camera the inputs belong to.
  99840. */
  99841. constructor(camera: FlyCamera);
  99842. /**
  99843. * Add keyboard input support to the input manager.
  99844. * @returns the new FlyCameraKeyboardMoveInput().
  99845. */
  99846. addKeyboard(): FlyCameraInputsManager;
  99847. /**
  99848. * Add mouse input support to the input manager.
  99849. * @param touchEnabled Enable touch screen support.
  99850. * @returns the new FlyCameraMouseInput().
  99851. */
  99852. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  99853. }
  99854. }
  99855. declare module BABYLON {
  99856. /**
  99857. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99858. * such as in a 3D Space Shooter or a Flight Simulator.
  99859. */
  99860. export class FlyCamera extends TargetCamera {
  99861. /**
  99862. * Define the collision ellipsoid of the camera.
  99863. * This is helpful for simulating a camera body, like a player's body.
  99864. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99865. */
  99866. ellipsoid: Vector3;
  99867. /**
  99868. * Define an offset for the position of the ellipsoid around the camera.
  99869. * This can be helpful if the camera is attached away from the player's body center,
  99870. * such as at its head.
  99871. */
  99872. ellipsoidOffset: Vector3;
  99873. /**
  99874. * Enable or disable collisions of the camera with the rest of the scene objects.
  99875. */
  99876. checkCollisions: boolean;
  99877. /**
  99878. * Enable or disable gravity on the camera.
  99879. */
  99880. applyGravity: boolean;
  99881. /**
  99882. * Define the current direction the camera is moving to.
  99883. */
  99884. cameraDirection: Vector3;
  99885. /**
  99886. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99887. * This overrides and empties cameraRotation.
  99888. */
  99889. rotationQuaternion: Quaternion;
  99890. /**
  99891. * Track Roll to maintain the wanted Rolling when looking around.
  99892. */
  99893. _trackRoll: number;
  99894. /**
  99895. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99896. */
  99897. rollCorrect: number;
  99898. /**
  99899. * Mimic a banked turn, Rolling the camera when Yawing.
  99900. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99901. */
  99902. bankedTurn: boolean;
  99903. /**
  99904. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99905. */
  99906. bankedTurnLimit: number;
  99907. /**
  99908. * Value of 0 disables the banked Roll.
  99909. * Value of 1 is equal to the Yaw angle in radians.
  99910. */
  99911. bankedTurnMultiplier: number;
  99912. /**
  99913. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99914. */
  99915. inputs: FlyCameraInputsManager;
  99916. /**
  99917. * Gets the input sensibility for mouse input.
  99918. * Higher values reduce sensitivity.
  99919. */
  99920. /**
  99921. * Sets the input sensibility for a mouse input.
  99922. * Higher values reduce sensitivity.
  99923. */
  99924. angularSensibility: number;
  99925. /**
  99926. * Get the keys for camera movement forward.
  99927. */
  99928. /**
  99929. * Set the keys for camera movement forward.
  99930. */
  99931. keysForward: number[];
  99932. /**
  99933. * Get the keys for camera movement backward.
  99934. */
  99935. keysBackward: number[];
  99936. /**
  99937. * Get the keys for camera movement up.
  99938. */
  99939. /**
  99940. * Set the keys for camera movement up.
  99941. */
  99942. keysUp: number[];
  99943. /**
  99944. * Get the keys for camera movement down.
  99945. */
  99946. /**
  99947. * Set the keys for camera movement down.
  99948. */
  99949. keysDown: number[];
  99950. /**
  99951. * Get the keys for camera movement left.
  99952. */
  99953. /**
  99954. * Set the keys for camera movement left.
  99955. */
  99956. keysLeft: number[];
  99957. /**
  99958. * Set the keys for camera movement right.
  99959. */
  99960. /**
  99961. * Set the keys for camera movement right.
  99962. */
  99963. keysRight: number[];
  99964. /**
  99965. * Event raised when the camera collides with a mesh in the scene.
  99966. */
  99967. onCollide: (collidedMesh: AbstractMesh) => void;
  99968. private _collider;
  99969. private _needMoveForGravity;
  99970. private _oldPosition;
  99971. private _diffPosition;
  99972. private _newPosition;
  99973. /** @hidden */
  99974. _localDirection: Vector3;
  99975. /** @hidden */
  99976. _transformedDirection: Vector3;
  99977. /**
  99978. * Instantiates a FlyCamera.
  99979. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99980. * such as in a 3D Space Shooter or a Flight Simulator.
  99981. * @param name Define the name of the camera in the scene.
  99982. * @param position Define the starting position of the camera in the scene.
  99983. * @param scene Define the scene the camera belongs to.
  99984. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99985. */
  99986. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99987. /**
  99988. * Attach a control to the HTML DOM element.
  99989. * @param element Defines the element that listens to the input events.
  99990. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99991. */
  99992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99993. /**
  99994. * Detach a control from the HTML DOM element.
  99995. * The camera will stop reacting to that input.
  99996. * @param element Defines the element that listens to the input events.
  99997. */
  99998. detachControl(element: HTMLElement): void;
  99999. private _collisionMask;
  100000. /**
  100001. * Get the mask that the camera ignores in collision events.
  100002. */
  100003. /**
  100004. * Set the mask that the camera ignores in collision events.
  100005. */
  100006. collisionMask: number;
  100007. /** @hidden */
  100008. _collideWithWorld(displacement: Vector3): void;
  100009. /** @hidden */
  100010. private _onCollisionPositionChange;
  100011. /** @hidden */
  100012. _checkInputs(): void;
  100013. /** @hidden */
  100014. _decideIfNeedsToMove(): boolean;
  100015. /** @hidden */
  100016. _updatePosition(): void;
  100017. /**
  100018. * Restore the Roll to its target value at the rate specified.
  100019. * @param rate - Higher means slower restoring.
  100020. * @hidden
  100021. */
  100022. restoreRoll(rate: number): void;
  100023. /**
  100024. * Destroy the camera and release the current resources held by it.
  100025. */
  100026. dispose(): void;
  100027. /**
  100028. * Get the current object class name.
  100029. * @returns the class name.
  100030. */
  100031. getClassName(): string;
  100032. }
  100033. }
  100034. declare module BABYLON {
  100035. /**
  100036. * Listen to keyboard events to control the camera.
  100037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100038. */
  100039. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  100040. /**
  100041. * Defines the camera the input is attached to.
  100042. */
  100043. camera: FlyCamera;
  100044. /**
  100045. * The list of keyboard keys used to control the forward move of the camera.
  100046. */
  100047. keysForward: number[];
  100048. /**
  100049. * The list of keyboard keys used to control the backward move of the camera.
  100050. */
  100051. keysBackward: number[];
  100052. /**
  100053. * The list of keyboard keys used to control the forward move of the camera.
  100054. */
  100055. keysUp: number[];
  100056. /**
  100057. * The list of keyboard keys used to control the backward move of the camera.
  100058. */
  100059. keysDown: number[];
  100060. /**
  100061. * The list of keyboard keys used to control the right strafe move of the camera.
  100062. */
  100063. keysRight: number[];
  100064. /**
  100065. * The list of keyboard keys used to control the left strafe move of the camera.
  100066. */
  100067. keysLeft: number[];
  100068. private _keys;
  100069. private _onCanvasBlurObserver;
  100070. private _onKeyboardObserver;
  100071. private _engine;
  100072. private _scene;
  100073. /**
  100074. * Attach the input controls to a specific dom element to get the input from.
  100075. * @param element Defines the element the controls should be listened from
  100076. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100077. */
  100078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100079. /**
  100080. * Detach the current controls from the specified dom element.
  100081. * @param element Defines the element to stop listening the inputs from
  100082. */
  100083. detachControl(element: Nullable<HTMLElement>): void;
  100084. /**
  100085. * Gets the class name of the current intput.
  100086. * @returns the class name
  100087. */
  100088. getClassName(): string;
  100089. /** @hidden */
  100090. _onLostFocus(e: FocusEvent): void;
  100091. /**
  100092. * Get the friendly name associated with the input class.
  100093. * @returns the input friendly name
  100094. */
  100095. getSimpleName(): string;
  100096. /**
  100097. * Update the current camera state depending on the inputs that have been used this frame.
  100098. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100099. */
  100100. checkInputs(): void;
  100101. }
  100102. }
  100103. declare module BABYLON {
  100104. /**
  100105. * Manage the mouse wheel inputs to control a follow camera.
  100106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100107. */
  100108. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  100109. /**
  100110. * Defines the camera the input is attached to.
  100111. */
  100112. camera: FollowCamera;
  100113. /**
  100114. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  100115. */
  100116. axisControlRadius: boolean;
  100117. /**
  100118. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  100119. */
  100120. axisControlHeight: boolean;
  100121. /**
  100122. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  100123. */
  100124. axisControlRotation: boolean;
  100125. /**
  100126. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  100127. * relation to mouseWheel events.
  100128. */
  100129. wheelPrecision: number;
  100130. /**
  100131. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100132. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100133. */
  100134. wheelDeltaPercentage: number;
  100135. private _wheel;
  100136. private _observer;
  100137. /**
  100138. * Attach the input controls to a specific dom element to get the input from.
  100139. * @param element Defines the element the controls should be listened from
  100140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100141. */
  100142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100143. /**
  100144. * Detach the current controls from the specified dom element.
  100145. * @param element Defines the element to stop listening the inputs from
  100146. */
  100147. detachControl(element: Nullable<HTMLElement>): void;
  100148. /**
  100149. * Gets the class name of the current intput.
  100150. * @returns the class name
  100151. */
  100152. getClassName(): string;
  100153. /**
  100154. * Get the friendly name associated with the input class.
  100155. * @returns the input friendly name
  100156. */
  100157. getSimpleName(): string;
  100158. }
  100159. }
  100160. declare module BABYLON {
  100161. /**
  100162. * Manage the pointers inputs to control an follow camera.
  100163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100164. */
  100165. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  100166. /**
  100167. * Defines the camera the input is attached to.
  100168. */
  100169. camera: FollowCamera;
  100170. /**
  100171. * Gets the class name of the current input.
  100172. * @returns the class name
  100173. */
  100174. getClassName(): string;
  100175. /**
  100176. * Defines the pointer angular sensibility along the X axis or how fast is
  100177. * the camera rotating.
  100178. * A negative number will reverse the axis direction.
  100179. */
  100180. angularSensibilityX: number;
  100181. /**
  100182. * Defines the pointer angular sensibility along the Y axis or how fast is
  100183. * the camera rotating.
  100184. * A negative number will reverse the axis direction.
  100185. */
  100186. angularSensibilityY: number;
  100187. /**
  100188. * Defines the pointer pinch precision or how fast is the camera zooming.
  100189. * A negative number will reverse the axis direction.
  100190. */
  100191. pinchPrecision: number;
  100192. /**
  100193. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  100194. * from 0.
  100195. * It defines the percentage of current camera.radius to use as delta when
  100196. * pinch zoom is used.
  100197. */
  100198. pinchDeltaPercentage: number;
  100199. /**
  100200. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  100201. */
  100202. axisXControlRadius: boolean;
  100203. /**
  100204. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  100205. */
  100206. axisXControlHeight: boolean;
  100207. /**
  100208. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  100209. */
  100210. axisXControlRotation: boolean;
  100211. /**
  100212. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  100213. */
  100214. axisYControlRadius: boolean;
  100215. /**
  100216. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  100217. */
  100218. axisYControlHeight: boolean;
  100219. /**
  100220. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  100221. */
  100222. axisYControlRotation: boolean;
  100223. /**
  100224. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  100225. */
  100226. axisPinchControlRadius: boolean;
  100227. /**
  100228. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  100229. */
  100230. axisPinchControlHeight: boolean;
  100231. /**
  100232. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  100233. */
  100234. axisPinchControlRotation: boolean;
  100235. /**
  100236. * Log error messages if basic misconfiguration has occurred.
  100237. */
  100238. warningEnable: boolean;
  100239. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100240. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100241. private _warningCounter;
  100242. private _warning;
  100243. }
  100244. }
  100245. declare module BABYLON {
  100246. /**
  100247. * Default Inputs manager for the FollowCamera.
  100248. * It groups all the default supported inputs for ease of use.
  100249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100250. */
  100251. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  100252. /**
  100253. * Instantiates a new FollowCameraInputsManager.
  100254. * @param camera Defines the camera the inputs belong to
  100255. */
  100256. constructor(camera: FollowCamera);
  100257. /**
  100258. * Add keyboard input support to the input manager.
  100259. * @returns the current input manager
  100260. */
  100261. addKeyboard(): FollowCameraInputsManager;
  100262. /**
  100263. * Add mouse wheel input support to the input manager.
  100264. * @returns the current input manager
  100265. */
  100266. addMouseWheel(): FollowCameraInputsManager;
  100267. /**
  100268. * Add pointers input support to the input manager.
  100269. * @returns the current input manager
  100270. */
  100271. addPointers(): FollowCameraInputsManager;
  100272. /**
  100273. * Add orientation input support to the input manager.
  100274. * @returns the current input manager
  100275. */
  100276. addVRDeviceOrientation(): FollowCameraInputsManager;
  100277. }
  100278. }
  100279. declare module BABYLON {
  100280. /**
  100281. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  100282. * an arc rotate version arcFollowCamera are available.
  100283. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100284. */
  100285. export class FollowCamera extends TargetCamera {
  100286. /**
  100287. * Distance the follow camera should follow an object at
  100288. */
  100289. radius: number;
  100290. /**
  100291. * Minimum allowed distance of the camera to the axis of rotation
  100292. * (The camera can not get closer).
  100293. * This can help limiting how the Camera is able to move in the scene.
  100294. */
  100295. lowerRadiusLimit: Nullable<number>;
  100296. /**
  100297. * Maximum allowed distance of the camera to the axis of rotation
  100298. * (The camera can not get further).
  100299. * This can help limiting how the Camera is able to move in the scene.
  100300. */
  100301. upperRadiusLimit: Nullable<number>;
  100302. /**
  100303. * Define a rotation offset between the camera and the object it follows
  100304. */
  100305. rotationOffset: number;
  100306. /**
  100307. * Minimum allowed angle to camera position relative to target object.
  100308. * This can help limiting how the Camera is able to move in the scene.
  100309. */
  100310. lowerRotationOffsetLimit: Nullable<number>;
  100311. /**
  100312. * Maximum allowed angle to camera position relative to target object.
  100313. * This can help limiting how the Camera is able to move in the scene.
  100314. */
  100315. upperRotationOffsetLimit: Nullable<number>;
  100316. /**
  100317. * Define a height offset between the camera and the object it follows.
  100318. * It can help following an object from the top (like a car chaing a plane)
  100319. */
  100320. heightOffset: number;
  100321. /**
  100322. * Minimum allowed height of camera position relative to target object.
  100323. * This can help limiting how the Camera is able to move in the scene.
  100324. */
  100325. lowerHeightOffsetLimit: Nullable<number>;
  100326. /**
  100327. * Maximum allowed height of camera position relative to target object.
  100328. * This can help limiting how the Camera is able to move in the scene.
  100329. */
  100330. upperHeightOffsetLimit: Nullable<number>;
  100331. /**
  100332. * Define how fast the camera can accelerate to follow it s target.
  100333. */
  100334. cameraAcceleration: number;
  100335. /**
  100336. * Define the speed limit of the camera following an object.
  100337. */
  100338. maxCameraSpeed: number;
  100339. /**
  100340. * Define the target of the camera.
  100341. */
  100342. lockedTarget: Nullable<AbstractMesh>;
  100343. /**
  100344. * Defines the input associated with the camera.
  100345. */
  100346. inputs: FollowCameraInputsManager;
  100347. /**
  100348. * Instantiates the follow camera.
  100349. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100350. * @param name Define the name of the camera in the scene
  100351. * @param position Define the position of the camera
  100352. * @param scene Define the scene the camera belong to
  100353. * @param lockedTarget Define the target of the camera
  100354. */
  100355. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  100356. private _follow;
  100357. /**
  100358. * Attached controls to the current camera.
  100359. * @param element Defines the element the controls should be listened from
  100360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100361. */
  100362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100363. /**
  100364. * Detach the current controls from the camera.
  100365. * The camera will stop reacting to inputs.
  100366. * @param element Defines the element to stop listening the inputs from
  100367. */
  100368. detachControl(element: HTMLElement): void;
  100369. /** @hidden */
  100370. _checkInputs(): void;
  100371. private _checkLimits;
  100372. /**
  100373. * Gets the camera class name.
  100374. * @returns the class name
  100375. */
  100376. getClassName(): string;
  100377. }
  100378. /**
  100379. * Arc Rotate version of the follow camera.
  100380. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  100381. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100382. */
  100383. export class ArcFollowCamera extends TargetCamera {
  100384. /** The longitudinal angle of the camera */
  100385. alpha: number;
  100386. /** The latitudinal angle of the camera */
  100387. beta: number;
  100388. /** The radius of the camera from its target */
  100389. radius: number;
  100390. /** Define the camera target (the messh it should follow) */
  100391. target: Nullable<AbstractMesh>;
  100392. private _cartesianCoordinates;
  100393. /**
  100394. * Instantiates a new ArcFollowCamera
  100395. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100396. * @param name Define the name of the camera
  100397. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  100398. * @param beta Define the rotation angle of the camera around the elevation axis
  100399. * @param radius Define the radius of the camera from its target point
  100400. * @param target Define the target of the camera
  100401. * @param scene Define the scene the camera belongs to
  100402. */
  100403. constructor(name: string,
  100404. /** The longitudinal angle of the camera */
  100405. alpha: number,
  100406. /** The latitudinal angle of the camera */
  100407. beta: number,
  100408. /** The radius of the camera from its target */
  100409. radius: number,
  100410. /** Define the camera target (the messh it should follow) */
  100411. target: Nullable<AbstractMesh>, scene: Scene);
  100412. private _follow;
  100413. /** @hidden */
  100414. _checkInputs(): void;
  100415. /**
  100416. * Returns the class name of the object.
  100417. * It is mostly used internally for serialization purposes.
  100418. */
  100419. getClassName(): string;
  100420. }
  100421. }
  100422. declare module BABYLON {
  100423. /**
  100424. * Manage the keyboard inputs to control the movement of a follow camera.
  100425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100426. */
  100427. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  100428. /**
  100429. * Defines the camera the input is attached to.
  100430. */
  100431. camera: FollowCamera;
  100432. /**
  100433. * Defines the list of key codes associated with the up action (increase heightOffset)
  100434. */
  100435. keysHeightOffsetIncr: number[];
  100436. /**
  100437. * Defines the list of key codes associated with the down action (decrease heightOffset)
  100438. */
  100439. keysHeightOffsetDecr: number[];
  100440. /**
  100441. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  100442. */
  100443. keysHeightOffsetModifierAlt: boolean;
  100444. /**
  100445. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  100446. */
  100447. keysHeightOffsetModifierCtrl: boolean;
  100448. /**
  100449. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  100450. */
  100451. keysHeightOffsetModifierShift: boolean;
  100452. /**
  100453. * Defines the list of key codes associated with the left action (increase rotationOffset)
  100454. */
  100455. keysRotationOffsetIncr: number[];
  100456. /**
  100457. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  100458. */
  100459. keysRotationOffsetDecr: number[];
  100460. /**
  100461. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  100462. */
  100463. keysRotationOffsetModifierAlt: boolean;
  100464. /**
  100465. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  100466. */
  100467. keysRotationOffsetModifierCtrl: boolean;
  100468. /**
  100469. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  100470. */
  100471. keysRotationOffsetModifierShift: boolean;
  100472. /**
  100473. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  100474. */
  100475. keysRadiusIncr: number[];
  100476. /**
  100477. * Defines the list of key codes associated with the zoom-out action (increase radius)
  100478. */
  100479. keysRadiusDecr: number[];
  100480. /**
  100481. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  100482. */
  100483. keysRadiusModifierAlt: boolean;
  100484. /**
  100485. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  100486. */
  100487. keysRadiusModifierCtrl: boolean;
  100488. /**
  100489. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  100490. */
  100491. keysRadiusModifierShift: boolean;
  100492. /**
  100493. * Defines the rate of change of heightOffset.
  100494. */
  100495. heightSensibility: number;
  100496. /**
  100497. * Defines the rate of change of rotationOffset.
  100498. */
  100499. rotationSensibility: number;
  100500. /**
  100501. * Defines the rate of change of radius.
  100502. */
  100503. radiusSensibility: number;
  100504. private _keys;
  100505. private _ctrlPressed;
  100506. private _altPressed;
  100507. private _shiftPressed;
  100508. private _onCanvasBlurObserver;
  100509. private _onKeyboardObserver;
  100510. private _engine;
  100511. private _scene;
  100512. /**
  100513. * Attach the input controls to a specific dom element to get the input from.
  100514. * @param element Defines the element the controls should be listened from
  100515. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100516. */
  100517. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100518. /**
  100519. * Detach the current controls from the specified dom element.
  100520. * @param element Defines the element to stop listening the inputs from
  100521. */
  100522. detachControl(element: Nullable<HTMLElement>): void;
  100523. /**
  100524. * Update the current camera state depending on the inputs that have been used this frame.
  100525. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100526. */
  100527. checkInputs(): void;
  100528. /**
  100529. * Gets the class name of the current input.
  100530. * @returns the class name
  100531. */
  100532. getClassName(): string;
  100533. /**
  100534. * Get the friendly name associated with the input class.
  100535. * @returns the input friendly name
  100536. */
  100537. getSimpleName(): string;
  100538. /**
  100539. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100540. * allow modification of the heightOffset value.
  100541. */
  100542. private _modifierHeightOffset;
  100543. /**
  100544. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100545. * allow modification of the rotationOffset value.
  100546. */
  100547. private _modifierRotationOffset;
  100548. /**
  100549. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100550. * allow modification of the radius value.
  100551. */
  100552. private _modifierRadius;
  100553. }
  100554. }
  100555. declare module BABYLON {
  100556. interface FreeCameraInputsManager {
  100557. /**
  100558. * @hidden
  100559. */
  100560. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  100561. /**
  100562. * Add orientation input support to the input manager.
  100563. * @returns the current input manager
  100564. */
  100565. addDeviceOrientation(): FreeCameraInputsManager;
  100566. }
  100567. /**
  100568. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  100569. * Screen rotation is taken into account.
  100570. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100571. */
  100572. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  100573. private _camera;
  100574. private _screenOrientationAngle;
  100575. private _constantTranform;
  100576. private _screenQuaternion;
  100577. private _alpha;
  100578. private _beta;
  100579. private _gamma;
  100580. /**
  100581. * Can be used to detect if a device orientation sensor is availible on a device
  100582. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  100583. * @returns a promise that will resolve on orientation change
  100584. */
  100585. static WaitForOrientationChangeAsync(timeout?: number): Promise<{}>;
  100586. /**
  100587. * @hidden
  100588. */
  100589. _onDeviceOrientationChangedObservable: Observable<void>;
  100590. /**
  100591. * Instantiates a new input
  100592. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100593. */
  100594. constructor();
  100595. /**
  100596. * Define the camera controlled by the input.
  100597. */
  100598. camera: FreeCamera;
  100599. /**
  100600. * Attach the input controls to a specific dom element to get the input from.
  100601. * @param element Defines the element the controls should be listened from
  100602. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100603. */
  100604. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100605. private _orientationChanged;
  100606. private _deviceOrientation;
  100607. /**
  100608. * Detach the current controls from the specified dom element.
  100609. * @param element Defines the element to stop listening the inputs from
  100610. */
  100611. detachControl(element: Nullable<HTMLElement>): void;
  100612. /**
  100613. * Update the current camera state depending on the inputs that have been used this frame.
  100614. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100615. */
  100616. checkInputs(): void;
  100617. /**
  100618. * Gets the class name of the current intput.
  100619. * @returns the class name
  100620. */
  100621. getClassName(): string;
  100622. /**
  100623. * Get the friendly name associated with the input class.
  100624. * @returns the input friendly name
  100625. */
  100626. getSimpleName(): string;
  100627. }
  100628. }
  100629. declare module BABYLON {
  100630. /**
  100631. * Manage the gamepad inputs to control a free camera.
  100632. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100633. */
  100634. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  100635. /**
  100636. * Define the camera the input is attached to.
  100637. */
  100638. camera: FreeCamera;
  100639. /**
  100640. * Define the Gamepad controlling the input
  100641. */
  100642. gamepad: Nullable<Gamepad>;
  100643. /**
  100644. * Defines the gamepad rotation sensiblity.
  100645. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100646. */
  100647. gamepadAngularSensibility: number;
  100648. /**
  100649. * Defines the gamepad move sensiblity.
  100650. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100651. */
  100652. gamepadMoveSensibility: number;
  100653. private _onGamepadConnectedObserver;
  100654. private _onGamepadDisconnectedObserver;
  100655. private _cameraTransform;
  100656. private _deltaTransform;
  100657. private _vector3;
  100658. private _vector2;
  100659. /**
  100660. * Attach the input controls to a specific dom element to get the input from.
  100661. * @param element Defines the element the controls should be listened from
  100662. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100663. */
  100664. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100665. /**
  100666. * Detach the current controls from the specified dom element.
  100667. * @param element Defines the element to stop listening the inputs from
  100668. */
  100669. detachControl(element: Nullable<HTMLElement>): void;
  100670. /**
  100671. * Update the current camera state depending on the inputs that have been used this frame.
  100672. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100673. */
  100674. checkInputs(): void;
  100675. /**
  100676. * Gets the class name of the current intput.
  100677. * @returns the class name
  100678. */
  100679. getClassName(): string;
  100680. /**
  100681. * Get the friendly name associated with the input class.
  100682. * @returns the input friendly name
  100683. */
  100684. getSimpleName(): string;
  100685. }
  100686. }
  100687. declare module BABYLON {
  100688. /**
  100689. * Defines the potential axis of a Joystick
  100690. */
  100691. export enum JoystickAxis {
  100692. /** X axis */
  100693. X = 0,
  100694. /** Y axis */
  100695. Y = 1,
  100696. /** Z axis */
  100697. Z = 2
  100698. }
  100699. /**
  100700. * Class used to define virtual joystick (used in touch mode)
  100701. */
  100702. export class VirtualJoystick {
  100703. /**
  100704. * Gets or sets a boolean indicating that left and right values must be inverted
  100705. */
  100706. reverseLeftRight: boolean;
  100707. /**
  100708. * Gets or sets a boolean indicating that up and down values must be inverted
  100709. */
  100710. reverseUpDown: boolean;
  100711. /**
  100712. * Gets the offset value for the position (ie. the change of the position value)
  100713. */
  100714. deltaPosition: Vector3;
  100715. /**
  100716. * Gets a boolean indicating if the virtual joystick was pressed
  100717. */
  100718. pressed: boolean;
  100719. /**
  100720. * Canvas the virtual joystick will render onto, default z-index of this is 5
  100721. */
  100722. static Canvas: Nullable<HTMLCanvasElement>;
  100723. private static _globalJoystickIndex;
  100724. private static vjCanvasContext;
  100725. private static vjCanvasWidth;
  100726. private static vjCanvasHeight;
  100727. private static halfWidth;
  100728. private _action;
  100729. private _axisTargetedByLeftAndRight;
  100730. private _axisTargetedByUpAndDown;
  100731. private _joystickSensibility;
  100732. private _inversedSensibility;
  100733. private _joystickPointerID;
  100734. private _joystickColor;
  100735. private _joystickPointerPos;
  100736. private _joystickPreviousPointerPos;
  100737. private _joystickPointerStartPos;
  100738. private _deltaJoystickVector;
  100739. private _leftJoystick;
  100740. private _touches;
  100741. private _onPointerDownHandlerRef;
  100742. private _onPointerMoveHandlerRef;
  100743. private _onPointerUpHandlerRef;
  100744. private _onResize;
  100745. /**
  100746. * Creates a new virtual joystick
  100747. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100748. */
  100749. constructor(leftJoystick?: boolean);
  100750. /**
  100751. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100752. * @param newJoystickSensibility defines the new sensibility
  100753. */
  100754. setJoystickSensibility(newJoystickSensibility: number): void;
  100755. private _onPointerDown;
  100756. private _onPointerMove;
  100757. private _onPointerUp;
  100758. /**
  100759. * Change the color of the virtual joystick
  100760. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100761. */
  100762. setJoystickColor(newColor: string): void;
  100763. /**
  100764. * Defines a callback to call when the joystick is touched
  100765. * @param action defines the callback
  100766. */
  100767. setActionOnTouch(action: () => any): void;
  100768. /**
  100769. * Defines which axis you'd like to control for left & right
  100770. * @param axis defines the axis to use
  100771. */
  100772. setAxisForLeftRight(axis: JoystickAxis): void;
  100773. /**
  100774. * Defines which axis you'd like to control for up & down
  100775. * @param axis defines the axis to use
  100776. */
  100777. setAxisForUpDown(axis: JoystickAxis): void;
  100778. private _drawVirtualJoystick;
  100779. /**
  100780. * Release internal HTML canvas
  100781. */
  100782. releaseCanvas(): void;
  100783. }
  100784. }
  100785. declare module BABYLON {
  100786. interface FreeCameraInputsManager {
  100787. /**
  100788. * Add virtual joystick input support to the input manager.
  100789. * @returns the current input manager
  100790. */
  100791. addVirtualJoystick(): FreeCameraInputsManager;
  100792. }
  100793. /**
  100794. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  100795. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100796. */
  100797. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  100798. /**
  100799. * Defines the camera the input is attached to.
  100800. */
  100801. camera: FreeCamera;
  100802. private _leftjoystick;
  100803. private _rightjoystick;
  100804. /**
  100805. * Gets the left stick of the virtual joystick.
  100806. * @returns The virtual Joystick
  100807. */
  100808. getLeftJoystick(): VirtualJoystick;
  100809. /**
  100810. * Gets the right stick of the virtual joystick.
  100811. * @returns The virtual Joystick
  100812. */
  100813. getRightJoystick(): VirtualJoystick;
  100814. /**
  100815. * Update the current camera state depending on the inputs that have been used this frame.
  100816. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100817. */
  100818. checkInputs(): void;
  100819. /**
  100820. * Attach the input controls to a specific dom element to get the input from.
  100821. * @param element Defines the element the controls should be listened from
  100822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100823. */
  100824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100825. /**
  100826. * Detach the current controls from the specified dom element.
  100827. * @param element Defines the element to stop listening the inputs from
  100828. */
  100829. detachControl(element: Nullable<HTMLElement>): void;
  100830. /**
  100831. * Gets the class name of the current intput.
  100832. * @returns the class name
  100833. */
  100834. getClassName(): string;
  100835. /**
  100836. * Get the friendly name associated with the input class.
  100837. * @returns the input friendly name
  100838. */
  100839. getSimpleName(): string;
  100840. }
  100841. }
  100842. declare module BABYLON {
  100843. /**
  100844. * This represents a FPS type of camera controlled by touch.
  100845. * This is like a universal camera minus the Gamepad controls.
  100846. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100847. */
  100848. export class TouchCamera extends FreeCamera {
  100849. /**
  100850. * Defines the touch sensibility for rotation.
  100851. * The higher the faster.
  100852. */
  100853. touchAngularSensibility: number;
  100854. /**
  100855. * Defines the touch sensibility for move.
  100856. * The higher the faster.
  100857. */
  100858. touchMoveSensibility: number;
  100859. /**
  100860. * Instantiates a new touch camera.
  100861. * This represents a FPS type of camera controlled by touch.
  100862. * This is like a universal camera minus the Gamepad controls.
  100863. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100864. * @param name Define the name of the camera in the scene
  100865. * @param position Define the start position of the camera in the scene
  100866. * @param scene Define the scene the camera belongs to
  100867. */
  100868. constructor(name: string, position: Vector3, scene: Scene);
  100869. /**
  100870. * Gets the current object class name.
  100871. * @return the class name
  100872. */
  100873. getClassName(): string;
  100874. /** @hidden */
  100875. _setupInputs(): void;
  100876. }
  100877. }
  100878. declare module BABYLON {
  100879. /**
  100880. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100881. * being tilted forward or back and left or right.
  100882. */
  100883. export class DeviceOrientationCamera extends FreeCamera {
  100884. private _initialQuaternion;
  100885. private _quaternionCache;
  100886. private _tmpDragQuaternion;
  100887. /**
  100888. * Creates a new device orientation camera
  100889. * @param name The name of the camera
  100890. * @param position The start position camera
  100891. * @param scene The scene the camera belongs to
  100892. */
  100893. constructor(name: string, position: Vector3, scene: Scene);
  100894. /**
  100895. * @hidden
  100896. * Disabled pointer input on first orientation sensor update (Default: true)
  100897. */
  100898. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100899. private _dragFactor;
  100900. /**
  100901. * Enabled turning on the y axis when the orientation sensor is active
  100902. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100903. */
  100904. enableHorizontalDragging(dragFactor?: number): void;
  100905. /**
  100906. * Gets the current instance class name ("DeviceOrientationCamera").
  100907. * This helps avoiding instanceof at run time.
  100908. * @returns the class name
  100909. */
  100910. getClassName(): string;
  100911. /**
  100912. * @hidden
  100913. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100914. */
  100915. _checkInputs(): void;
  100916. /**
  100917. * Reset the camera to its default orientation on the specified axis only.
  100918. * @param axis The axis to reset
  100919. */
  100920. resetToCurrentRotation(axis?: Axis): void;
  100921. }
  100922. }
  100923. declare module BABYLON {
  100924. /**
  100925. * Defines supported buttons for XBox360 compatible gamepads
  100926. */
  100927. export enum Xbox360Button {
  100928. /** A */
  100929. A = 0,
  100930. /** B */
  100931. B = 1,
  100932. /** X */
  100933. X = 2,
  100934. /** Y */
  100935. Y = 3,
  100936. /** Start */
  100937. Start = 4,
  100938. /** Back */
  100939. Back = 5,
  100940. /** Left button */
  100941. LB = 6,
  100942. /** Right button */
  100943. RB = 7,
  100944. /** Left stick */
  100945. LeftStick = 8,
  100946. /** Right stick */
  100947. RightStick = 9
  100948. }
  100949. /** Defines values for XBox360 DPad */
  100950. export enum Xbox360Dpad {
  100951. /** Up */
  100952. Up = 0,
  100953. /** Down */
  100954. Down = 1,
  100955. /** Left */
  100956. Left = 2,
  100957. /** Right */
  100958. Right = 3
  100959. }
  100960. /**
  100961. * Defines a XBox360 gamepad
  100962. */
  100963. export class Xbox360Pad extends Gamepad {
  100964. private _leftTrigger;
  100965. private _rightTrigger;
  100966. private _onlefttriggerchanged;
  100967. private _onrighttriggerchanged;
  100968. private _onbuttondown;
  100969. private _onbuttonup;
  100970. private _ondpaddown;
  100971. private _ondpadup;
  100972. /** Observable raised when a button is pressed */
  100973. onButtonDownObservable: Observable<Xbox360Button>;
  100974. /** Observable raised when a button is released */
  100975. onButtonUpObservable: Observable<Xbox360Button>;
  100976. /** Observable raised when a pad is pressed */
  100977. onPadDownObservable: Observable<Xbox360Dpad>;
  100978. /** Observable raised when a pad is released */
  100979. onPadUpObservable: Observable<Xbox360Dpad>;
  100980. private _buttonA;
  100981. private _buttonB;
  100982. private _buttonX;
  100983. private _buttonY;
  100984. private _buttonBack;
  100985. private _buttonStart;
  100986. private _buttonLB;
  100987. private _buttonRB;
  100988. private _buttonLeftStick;
  100989. private _buttonRightStick;
  100990. private _dPadUp;
  100991. private _dPadDown;
  100992. private _dPadLeft;
  100993. private _dPadRight;
  100994. private _isXboxOnePad;
  100995. /**
  100996. * Creates a new XBox360 gamepad object
  100997. * @param id defines the id of this gamepad
  100998. * @param index defines its index
  100999. * @param gamepad defines the internal HTML gamepad object
  101000. * @param xboxOne defines if it is a XBox One gamepad
  101001. */
  101002. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  101003. /**
  101004. * Defines the callback to call when left trigger is pressed
  101005. * @param callback defines the callback to use
  101006. */
  101007. onlefttriggerchanged(callback: (value: number) => void): void;
  101008. /**
  101009. * Defines the callback to call when right trigger is pressed
  101010. * @param callback defines the callback to use
  101011. */
  101012. onrighttriggerchanged(callback: (value: number) => void): void;
  101013. /**
  101014. * Gets the left trigger value
  101015. */
  101016. /**
  101017. * Sets the left trigger value
  101018. */
  101019. leftTrigger: number;
  101020. /**
  101021. * Gets the right trigger value
  101022. */
  101023. /**
  101024. * Sets the right trigger value
  101025. */
  101026. rightTrigger: number;
  101027. /**
  101028. * Defines the callback to call when a button is pressed
  101029. * @param callback defines the callback to use
  101030. */
  101031. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  101032. /**
  101033. * Defines the callback to call when a button is released
  101034. * @param callback defines the callback to use
  101035. */
  101036. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  101037. /**
  101038. * Defines the callback to call when a pad is pressed
  101039. * @param callback defines the callback to use
  101040. */
  101041. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  101042. /**
  101043. * Defines the callback to call when a pad is released
  101044. * @param callback defines the callback to use
  101045. */
  101046. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  101047. private _setButtonValue;
  101048. private _setDPadValue;
  101049. /**
  101050. * Gets the value of the `A` button
  101051. */
  101052. /**
  101053. * Sets the value of the `A` button
  101054. */
  101055. buttonA: number;
  101056. /**
  101057. * Gets the value of the `B` button
  101058. */
  101059. /**
  101060. * Sets the value of the `B` button
  101061. */
  101062. buttonB: number;
  101063. /**
  101064. * Gets the value of the `X` button
  101065. */
  101066. /**
  101067. * Sets the value of the `X` button
  101068. */
  101069. buttonX: number;
  101070. /**
  101071. * Gets the value of the `Y` button
  101072. */
  101073. /**
  101074. * Sets the value of the `Y` button
  101075. */
  101076. buttonY: number;
  101077. /**
  101078. * Gets the value of the `Start` button
  101079. */
  101080. /**
  101081. * Sets the value of the `Start` button
  101082. */
  101083. buttonStart: number;
  101084. /**
  101085. * Gets the value of the `Back` button
  101086. */
  101087. /**
  101088. * Sets the value of the `Back` button
  101089. */
  101090. buttonBack: number;
  101091. /**
  101092. * Gets the value of the `Left` button
  101093. */
  101094. /**
  101095. * Sets the value of the `Left` button
  101096. */
  101097. buttonLB: number;
  101098. /**
  101099. * Gets the value of the `Right` button
  101100. */
  101101. /**
  101102. * Sets the value of the `Right` button
  101103. */
  101104. buttonRB: number;
  101105. /**
  101106. * Gets the value of the Left joystick
  101107. */
  101108. /**
  101109. * Sets the value of the Left joystick
  101110. */
  101111. buttonLeftStick: number;
  101112. /**
  101113. * Gets the value of the Right joystick
  101114. */
  101115. /**
  101116. * Sets the value of the Right joystick
  101117. */
  101118. buttonRightStick: number;
  101119. /**
  101120. * Gets the value of D-pad up
  101121. */
  101122. /**
  101123. * Sets the value of D-pad up
  101124. */
  101125. dPadUp: number;
  101126. /**
  101127. * Gets the value of D-pad down
  101128. */
  101129. /**
  101130. * Sets the value of D-pad down
  101131. */
  101132. dPadDown: number;
  101133. /**
  101134. * Gets the value of D-pad left
  101135. */
  101136. /**
  101137. * Sets the value of D-pad left
  101138. */
  101139. dPadLeft: number;
  101140. /**
  101141. * Gets the value of D-pad right
  101142. */
  101143. /**
  101144. * Sets the value of D-pad right
  101145. */
  101146. dPadRight: number;
  101147. /**
  101148. * Force the gamepad to synchronize with device values
  101149. */
  101150. update(): void;
  101151. /**
  101152. * Disposes the gamepad
  101153. */
  101154. dispose(): void;
  101155. }
  101156. }
  101157. declare module BABYLON {
  101158. /**
  101159. * Manager for handling gamepads
  101160. */
  101161. export class GamepadManager {
  101162. private _scene?;
  101163. private _babylonGamepads;
  101164. private _oneGamepadConnected;
  101165. /** @hidden */
  101166. _isMonitoring: boolean;
  101167. private _gamepadEventSupported;
  101168. private _gamepadSupport;
  101169. /**
  101170. * observable to be triggered when the gamepad controller has been connected
  101171. */
  101172. onGamepadConnectedObservable: Observable<Gamepad>;
  101173. /**
  101174. * observable to be triggered when the gamepad controller has been disconnected
  101175. */
  101176. onGamepadDisconnectedObservable: Observable<Gamepad>;
  101177. private _onGamepadConnectedEvent;
  101178. private _onGamepadDisconnectedEvent;
  101179. /**
  101180. * Initializes the gamepad manager
  101181. * @param _scene BabylonJS scene
  101182. */
  101183. constructor(_scene?: Scene | undefined);
  101184. /**
  101185. * The gamepads in the game pad manager
  101186. */
  101187. readonly gamepads: Gamepad[];
  101188. /**
  101189. * Get the gamepad controllers based on type
  101190. * @param type The type of gamepad controller
  101191. * @returns Nullable gamepad
  101192. */
  101193. getGamepadByType(type?: number): Nullable<Gamepad>;
  101194. /**
  101195. * Disposes the gamepad manager
  101196. */
  101197. dispose(): void;
  101198. private _addNewGamepad;
  101199. private _startMonitoringGamepads;
  101200. private _stopMonitoringGamepads;
  101201. /** @hidden */
  101202. _checkGamepadsStatus(): void;
  101203. private _updateGamepadObjects;
  101204. }
  101205. }
  101206. declare module BABYLON {
  101207. interface Scene {
  101208. /** @hidden */
  101209. _gamepadManager: Nullable<GamepadManager>;
  101210. /**
  101211. * Gets the gamepad manager associated with the scene
  101212. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  101213. */
  101214. gamepadManager: GamepadManager;
  101215. }
  101216. /**
  101217. * Interface representing a free camera inputs manager
  101218. */
  101219. interface FreeCameraInputsManager {
  101220. /**
  101221. * Adds gamepad input support to the FreeCameraInputsManager.
  101222. * @returns the FreeCameraInputsManager
  101223. */
  101224. addGamepad(): FreeCameraInputsManager;
  101225. }
  101226. /**
  101227. * Interface representing an arc rotate camera inputs manager
  101228. */
  101229. interface ArcRotateCameraInputsManager {
  101230. /**
  101231. * Adds gamepad input support to the ArcRotateCamera InputManager.
  101232. * @returns the camera inputs manager
  101233. */
  101234. addGamepad(): ArcRotateCameraInputsManager;
  101235. }
  101236. /**
  101237. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  101238. */
  101239. export class GamepadSystemSceneComponent implements ISceneComponent {
  101240. /**
  101241. * The component name helpfull to identify the component in the list of scene components.
  101242. */
  101243. readonly name: string;
  101244. /**
  101245. * The scene the component belongs to.
  101246. */
  101247. scene: Scene;
  101248. /**
  101249. * Creates a new instance of the component for the given scene
  101250. * @param scene Defines the scene to register the component in
  101251. */
  101252. constructor(scene: Scene);
  101253. /**
  101254. * Registers the component in a given scene
  101255. */
  101256. register(): void;
  101257. /**
  101258. * Rebuilds the elements related to this component in case of
  101259. * context lost for instance.
  101260. */
  101261. rebuild(): void;
  101262. /**
  101263. * Disposes the component and the associated ressources
  101264. */
  101265. dispose(): void;
  101266. private _beforeCameraUpdate;
  101267. }
  101268. }
  101269. declare module BABYLON {
  101270. /**
  101271. * 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,
  101272. * which still works and will still be found in many Playgrounds.
  101273. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101274. */
  101275. export class UniversalCamera extends TouchCamera {
  101276. /**
  101277. * Defines the gamepad rotation sensiblity.
  101278. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101279. */
  101280. gamepadAngularSensibility: number;
  101281. /**
  101282. * Defines the gamepad move sensiblity.
  101283. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101284. */
  101285. gamepadMoveSensibility: number;
  101286. /**
  101287. * 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,
  101288. * which still works and will still be found in many Playgrounds.
  101289. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101290. * @param name Define the name of the camera in the scene
  101291. * @param position Define the start position of the camera in the scene
  101292. * @param scene Define the scene the camera belongs to
  101293. */
  101294. constructor(name: string, position: Vector3, scene: Scene);
  101295. /**
  101296. * Gets the current object class name.
  101297. * @return the class name
  101298. */
  101299. getClassName(): string;
  101300. }
  101301. }
  101302. declare module BABYLON {
  101303. /**
  101304. * This represents a FPS type of camera. This is only here for back compat purpose.
  101305. * Please use the UniversalCamera instead as both are identical.
  101306. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101307. */
  101308. export class GamepadCamera extends UniversalCamera {
  101309. /**
  101310. * Instantiates a new Gamepad Camera
  101311. * This represents a FPS type of camera. This is only here for back compat purpose.
  101312. * Please use the UniversalCamera instead as both are identical.
  101313. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101314. * @param name Define the name of the camera in the scene
  101315. * @param position Define the start position of the camera in the scene
  101316. * @param scene Define the scene the camera belongs to
  101317. */
  101318. constructor(name: string, position: Vector3, scene: Scene);
  101319. /**
  101320. * Gets the current object class name.
  101321. * @return the class name
  101322. */
  101323. getClassName(): string;
  101324. }
  101325. }
  101326. declare module BABYLON {
  101327. /** @hidden */
  101328. export var passPixelShader: {
  101329. name: string;
  101330. shader: string;
  101331. };
  101332. }
  101333. declare module BABYLON {
  101334. /** @hidden */
  101335. export var passCubePixelShader: {
  101336. name: string;
  101337. shader: string;
  101338. };
  101339. }
  101340. declare module BABYLON {
  101341. /**
  101342. * PassPostProcess which produces an output the same as it's input
  101343. */
  101344. export class PassPostProcess extends PostProcess {
  101345. /**
  101346. * Creates the PassPostProcess
  101347. * @param name The name of the effect.
  101348. * @param options The required width/height ratio to downsize to before computing the render pass.
  101349. * @param camera The camera to apply the render pass to.
  101350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101351. * @param engine The engine which the post process will be applied. (default: current engine)
  101352. * @param reusable If the post process can be reused on the same frame. (default: false)
  101353. * @param textureType The type of texture to be used when performing the post processing.
  101354. * @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)
  101355. */
  101356. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101357. }
  101358. /**
  101359. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  101360. */
  101361. export class PassCubePostProcess extends PostProcess {
  101362. private _face;
  101363. /**
  101364. * Gets or sets the cube face to display.
  101365. * * 0 is +X
  101366. * * 1 is -X
  101367. * * 2 is +Y
  101368. * * 3 is -Y
  101369. * * 4 is +Z
  101370. * * 5 is -Z
  101371. */
  101372. face: number;
  101373. /**
  101374. * Creates the PassCubePostProcess
  101375. * @param name The name of the effect.
  101376. * @param options The required width/height ratio to downsize to before computing the render pass.
  101377. * @param camera The camera to apply the render pass to.
  101378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101379. * @param engine The engine which the post process will be applied. (default: current engine)
  101380. * @param reusable If the post process can be reused on the same frame. (default: false)
  101381. * @param textureType The type of texture to be used when performing the post processing.
  101382. * @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)
  101383. */
  101384. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101385. }
  101386. }
  101387. declare module BABYLON {
  101388. /** @hidden */
  101389. export var anaglyphPixelShader: {
  101390. name: string;
  101391. shader: string;
  101392. };
  101393. }
  101394. declare module BABYLON {
  101395. /**
  101396. * Postprocess used to generate anaglyphic rendering
  101397. */
  101398. export class AnaglyphPostProcess extends PostProcess {
  101399. private _passedProcess;
  101400. /**
  101401. * Creates a new AnaglyphPostProcess
  101402. * @param name defines postprocess name
  101403. * @param options defines creation options or target ratio scale
  101404. * @param rigCameras defines cameras using this postprocess
  101405. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  101406. * @param engine defines hosting engine
  101407. * @param reusable defines if the postprocess will be reused multiple times per frame
  101408. */
  101409. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  101410. }
  101411. }
  101412. declare module BABYLON {
  101413. /**
  101414. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  101415. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101416. */
  101417. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  101418. /**
  101419. * Creates a new AnaglyphArcRotateCamera
  101420. * @param name defines camera name
  101421. * @param alpha defines alpha angle (in radians)
  101422. * @param beta defines beta angle (in radians)
  101423. * @param radius defines radius
  101424. * @param target defines camera target
  101425. * @param interaxialDistance defines distance between each color axis
  101426. * @param scene defines the hosting scene
  101427. */
  101428. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  101429. /**
  101430. * Gets camera class name
  101431. * @returns AnaglyphArcRotateCamera
  101432. */
  101433. getClassName(): string;
  101434. }
  101435. }
  101436. declare module BABYLON {
  101437. /**
  101438. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  101439. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101440. */
  101441. export class AnaglyphFreeCamera extends FreeCamera {
  101442. /**
  101443. * Creates a new AnaglyphFreeCamera
  101444. * @param name defines camera name
  101445. * @param position defines initial position
  101446. * @param interaxialDistance defines distance between each color axis
  101447. * @param scene defines the hosting scene
  101448. */
  101449. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101450. /**
  101451. * Gets camera class name
  101452. * @returns AnaglyphFreeCamera
  101453. */
  101454. getClassName(): string;
  101455. }
  101456. }
  101457. declare module BABYLON {
  101458. /**
  101459. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  101460. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101461. */
  101462. export class AnaglyphGamepadCamera extends GamepadCamera {
  101463. /**
  101464. * Creates a new AnaglyphGamepadCamera
  101465. * @param name defines camera name
  101466. * @param position defines initial position
  101467. * @param interaxialDistance defines distance between each color axis
  101468. * @param scene defines the hosting scene
  101469. */
  101470. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101471. /**
  101472. * Gets camera class name
  101473. * @returns AnaglyphGamepadCamera
  101474. */
  101475. getClassName(): string;
  101476. }
  101477. }
  101478. declare module BABYLON {
  101479. /**
  101480. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  101481. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101482. */
  101483. export class AnaglyphUniversalCamera extends UniversalCamera {
  101484. /**
  101485. * Creates a new AnaglyphUniversalCamera
  101486. * @param name defines camera name
  101487. * @param position defines initial position
  101488. * @param interaxialDistance defines distance between each color axis
  101489. * @param scene defines the hosting scene
  101490. */
  101491. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101492. /**
  101493. * Gets camera class name
  101494. * @returns AnaglyphUniversalCamera
  101495. */
  101496. getClassName(): string;
  101497. }
  101498. }
  101499. declare module BABYLON {
  101500. /** @hidden */
  101501. export var stereoscopicInterlacePixelShader: {
  101502. name: string;
  101503. shader: string;
  101504. };
  101505. }
  101506. declare module BABYLON {
  101507. /**
  101508. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  101509. */
  101510. export class StereoscopicInterlacePostProcess extends PostProcess {
  101511. private _stepSize;
  101512. private _passedProcess;
  101513. /**
  101514. * Initializes a StereoscopicInterlacePostProcess
  101515. * @param name The name of the effect.
  101516. * @param rigCameras The rig cameras to be appled to the post process
  101517. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  101518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101519. * @param engine The engine which the post process will be applied. (default: current engine)
  101520. * @param reusable If the post process can be reused on the same frame. (default: false)
  101521. */
  101522. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  101523. }
  101524. }
  101525. declare module BABYLON {
  101526. /**
  101527. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  101528. * @see http://doc.babylonjs.com/features/cameras
  101529. */
  101530. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  101531. /**
  101532. * Creates a new StereoscopicArcRotateCamera
  101533. * @param name defines camera name
  101534. * @param alpha defines alpha angle (in radians)
  101535. * @param beta defines beta angle (in radians)
  101536. * @param radius defines radius
  101537. * @param target defines camera target
  101538. * @param interaxialDistance defines distance between each color axis
  101539. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101540. * @param scene defines the hosting scene
  101541. */
  101542. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101543. /**
  101544. * Gets camera class name
  101545. * @returns StereoscopicArcRotateCamera
  101546. */
  101547. getClassName(): string;
  101548. }
  101549. }
  101550. declare module BABYLON {
  101551. /**
  101552. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  101553. * @see http://doc.babylonjs.com/features/cameras
  101554. */
  101555. export class StereoscopicFreeCamera extends FreeCamera {
  101556. /**
  101557. * Creates a new StereoscopicFreeCamera
  101558. * @param name defines camera name
  101559. * @param position defines initial position
  101560. * @param interaxialDistance defines distance between each color axis
  101561. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101562. * @param scene defines the hosting scene
  101563. */
  101564. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101565. /**
  101566. * Gets camera class name
  101567. * @returns StereoscopicFreeCamera
  101568. */
  101569. getClassName(): string;
  101570. }
  101571. }
  101572. declare module BABYLON {
  101573. /**
  101574. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  101575. * @see http://doc.babylonjs.com/features/cameras
  101576. */
  101577. export class StereoscopicGamepadCamera extends GamepadCamera {
  101578. /**
  101579. * Creates a new StereoscopicGamepadCamera
  101580. * @param name defines camera name
  101581. * @param position defines initial position
  101582. * @param interaxialDistance defines distance between each color axis
  101583. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101584. * @param scene defines the hosting scene
  101585. */
  101586. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101587. /**
  101588. * Gets camera class name
  101589. * @returns StereoscopicGamepadCamera
  101590. */
  101591. getClassName(): string;
  101592. }
  101593. }
  101594. declare module BABYLON {
  101595. /**
  101596. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  101597. * @see http://doc.babylonjs.com/features/cameras
  101598. */
  101599. export class StereoscopicUniversalCamera extends UniversalCamera {
  101600. /**
  101601. * Creates a new StereoscopicUniversalCamera
  101602. * @param name defines camera name
  101603. * @param position defines initial position
  101604. * @param interaxialDistance defines distance between each color axis
  101605. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101606. * @param scene defines the hosting scene
  101607. */
  101608. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101609. /**
  101610. * Gets camera class name
  101611. * @returns StereoscopicUniversalCamera
  101612. */
  101613. getClassName(): string;
  101614. }
  101615. }
  101616. declare module BABYLON {
  101617. /**
  101618. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  101619. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101620. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101621. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101622. */
  101623. export class VirtualJoysticksCamera extends FreeCamera {
  101624. /**
  101625. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  101626. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101627. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101628. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101629. * @param name Define the name of the camera in the scene
  101630. * @param position Define the start position of the camera in the scene
  101631. * @param scene Define the scene the camera belongs to
  101632. */
  101633. constructor(name: string, position: Vector3, scene: Scene);
  101634. /**
  101635. * Gets the current object class name.
  101636. * @return the class name
  101637. */
  101638. getClassName(): string;
  101639. }
  101640. }
  101641. declare module BABYLON {
  101642. /**
  101643. * This represents all the required metrics to create a VR camera.
  101644. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  101645. */
  101646. export class VRCameraMetrics {
  101647. /**
  101648. * Define the horizontal resolution off the screen.
  101649. */
  101650. hResolution: number;
  101651. /**
  101652. * Define the vertical resolution off the screen.
  101653. */
  101654. vResolution: number;
  101655. /**
  101656. * Define the horizontal screen size.
  101657. */
  101658. hScreenSize: number;
  101659. /**
  101660. * Define the vertical screen size.
  101661. */
  101662. vScreenSize: number;
  101663. /**
  101664. * Define the vertical screen center position.
  101665. */
  101666. vScreenCenter: number;
  101667. /**
  101668. * Define the distance of the eyes to the screen.
  101669. */
  101670. eyeToScreenDistance: number;
  101671. /**
  101672. * Define the distance between both lenses
  101673. */
  101674. lensSeparationDistance: number;
  101675. /**
  101676. * Define the distance between both viewer's eyes.
  101677. */
  101678. interpupillaryDistance: number;
  101679. /**
  101680. * Define the distortion factor of the VR postprocess.
  101681. * Please, touch with care.
  101682. */
  101683. distortionK: number[];
  101684. /**
  101685. * Define the chromatic aberration correction factors for the VR post process.
  101686. */
  101687. chromaAbCorrection: number[];
  101688. /**
  101689. * Define the scale factor of the post process.
  101690. * The smaller the better but the slower.
  101691. */
  101692. postProcessScaleFactor: number;
  101693. /**
  101694. * Define an offset for the lens center.
  101695. */
  101696. lensCenterOffset: number;
  101697. /**
  101698. * Define if the current vr camera should compensate the distortion of the lense or not.
  101699. */
  101700. compensateDistortion: boolean;
  101701. /**
  101702. * Defines if multiview should be enabled when rendering (Default: false)
  101703. */
  101704. multiviewEnabled: boolean;
  101705. /**
  101706. * Gets the rendering aspect ratio based on the provided resolutions.
  101707. */
  101708. readonly aspectRatio: number;
  101709. /**
  101710. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  101711. */
  101712. readonly aspectRatioFov: number;
  101713. /**
  101714. * @hidden
  101715. */
  101716. readonly leftHMatrix: Matrix;
  101717. /**
  101718. * @hidden
  101719. */
  101720. readonly rightHMatrix: Matrix;
  101721. /**
  101722. * @hidden
  101723. */
  101724. readonly leftPreViewMatrix: Matrix;
  101725. /**
  101726. * @hidden
  101727. */
  101728. readonly rightPreViewMatrix: Matrix;
  101729. /**
  101730. * Get the default VRMetrics based on the most generic setup.
  101731. * @returns the default vr metrics
  101732. */
  101733. static GetDefault(): VRCameraMetrics;
  101734. }
  101735. }
  101736. declare module BABYLON {
  101737. /** @hidden */
  101738. export var vrDistortionCorrectionPixelShader: {
  101739. name: string;
  101740. shader: string;
  101741. };
  101742. }
  101743. declare module BABYLON {
  101744. /**
  101745. * VRDistortionCorrectionPostProcess used for mobile VR
  101746. */
  101747. export class VRDistortionCorrectionPostProcess extends PostProcess {
  101748. private _isRightEye;
  101749. private _distortionFactors;
  101750. private _postProcessScaleFactor;
  101751. private _lensCenterOffset;
  101752. private _scaleIn;
  101753. private _scaleFactor;
  101754. private _lensCenter;
  101755. /**
  101756. * Initializes the VRDistortionCorrectionPostProcess
  101757. * @param name The name of the effect.
  101758. * @param camera The camera to apply the render pass to.
  101759. * @param isRightEye If this is for the right eye distortion
  101760. * @param vrMetrics All the required metrics for the VR camera
  101761. */
  101762. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  101763. }
  101764. }
  101765. declare module BABYLON {
  101766. /**
  101767. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  101768. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101769. */
  101770. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  101771. /**
  101772. * Creates a new VRDeviceOrientationArcRotateCamera
  101773. * @param name defines camera name
  101774. * @param alpha defines the camera rotation along the logitudinal axis
  101775. * @param beta defines the camera rotation along the latitudinal axis
  101776. * @param radius defines the camera distance from its target
  101777. * @param target defines the camera target
  101778. * @param scene defines the scene the camera belongs to
  101779. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101780. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101781. */
  101782. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101783. /**
  101784. * Gets camera class name
  101785. * @returns VRDeviceOrientationArcRotateCamera
  101786. */
  101787. getClassName(): string;
  101788. }
  101789. }
  101790. declare module BABYLON {
  101791. /**
  101792. * Camera used to simulate VR rendering (based on FreeCamera)
  101793. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101794. */
  101795. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  101796. /**
  101797. * Creates a new VRDeviceOrientationFreeCamera
  101798. * @param name defines camera name
  101799. * @param position defines the start position of the camera
  101800. * @param scene defines the scene the camera belongs to
  101801. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101802. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101803. */
  101804. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101805. /**
  101806. * Gets camera class name
  101807. * @returns VRDeviceOrientationFreeCamera
  101808. */
  101809. getClassName(): string;
  101810. }
  101811. }
  101812. declare module BABYLON {
  101813. /**
  101814. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  101815. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101816. */
  101817. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  101818. /**
  101819. * Creates a new VRDeviceOrientationGamepadCamera
  101820. * @param name defines camera name
  101821. * @param position defines the start position of the camera
  101822. * @param scene defines the scene the camera belongs to
  101823. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101824. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101825. */
  101826. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101827. /**
  101828. * Gets camera class name
  101829. * @returns VRDeviceOrientationGamepadCamera
  101830. */
  101831. getClassName(): string;
  101832. }
  101833. }
  101834. declare module BABYLON {
  101835. /**
  101836. * Base class of materials working in push mode in babylon JS
  101837. * @hidden
  101838. */
  101839. export class PushMaterial extends Material {
  101840. protected _activeEffect: Effect;
  101841. protected _normalMatrix: Matrix;
  101842. /**
  101843. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101844. * This means that the material can keep using a previous shader while a new one is being compiled.
  101845. * This is mostly used when shader parallel compilation is supported (true by default)
  101846. */
  101847. allowShaderHotSwapping: boolean;
  101848. constructor(name: string, scene: Scene);
  101849. getEffect(): Effect;
  101850. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101851. /**
  101852. * Binds the given world matrix to the active effect
  101853. *
  101854. * @param world the matrix to bind
  101855. */
  101856. bindOnlyWorldMatrix(world: Matrix): void;
  101857. /**
  101858. * Binds the given normal matrix to the active effect
  101859. *
  101860. * @param normalMatrix the matrix to bind
  101861. */
  101862. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101863. bind(world: Matrix, mesh?: Mesh): void;
  101864. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101865. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101866. }
  101867. }
  101868. declare module BABYLON {
  101869. /**
  101870. * This groups all the flags used to control the materials channel.
  101871. */
  101872. export class MaterialFlags {
  101873. private static _DiffuseTextureEnabled;
  101874. /**
  101875. * Are diffuse textures enabled in the application.
  101876. */
  101877. static DiffuseTextureEnabled: boolean;
  101878. private static _AmbientTextureEnabled;
  101879. /**
  101880. * Are ambient textures enabled in the application.
  101881. */
  101882. static AmbientTextureEnabled: boolean;
  101883. private static _OpacityTextureEnabled;
  101884. /**
  101885. * Are opacity textures enabled in the application.
  101886. */
  101887. static OpacityTextureEnabled: boolean;
  101888. private static _ReflectionTextureEnabled;
  101889. /**
  101890. * Are reflection textures enabled in the application.
  101891. */
  101892. static ReflectionTextureEnabled: boolean;
  101893. private static _EmissiveTextureEnabled;
  101894. /**
  101895. * Are emissive textures enabled in the application.
  101896. */
  101897. static EmissiveTextureEnabled: boolean;
  101898. private static _SpecularTextureEnabled;
  101899. /**
  101900. * Are specular textures enabled in the application.
  101901. */
  101902. static SpecularTextureEnabled: boolean;
  101903. private static _BumpTextureEnabled;
  101904. /**
  101905. * Are bump textures enabled in the application.
  101906. */
  101907. static BumpTextureEnabled: boolean;
  101908. private static _LightmapTextureEnabled;
  101909. /**
  101910. * Are lightmap textures enabled in the application.
  101911. */
  101912. static LightmapTextureEnabled: boolean;
  101913. private static _RefractionTextureEnabled;
  101914. /**
  101915. * Are refraction textures enabled in the application.
  101916. */
  101917. static RefractionTextureEnabled: boolean;
  101918. private static _ColorGradingTextureEnabled;
  101919. /**
  101920. * Are color grading textures enabled in the application.
  101921. */
  101922. static ColorGradingTextureEnabled: boolean;
  101923. private static _FresnelEnabled;
  101924. /**
  101925. * Are fresnels enabled in the application.
  101926. */
  101927. static FresnelEnabled: boolean;
  101928. private static _ClearCoatTextureEnabled;
  101929. /**
  101930. * Are clear coat textures enabled in the application.
  101931. */
  101932. static ClearCoatTextureEnabled: boolean;
  101933. private static _ClearCoatBumpTextureEnabled;
  101934. /**
  101935. * Are clear coat bump textures enabled in the application.
  101936. */
  101937. static ClearCoatBumpTextureEnabled: boolean;
  101938. private static _ClearCoatTintTextureEnabled;
  101939. /**
  101940. * Are clear coat tint textures enabled in the application.
  101941. */
  101942. static ClearCoatTintTextureEnabled: boolean;
  101943. private static _SheenTextureEnabled;
  101944. /**
  101945. * Are sheen textures enabled in the application.
  101946. */
  101947. static SheenTextureEnabled: boolean;
  101948. private static _AnisotropicTextureEnabled;
  101949. /**
  101950. * Are anisotropic textures enabled in the application.
  101951. */
  101952. static AnisotropicTextureEnabled: boolean;
  101953. private static _ThicknessTextureEnabled;
  101954. /**
  101955. * Are thickness textures enabled in the application.
  101956. */
  101957. static ThicknessTextureEnabled: boolean;
  101958. }
  101959. }
  101960. declare module BABYLON {
  101961. /** @hidden */
  101962. export var defaultFragmentDeclaration: {
  101963. name: string;
  101964. shader: string;
  101965. };
  101966. }
  101967. declare module BABYLON {
  101968. /** @hidden */
  101969. export var defaultUboDeclaration: {
  101970. name: string;
  101971. shader: string;
  101972. };
  101973. }
  101974. declare module BABYLON {
  101975. /** @hidden */
  101976. export var lightFragmentDeclaration: {
  101977. name: string;
  101978. shader: string;
  101979. };
  101980. }
  101981. declare module BABYLON {
  101982. /** @hidden */
  101983. export var lightUboDeclaration: {
  101984. name: string;
  101985. shader: string;
  101986. };
  101987. }
  101988. declare module BABYLON {
  101989. /** @hidden */
  101990. export var lightsFragmentFunctions: {
  101991. name: string;
  101992. shader: string;
  101993. };
  101994. }
  101995. declare module BABYLON {
  101996. /** @hidden */
  101997. export var shadowsFragmentFunctions: {
  101998. name: string;
  101999. shader: string;
  102000. };
  102001. }
  102002. declare module BABYLON {
  102003. /** @hidden */
  102004. export var fresnelFunction: {
  102005. name: string;
  102006. shader: string;
  102007. };
  102008. }
  102009. declare module BABYLON {
  102010. /** @hidden */
  102011. export var reflectionFunction: {
  102012. name: string;
  102013. shader: string;
  102014. };
  102015. }
  102016. declare module BABYLON {
  102017. /** @hidden */
  102018. export var bumpFragmentFunctions: {
  102019. name: string;
  102020. shader: string;
  102021. };
  102022. }
  102023. declare module BABYLON {
  102024. /** @hidden */
  102025. export var logDepthDeclaration: {
  102026. name: string;
  102027. shader: string;
  102028. };
  102029. }
  102030. declare module BABYLON {
  102031. /** @hidden */
  102032. export var bumpFragment: {
  102033. name: string;
  102034. shader: string;
  102035. };
  102036. }
  102037. declare module BABYLON {
  102038. /** @hidden */
  102039. export var depthPrePass: {
  102040. name: string;
  102041. shader: string;
  102042. };
  102043. }
  102044. declare module BABYLON {
  102045. /** @hidden */
  102046. export var lightFragment: {
  102047. name: string;
  102048. shader: string;
  102049. };
  102050. }
  102051. declare module BABYLON {
  102052. /** @hidden */
  102053. export var logDepthFragment: {
  102054. name: string;
  102055. shader: string;
  102056. };
  102057. }
  102058. declare module BABYLON {
  102059. /** @hidden */
  102060. export var defaultPixelShader: {
  102061. name: string;
  102062. shader: string;
  102063. };
  102064. }
  102065. declare module BABYLON {
  102066. /** @hidden */
  102067. export var defaultVertexDeclaration: {
  102068. name: string;
  102069. shader: string;
  102070. };
  102071. }
  102072. declare module BABYLON {
  102073. /** @hidden */
  102074. export var bumpVertexDeclaration: {
  102075. name: string;
  102076. shader: string;
  102077. };
  102078. }
  102079. declare module BABYLON {
  102080. /** @hidden */
  102081. export var bumpVertex: {
  102082. name: string;
  102083. shader: string;
  102084. };
  102085. }
  102086. declare module BABYLON {
  102087. /** @hidden */
  102088. export var fogVertex: {
  102089. name: string;
  102090. shader: string;
  102091. };
  102092. }
  102093. declare module BABYLON {
  102094. /** @hidden */
  102095. export var shadowsVertex: {
  102096. name: string;
  102097. shader: string;
  102098. };
  102099. }
  102100. declare module BABYLON {
  102101. /** @hidden */
  102102. export var pointCloudVertex: {
  102103. name: string;
  102104. shader: string;
  102105. };
  102106. }
  102107. declare module BABYLON {
  102108. /** @hidden */
  102109. export var logDepthVertex: {
  102110. name: string;
  102111. shader: string;
  102112. };
  102113. }
  102114. declare module BABYLON {
  102115. /** @hidden */
  102116. export var defaultVertexShader: {
  102117. name: string;
  102118. shader: string;
  102119. };
  102120. }
  102121. declare module BABYLON {
  102122. /** @hidden */
  102123. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102124. MAINUV1: boolean;
  102125. MAINUV2: boolean;
  102126. DIFFUSE: boolean;
  102127. DIFFUSEDIRECTUV: number;
  102128. AMBIENT: boolean;
  102129. AMBIENTDIRECTUV: number;
  102130. OPACITY: boolean;
  102131. OPACITYDIRECTUV: number;
  102132. OPACITYRGB: boolean;
  102133. REFLECTION: boolean;
  102134. EMISSIVE: boolean;
  102135. EMISSIVEDIRECTUV: number;
  102136. SPECULAR: boolean;
  102137. SPECULARDIRECTUV: number;
  102138. BUMP: boolean;
  102139. BUMPDIRECTUV: number;
  102140. PARALLAX: boolean;
  102141. PARALLAXOCCLUSION: boolean;
  102142. SPECULAROVERALPHA: boolean;
  102143. CLIPPLANE: boolean;
  102144. CLIPPLANE2: boolean;
  102145. CLIPPLANE3: boolean;
  102146. CLIPPLANE4: boolean;
  102147. ALPHATEST: boolean;
  102148. DEPTHPREPASS: boolean;
  102149. ALPHAFROMDIFFUSE: boolean;
  102150. POINTSIZE: boolean;
  102151. FOG: boolean;
  102152. SPECULARTERM: boolean;
  102153. DIFFUSEFRESNEL: boolean;
  102154. OPACITYFRESNEL: boolean;
  102155. REFLECTIONFRESNEL: boolean;
  102156. REFRACTIONFRESNEL: boolean;
  102157. EMISSIVEFRESNEL: boolean;
  102158. FRESNEL: boolean;
  102159. NORMAL: boolean;
  102160. UV1: boolean;
  102161. UV2: boolean;
  102162. VERTEXCOLOR: boolean;
  102163. VERTEXALPHA: boolean;
  102164. NUM_BONE_INFLUENCERS: number;
  102165. BonesPerMesh: number;
  102166. BONETEXTURE: boolean;
  102167. INSTANCES: boolean;
  102168. GLOSSINESS: boolean;
  102169. ROUGHNESS: boolean;
  102170. EMISSIVEASILLUMINATION: boolean;
  102171. LINKEMISSIVEWITHDIFFUSE: boolean;
  102172. REFLECTIONFRESNELFROMSPECULAR: boolean;
  102173. LIGHTMAP: boolean;
  102174. LIGHTMAPDIRECTUV: number;
  102175. OBJECTSPACE_NORMALMAP: boolean;
  102176. USELIGHTMAPASSHADOWMAP: boolean;
  102177. REFLECTIONMAP_3D: boolean;
  102178. REFLECTIONMAP_SPHERICAL: boolean;
  102179. REFLECTIONMAP_PLANAR: boolean;
  102180. REFLECTIONMAP_CUBIC: boolean;
  102181. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102182. REFLECTIONMAP_PROJECTION: boolean;
  102183. REFLECTIONMAP_SKYBOX: boolean;
  102184. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  102185. REFLECTIONMAP_EXPLICIT: boolean;
  102186. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102187. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102188. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102189. INVERTCUBICMAP: boolean;
  102190. LOGARITHMICDEPTH: boolean;
  102191. REFRACTION: boolean;
  102192. REFRACTIONMAP_3D: boolean;
  102193. REFLECTIONOVERALPHA: boolean;
  102194. TWOSIDEDLIGHTING: boolean;
  102195. SHADOWFLOAT: boolean;
  102196. MORPHTARGETS: boolean;
  102197. MORPHTARGETS_NORMAL: boolean;
  102198. MORPHTARGETS_TANGENT: boolean;
  102199. MORPHTARGETS_UV: boolean;
  102200. NUM_MORPH_INFLUENCERS: number;
  102201. NONUNIFORMSCALING: boolean;
  102202. PREMULTIPLYALPHA: boolean;
  102203. IMAGEPROCESSING: boolean;
  102204. VIGNETTE: boolean;
  102205. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102206. VIGNETTEBLENDMODEOPAQUE: boolean;
  102207. TONEMAPPING: boolean;
  102208. TONEMAPPING_ACES: boolean;
  102209. CONTRAST: boolean;
  102210. COLORCURVES: boolean;
  102211. COLORGRADING: boolean;
  102212. COLORGRADING3D: boolean;
  102213. SAMPLER3DGREENDEPTH: boolean;
  102214. SAMPLER3DBGRMAP: boolean;
  102215. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102216. MULTIVIEW: boolean;
  102217. /**
  102218. * If the reflection texture on this material is in linear color space
  102219. * @hidden
  102220. */
  102221. IS_REFLECTION_LINEAR: boolean;
  102222. /**
  102223. * If the refraction texture on this material is in linear color space
  102224. * @hidden
  102225. */
  102226. IS_REFRACTION_LINEAR: boolean;
  102227. EXPOSURE: boolean;
  102228. constructor();
  102229. setReflectionMode(modeToEnable: string): void;
  102230. }
  102231. /**
  102232. * This is the default material used in Babylon. It is the best trade off between quality
  102233. * and performances.
  102234. * @see http://doc.babylonjs.com/babylon101/materials
  102235. */
  102236. export class StandardMaterial extends PushMaterial {
  102237. private _diffuseTexture;
  102238. /**
  102239. * The basic texture of the material as viewed under a light.
  102240. */
  102241. diffuseTexture: Nullable<BaseTexture>;
  102242. private _ambientTexture;
  102243. /**
  102244. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  102245. */
  102246. ambientTexture: Nullable<BaseTexture>;
  102247. private _opacityTexture;
  102248. /**
  102249. * Define the transparency of the material from a texture.
  102250. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  102251. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  102252. */
  102253. opacityTexture: Nullable<BaseTexture>;
  102254. private _reflectionTexture;
  102255. /**
  102256. * Define the texture used to display the reflection.
  102257. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102258. */
  102259. reflectionTexture: Nullable<BaseTexture>;
  102260. private _emissiveTexture;
  102261. /**
  102262. * Define texture of the material as if self lit.
  102263. * This will be mixed in the final result even in the absence of light.
  102264. */
  102265. emissiveTexture: Nullable<BaseTexture>;
  102266. private _specularTexture;
  102267. /**
  102268. * Define how the color and intensity of the highlight given by the light in the material.
  102269. */
  102270. specularTexture: Nullable<BaseTexture>;
  102271. private _bumpTexture;
  102272. /**
  102273. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  102274. * 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.
  102275. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  102276. */
  102277. bumpTexture: Nullable<BaseTexture>;
  102278. private _lightmapTexture;
  102279. /**
  102280. * Complex lighting can be computationally expensive to compute at runtime.
  102281. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  102282. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  102283. */
  102284. lightmapTexture: Nullable<BaseTexture>;
  102285. private _refractionTexture;
  102286. /**
  102287. * Define the texture used to display the refraction.
  102288. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102289. */
  102290. refractionTexture: Nullable<BaseTexture>;
  102291. /**
  102292. * The color of the material lit by the environmental background lighting.
  102293. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  102294. */
  102295. ambientColor: Color3;
  102296. /**
  102297. * The basic color of the material as viewed under a light.
  102298. */
  102299. diffuseColor: Color3;
  102300. /**
  102301. * Define how the color and intensity of the highlight given by the light in the material.
  102302. */
  102303. specularColor: Color3;
  102304. /**
  102305. * Define the color of the material as if self lit.
  102306. * This will be mixed in the final result even in the absence of light.
  102307. */
  102308. emissiveColor: Color3;
  102309. /**
  102310. * Defines how sharp are the highlights in the material.
  102311. * The bigger the value the sharper giving a more glossy feeling to the result.
  102312. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  102313. */
  102314. specularPower: number;
  102315. private _useAlphaFromDiffuseTexture;
  102316. /**
  102317. * Does the transparency come from the diffuse texture alpha channel.
  102318. */
  102319. useAlphaFromDiffuseTexture: boolean;
  102320. private _useEmissiveAsIllumination;
  102321. /**
  102322. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  102323. */
  102324. useEmissiveAsIllumination: boolean;
  102325. private _linkEmissiveWithDiffuse;
  102326. /**
  102327. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  102328. * the emissive level when the final color is close to one.
  102329. */
  102330. linkEmissiveWithDiffuse: boolean;
  102331. private _useSpecularOverAlpha;
  102332. /**
  102333. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102334. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102335. */
  102336. useSpecularOverAlpha: boolean;
  102337. private _useReflectionOverAlpha;
  102338. /**
  102339. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102340. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102341. */
  102342. useReflectionOverAlpha: boolean;
  102343. private _disableLighting;
  102344. /**
  102345. * Does lights from the scene impacts this material.
  102346. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  102347. */
  102348. disableLighting: boolean;
  102349. private _useObjectSpaceNormalMap;
  102350. /**
  102351. * Allows using an object space normal map (instead of tangent space).
  102352. */
  102353. useObjectSpaceNormalMap: boolean;
  102354. private _useParallax;
  102355. /**
  102356. * Is parallax enabled or not.
  102357. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102358. */
  102359. useParallax: boolean;
  102360. private _useParallaxOcclusion;
  102361. /**
  102362. * Is parallax occlusion enabled or not.
  102363. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  102364. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102365. */
  102366. useParallaxOcclusion: boolean;
  102367. /**
  102368. * 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.
  102369. */
  102370. parallaxScaleBias: number;
  102371. private _roughness;
  102372. /**
  102373. * Helps to define how blurry the reflections should appears in the material.
  102374. */
  102375. roughness: number;
  102376. /**
  102377. * In case of refraction, define the value of the index of refraction.
  102378. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102379. */
  102380. indexOfRefraction: number;
  102381. /**
  102382. * Invert the refraction texture alongside the y axis.
  102383. * It can be useful with procedural textures or probe for instance.
  102384. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102385. */
  102386. invertRefractionY: boolean;
  102387. /**
  102388. * Defines the alpha limits in alpha test mode.
  102389. */
  102390. alphaCutOff: number;
  102391. private _useLightmapAsShadowmap;
  102392. /**
  102393. * In case of light mapping, define whether the map contains light or shadow informations.
  102394. */
  102395. useLightmapAsShadowmap: boolean;
  102396. private _diffuseFresnelParameters;
  102397. /**
  102398. * Define the diffuse fresnel parameters of the material.
  102399. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102400. */
  102401. diffuseFresnelParameters: FresnelParameters;
  102402. private _opacityFresnelParameters;
  102403. /**
  102404. * Define the opacity fresnel parameters of the material.
  102405. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102406. */
  102407. opacityFresnelParameters: FresnelParameters;
  102408. private _reflectionFresnelParameters;
  102409. /**
  102410. * Define the reflection fresnel parameters of the material.
  102411. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102412. */
  102413. reflectionFresnelParameters: FresnelParameters;
  102414. private _refractionFresnelParameters;
  102415. /**
  102416. * Define the refraction fresnel parameters of the material.
  102417. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102418. */
  102419. refractionFresnelParameters: FresnelParameters;
  102420. private _emissiveFresnelParameters;
  102421. /**
  102422. * Define the emissive fresnel parameters of the material.
  102423. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102424. */
  102425. emissiveFresnelParameters: FresnelParameters;
  102426. private _useReflectionFresnelFromSpecular;
  102427. /**
  102428. * If true automatically deducts the fresnels values from the material specularity.
  102429. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102430. */
  102431. useReflectionFresnelFromSpecular: boolean;
  102432. private _useGlossinessFromSpecularMapAlpha;
  102433. /**
  102434. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  102435. */
  102436. useGlossinessFromSpecularMapAlpha: boolean;
  102437. private _maxSimultaneousLights;
  102438. /**
  102439. * Defines the maximum number of lights that can be used in the material
  102440. */
  102441. maxSimultaneousLights: number;
  102442. private _invertNormalMapX;
  102443. /**
  102444. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102445. */
  102446. invertNormalMapX: boolean;
  102447. private _invertNormalMapY;
  102448. /**
  102449. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102450. */
  102451. invertNormalMapY: boolean;
  102452. private _twoSidedLighting;
  102453. /**
  102454. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102455. */
  102456. twoSidedLighting: boolean;
  102457. /**
  102458. * Default configuration related to image processing available in the standard Material.
  102459. */
  102460. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102461. /**
  102462. * Gets the image processing configuration used either in this material.
  102463. */
  102464. /**
  102465. * Sets the Default image processing configuration used either in the this material.
  102466. *
  102467. * If sets to null, the scene one is in use.
  102468. */
  102469. imageProcessingConfiguration: ImageProcessingConfiguration;
  102470. /**
  102471. * Keep track of the image processing observer to allow dispose and replace.
  102472. */
  102473. private _imageProcessingObserver;
  102474. /**
  102475. * Attaches a new image processing configuration to the Standard Material.
  102476. * @param configuration
  102477. */
  102478. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102479. /**
  102480. * Gets wether the color curves effect is enabled.
  102481. */
  102482. /**
  102483. * Sets wether the color curves effect is enabled.
  102484. */
  102485. cameraColorCurvesEnabled: boolean;
  102486. /**
  102487. * Gets wether the color grading effect is enabled.
  102488. */
  102489. /**
  102490. * Gets wether the color grading effect is enabled.
  102491. */
  102492. cameraColorGradingEnabled: boolean;
  102493. /**
  102494. * Gets wether tonemapping is enabled or not.
  102495. */
  102496. /**
  102497. * Sets wether tonemapping is enabled or not
  102498. */
  102499. cameraToneMappingEnabled: boolean;
  102500. /**
  102501. * The camera exposure used on this material.
  102502. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102503. * This corresponds to a photographic exposure.
  102504. */
  102505. /**
  102506. * The camera exposure used on this material.
  102507. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102508. * This corresponds to a photographic exposure.
  102509. */
  102510. cameraExposure: number;
  102511. /**
  102512. * Gets The camera contrast used on this material.
  102513. */
  102514. /**
  102515. * Sets The camera contrast used on this material.
  102516. */
  102517. cameraContrast: number;
  102518. /**
  102519. * Gets the Color Grading 2D Lookup Texture.
  102520. */
  102521. /**
  102522. * Sets the Color Grading 2D Lookup Texture.
  102523. */
  102524. cameraColorGradingTexture: Nullable<BaseTexture>;
  102525. /**
  102526. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102527. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102528. * 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;
  102529. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102530. */
  102531. /**
  102532. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102533. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102534. * 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;
  102535. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102536. */
  102537. cameraColorCurves: Nullable<ColorCurves>;
  102538. /**
  102539. * Custom callback helping to override the default shader used in the material.
  102540. */
  102541. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  102542. protected _renderTargets: SmartArray<RenderTargetTexture>;
  102543. protected _worldViewProjectionMatrix: Matrix;
  102544. protected _globalAmbientColor: Color3;
  102545. protected _useLogarithmicDepth: boolean;
  102546. /**
  102547. * Instantiates a new standard material.
  102548. * This is the default material used in Babylon. It is the best trade off between quality
  102549. * and performances.
  102550. * @see http://doc.babylonjs.com/babylon101/materials
  102551. * @param name Define the name of the material in the scene
  102552. * @param scene Define the scene the material belong to
  102553. */
  102554. constructor(name: string, scene: Scene);
  102555. /**
  102556. * Gets a boolean indicating that current material needs to register RTT
  102557. */
  102558. readonly hasRenderTargetTextures: boolean;
  102559. /**
  102560. * Gets the current class name of the material e.g. "StandardMaterial"
  102561. * Mainly use in serialization.
  102562. * @returns the class name
  102563. */
  102564. getClassName(): string;
  102565. /**
  102566. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  102567. * You can try switching to logarithmic depth.
  102568. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  102569. */
  102570. useLogarithmicDepth: boolean;
  102571. /**
  102572. * Specifies if the material will require alpha blending
  102573. * @returns a boolean specifying if alpha blending is needed
  102574. */
  102575. needAlphaBlending(): boolean;
  102576. /**
  102577. * Specifies if this material should be rendered in alpha test mode
  102578. * @returns a boolean specifying if an alpha test is needed.
  102579. */
  102580. needAlphaTesting(): boolean;
  102581. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  102582. /**
  102583. * Get the texture used for alpha test purpose.
  102584. * @returns the diffuse texture in case of the standard material.
  102585. */
  102586. getAlphaTestTexture(): Nullable<BaseTexture>;
  102587. /**
  102588. * Get if the submesh is ready to be used and all its information available.
  102589. * Child classes can use it to update shaders
  102590. * @param mesh defines the mesh to check
  102591. * @param subMesh defines which submesh to check
  102592. * @param useInstances specifies that instances should be used
  102593. * @returns a boolean indicating that the submesh is ready or not
  102594. */
  102595. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102596. /**
  102597. * Builds the material UBO layouts.
  102598. * Used internally during the effect preparation.
  102599. */
  102600. buildUniformLayout(): void;
  102601. /**
  102602. * Unbinds the material from the mesh
  102603. */
  102604. unbind(): void;
  102605. /**
  102606. * Binds the submesh to this material by preparing the effect and shader to draw
  102607. * @param world defines the world transformation matrix
  102608. * @param mesh defines the mesh containing the submesh
  102609. * @param subMesh defines the submesh to bind the material to
  102610. */
  102611. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102612. /**
  102613. * Get the list of animatables in the material.
  102614. * @returns the list of animatables object used in the material
  102615. */
  102616. getAnimatables(): IAnimatable[];
  102617. /**
  102618. * Gets the active textures from the material
  102619. * @returns an array of textures
  102620. */
  102621. getActiveTextures(): BaseTexture[];
  102622. /**
  102623. * Specifies if the material uses a texture
  102624. * @param texture defines the texture to check against the material
  102625. * @returns a boolean specifying if the material uses the texture
  102626. */
  102627. hasTexture(texture: BaseTexture): boolean;
  102628. /**
  102629. * Disposes the material
  102630. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102631. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102632. */
  102633. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102634. /**
  102635. * Makes a duplicate of the material, and gives it a new name
  102636. * @param name defines the new name for the duplicated material
  102637. * @returns the cloned material
  102638. */
  102639. clone(name: string): StandardMaterial;
  102640. /**
  102641. * Serializes this material in a JSON representation
  102642. * @returns the serialized material object
  102643. */
  102644. serialize(): any;
  102645. /**
  102646. * Creates a standard material from parsed material data
  102647. * @param source defines the JSON representation of the material
  102648. * @param scene defines the hosting scene
  102649. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102650. * @returns a new standard material
  102651. */
  102652. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  102653. /**
  102654. * Are diffuse textures enabled in the application.
  102655. */
  102656. static DiffuseTextureEnabled: boolean;
  102657. /**
  102658. * Are ambient textures enabled in the application.
  102659. */
  102660. static AmbientTextureEnabled: boolean;
  102661. /**
  102662. * Are opacity textures enabled in the application.
  102663. */
  102664. static OpacityTextureEnabled: boolean;
  102665. /**
  102666. * Are reflection textures enabled in the application.
  102667. */
  102668. static ReflectionTextureEnabled: boolean;
  102669. /**
  102670. * Are emissive textures enabled in the application.
  102671. */
  102672. static EmissiveTextureEnabled: boolean;
  102673. /**
  102674. * Are specular textures enabled in the application.
  102675. */
  102676. static SpecularTextureEnabled: boolean;
  102677. /**
  102678. * Are bump textures enabled in the application.
  102679. */
  102680. static BumpTextureEnabled: boolean;
  102681. /**
  102682. * Are lightmap textures enabled in the application.
  102683. */
  102684. static LightmapTextureEnabled: boolean;
  102685. /**
  102686. * Are refraction textures enabled in the application.
  102687. */
  102688. static RefractionTextureEnabled: boolean;
  102689. /**
  102690. * Are color grading textures enabled in the application.
  102691. */
  102692. static ColorGradingTextureEnabled: boolean;
  102693. /**
  102694. * Are fresnels enabled in the application.
  102695. */
  102696. static FresnelEnabled: boolean;
  102697. }
  102698. }
  102699. declare module BABYLON {
  102700. /**
  102701. * A class extending Texture allowing drawing on a texture
  102702. * @see http://doc.babylonjs.com/how_to/dynamictexture
  102703. */
  102704. export class DynamicTexture extends Texture {
  102705. private _generateMipMaps;
  102706. private _canvas;
  102707. private _context;
  102708. private _engine;
  102709. /**
  102710. * Creates a DynamicTexture
  102711. * @param name defines the name of the texture
  102712. * @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
  102713. * @param scene defines the scene where you want the texture
  102714. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  102715. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  102716. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  102717. */
  102718. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  102719. /**
  102720. * Get the current class name of the texture useful for serialization or dynamic coding.
  102721. * @returns "DynamicTexture"
  102722. */
  102723. getClassName(): string;
  102724. /**
  102725. * Gets the current state of canRescale
  102726. */
  102727. readonly canRescale: boolean;
  102728. private _recreate;
  102729. /**
  102730. * Scales the texture
  102731. * @param ratio the scale factor to apply to both width and height
  102732. */
  102733. scale(ratio: number): void;
  102734. /**
  102735. * Resizes the texture
  102736. * @param width the new width
  102737. * @param height the new height
  102738. */
  102739. scaleTo(width: number, height: number): void;
  102740. /**
  102741. * Gets the context of the canvas used by the texture
  102742. * @returns the canvas context of the dynamic texture
  102743. */
  102744. getContext(): CanvasRenderingContext2D;
  102745. /**
  102746. * Clears the texture
  102747. */
  102748. clear(): void;
  102749. /**
  102750. * Updates the texture
  102751. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102752. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  102753. */
  102754. update(invertY?: boolean, premulAlpha?: boolean): void;
  102755. /**
  102756. * Draws text onto the texture
  102757. * @param text defines the text to be drawn
  102758. * @param x defines the placement of the text from the left
  102759. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  102760. * @param font defines the font to be used with font-style, font-size, font-name
  102761. * @param color defines the color used for the text
  102762. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  102763. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102764. * @param update defines whether texture is immediately update (default is true)
  102765. */
  102766. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  102767. /**
  102768. * Clones the texture
  102769. * @returns the clone of the texture.
  102770. */
  102771. clone(): DynamicTexture;
  102772. /**
  102773. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  102774. * @returns a serialized dynamic texture object
  102775. */
  102776. serialize(): any;
  102777. /** @hidden */
  102778. _rebuild(): void;
  102779. }
  102780. }
  102781. declare module BABYLON {
  102782. /** @hidden */
  102783. export var imageProcessingPixelShader: {
  102784. name: string;
  102785. shader: string;
  102786. };
  102787. }
  102788. declare module BABYLON {
  102789. /**
  102790. * ImageProcessingPostProcess
  102791. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102792. */
  102793. export class ImageProcessingPostProcess extends PostProcess {
  102794. /**
  102795. * Default configuration related to image processing available in the PBR Material.
  102796. */
  102797. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102798. /**
  102799. * Gets the image processing configuration used either in this material.
  102800. */
  102801. /**
  102802. * Sets the Default image processing configuration used either in the this material.
  102803. *
  102804. * If sets to null, the scene one is in use.
  102805. */
  102806. imageProcessingConfiguration: ImageProcessingConfiguration;
  102807. /**
  102808. * Keep track of the image processing observer to allow dispose and replace.
  102809. */
  102810. private _imageProcessingObserver;
  102811. /**
  102812. * Attaches a new image processing configuration to the PBR Material.
  102813. * @param configuration
  102814. */
  102815. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102816. /**
  102817. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102818. */
  102819. /**
  102820. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102821. */
  102822. colorCurves: Nullable<ColorCurves>;
  102823. /**
  102824. * Gets wether the color curves effect is enabled.
  102825. */
  102826. /**
  102827. * Sets wether the color curves effect is enabled.
  102828. */
  102829. colorCurvesEnabled: boolean;
  102830. /**
  102831. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102832. */
  102833. /**
  102834. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102835. */
  102836. colorGradingTexture: Nullable<BaseTexture>;
  102837. /**
  102838. * Gets wether the color grading effect is enabled.
  102839. */
  102840. /**
  102841. * Gets wether the color grading effect is enabled.
  102842. */
  102843. colorGradingEnabled: boolean;
  102844. /**
  102845. * Gets exposure used in the effect.
  102846. */
  102847. /**
  102848. * Sets exposure used in the effect.
  102849. */
  102850. exposure: number;
  102851. /**
  102852. * Gets wether tonemapping is enabled or not.
  102853. */
  102854. /**
  102855. * Sets wether tonemapping is enabled or not
  102856. */
  102857. toneMappingEnabled: boolean;
  102858. /**
  102859. * Gets the type of tone mapping effect.
  102860. */
  102861. /**
  102862. * Sets the type of tone mapping effect.
  102863. */
  102864. toneMappingType: number;
  102865. /**
  102866. * Gets contrast used in the effect.
  102867. */
  102868. /**
  102869. * Sets contrast used in the effect.
  102870. */
  102871. contrast: number;
  102872. /**
  102873. * Gets Vignette stretch size.
  102874. */
  102875. /**
  102876. * Sets Vignette stretch size.
  102877. */
  102878. vignetteStretch: number;
  102879. /**
  102880. * Gets Vignette centre X Offset.
  102881. */
  102882. /**
  102883. * Sets Vignette centre X Offset.
  102884. */
  102885. vignetteCentreX: number;
  102886. /**
  102887. * Gets Vignette centre Y Offset.
  102888. */
  102889. /**
  102890. * Sets Vignette centre Y Offset.
  102891. */
  102892. vignetteCentreY: number;
  102893. /**
  102894. * Gets Vignette weight or intensity of the vignette effect.
  102895. */
  102896. /**
  102897. * Sets Vignette weight or intensity of the vignette effect.
  102898. */
  102899. vignetteWeight: number;
  102900. /**
  102901. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102902. * if vignetteEnabled is set to true.
  102903. */
  102904. /**
  102905. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102906. * if vignetteEnabled is set to true.
  102907. */
  102908. vignetteColor: Color4;
  102909. /**
  102910. * Gets Camera field of view used by the Vignette effect.
  102911. */
  102912. /**
  102913. * Sets Camera field of view used by the Vignette effect.
  102914. */
  102915. vignetteCameraFov: number;
  102916. /**
  102917. * Gets the vignette blend mode allowing different kind of effect.
  102918. */
  102919. /**
  102920. * Sets the vignette blend mode allowing different kind of effect.
  102921. */
  102922. vignetteBlendMode: number;
  102923. /**
  102924. * Gets wether the vignette effect is enabled.
  102925. */
  102926. /**
  102927. * Sets wether the vignette effect is enabled.
  102928. */
  102929. vignetteEnabled: boolean;
  102930. private _fromLinearSpace;
  102931. /**
  102932. * Gets wether the input of the processing is in Gamma or Linear Space.
  102933. */
  102934. /**
  102935. * Sets wether the input of the processing is in Gamma or Linear Space.
  102936. */
  102937. fromLinearSpace: boolean;
  102938. /**
  102939. * Defines cache preventing GC.
  102940. */
  102941. private _defines;
  102942. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102943. /**
  102944. * "ImageProcessingPostProcess"
  102945. * @returns "ImageProcessingPostProcess"
  102946. */
  102947. getClassName(): string;
  102948. protected _updateParameters(): void;
  102949. dispose(camera?: Camera): void;
  102950. }
  102951. }
  102952. declare module BABYLON {
  102953. /**
  102954. * Class containing static functions to help procedurally build meshes
  102955. */
  102956. export class GroundBuilder {
  102957. /**
  102958. * Creates a ground mesh
  102959. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102960. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102962. * @param name defines the name of the mesh
  102963. * @param options defines the options used to create the mesh
  102964. * @param scene defines the hosting scene
  102965. * @returns the ground mesh
  102966. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102967. */
  102968. static CreateGround(name: string, options: {
  102969. width?: number;
  102970. height?: number;
  102971. subdivisions?: number;
  102972. subdivisionsX?: number;
  102973. subdivisionsY?: number;
  102974. updatable?: boolean;
  102975. }, scene: any): Mesh;
  102976. /**
  102977. * Creates a tiled ground mesh
  102978. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102979. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102980. * * 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
  102981. * * 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
  102982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102983. * @param name defines the name of the mesh
  102984. * @param options defines the options used to create the mesh
  102985. * @param scene defines the hosting scene
  102986. * @returns the tiled ground mesh
  102987. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102988. */
  102989. static CreateTiledGround(name: string, options: {
  102990. xmin: number;
  102991. zmin: number;
  102992. xmax: number;
  102993. zmax: number;
  102994. subdivisions?: {
  102995. w: number;
  102996. h: number;
  102997. };
  102998. precision?: {
  102999. w: number;
  103000. h: number;
  103001. };
  103002. updatable?: boolean;
  103003. }, scene?: Nullable<Scene>): Mesh;
  103004. /**
  103005. * Creates a ground mesh from a height map
  103006. * * The parameter `url` sets the URL of the height map image resource.
  103007. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  103008. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  103009. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  103010. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  103011. * * 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.
  103012. * * 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).
  103013. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  103014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103015. * @param name defines the name of the mesh
  103016. * @param url defines the url to the height map
  103017. * @param options defines the options used to create the mesh
  103018. * @param scene defines the hosting scene
  103019. * @returns the ground mesh
  103020. * @see https://doc.babylonjs.com/babylon101/height_map
  103021. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  103022. */
  103023. static CreateGroundFromHeightMap(name: string, url: string, options: {
  103024. width?: number;
  103025. height?: number;
  103026. subdivisions?: number;
  103027. minHeight?: number;
  103028. maxHeight?: number;
  103029. colorFilter?: Color3;
  103030. alphaFilter?: number;
  103031. updatable?: boolean;
  103032. onReady?: (mesh: GroundMesh) => void;
  103033. }, scene?: Nullable<Scene>): GroundMesh;
  103034. }
  103035. }
  103036. declare module BABYLON {
  103037. /**
  103038. * Class containing static functions to help procedurally build meshes
  103039. */
  103040. export class TorusBuilder {
  103041. /**
  103042. * Creates a torus mesh
  103043. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  103044. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  103045. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  103046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103049. * @param name defines the name of the mesh
  103050. * @param options defines the options used to create the mesh
  103051. * @param scene defines the hosting scene
  103052. * @returns the torus mesh
  103053. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  103054. */
  103055. static CreateTorus(name: string, options: {
  103056. diameter?: number;
  103057. thickness?: number;
  103058. tessellation?: number;
  103059. updatable?: boolean;
  103060. sideOrientation?: number;
  103061. frontUVs?: Vector4;
  103062. backUVs?: Vector4;
  103063. }, scene: any): Mesh;
  103064. }
  103065. }
  103066. declare module BABYLON {
  103067. /**
  103068. * Class containing static functions to help procedurally build meshes
  103069. */
  103070. export class CylinderBuilder {
  103071. /**
  103072. * Creates a cylinder or a cone mesh
  103073. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  103074. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  103075. * * 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.
  103076. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  103077. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  103078. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  103079. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  103080. * * 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).
  103081. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  103082. * * 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).
  103083. * * 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
  103084. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  103085. * * 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
  103086. * * 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.
  103087. * * If `enclose` is false, a ring surface is one element.
  103088. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  103089. * * 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
  103090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103091. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103093. * @param name defines the name of the mesh
  103094. * @param options defines the options used to create the mesh
  103095. * @param scene defines the hosting scene
  103096. * @returns the cylinder mesh
  103097. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  103098. */
  103099. static CreateCylinder(name: string, options: {
  103100. height?: number;
  103101. diameterTop?: number;
  103102. diameterBottom?: number;
  103103. diameter?: number;
  103104. tessellation?: number;
  103105. subdivisions?: number;
  103106. arc?: number;
  103107. faceColors?: Color4[];
  103108. faceUV?: Vector4[];
  103109. updatable?: boolean;
  103110. hasRings?: boolean;
  103111. enclose?: boolean;
  103112. cap?: number;
  103113. sideOrientation?: number;
  103114. frontUVs?: Vector4;
  103115. backUVs?: Vector4;
  103116. }, scene: any): Mesh;
  103117. }
  103118. }
  103119. declare module BABYLON {
  103120. /**
  103121. * Options to modify the vr teleportation behavior.
  103122. */
  103123. export interface VRTeleportationOptions {
  103124. /**
  103125. * The name of the mesh which should be used as the teleportation floor. (default: null)
  103126. */
  103127. floorMeshName?: string;
  103128. /**
  103129. * A list of meshes to be used as the teleportation floor. (default: empty)
  103130. */
  103131. floorMeshes?: Mesh[];
  103132. }
  103133. /**
  103134. * Options to modify the vr experience helper's behavior.
  103135. */
  103136. export interface VRExperienceHelperOptions extends WebVROptions {
  103137. /**
  103138. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  103139. */
  103140. createDeviceOrientationCamera?: boolean;
  103141. /**
  103142. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  103143. */
  103144. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  103145. /**
  103146. * Uses the main button on the controller to toggle the laser casted. (default: true)
  103147. */
  103148. laserToggle?: boolean;
  103149. /**
  103150. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  103151. */
  103152. floorMeshes?: Mesh[];
  103153. /**
  103154. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  103155. */
  103156. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  103157. }
  103158. /**
  103159. * Event containing information after VR has been entered
  103160. */
  103161. export class OnAfterEnteringVRObservableEvent {
  103162. /**
  103163. * If entering vr was successful
  103164. */
  103165. success: boolean;
  103166. }
  103167. /**
  103168. * Helps to quickly add VR support to an existing scene.
  103169. * See http://doc.babylonjs.com/how_to/webvr_helper
  103170. */
  103171. export class VRExperienceHelper {
  103172. /** Options to modify the vr experience helper's behavior. */
  103173. webVROptions: VRExperienceHelperOptions;
  103174. private _scene;
  103175. private _position;
  103176. private _btnVR;
  103177. private _btnVRDisplayed;
  103178. private _webVRsupported;
  103179. private _webVRready;
  103180. private _webVRrequesting;
  103181. private _webVRpresenting;
  103182. private _hasEnteredVR;
  103183. private _fullscreenVRpresenting;
  103184. private _canvas;
  103185. private _webVRCamera;
  103186. private _vrDeviceOrientationCamera;
  103187. private _deviceOrientationCamera;
  103188. private _existingCamera;
  103189. private _onKeyDown;
  103190. private _onVrDisplayPresentChange;
  103191. private _onVRDisplayChanged;
  103192. private _onVRRequestPresentStart;
  103193. private _onVRRequestPresentComplete;
  103194. /**
  103195. * Observable raised right before entering VR.
  103196. */
  103197. onEnteringVRObservable: Observable<VRExperienceHelper>;
  103198. /**
  103199. * Observable raised when entering VR has completed.
  103200. */
  103201. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  103202. /**
  103203. * Observable raised when exiting VR.
  103204. */
  103205. onExitingVRObservable: Observable<VRExperienceHelper>;
  103206. /**
  103207. * Observable raised when controller mesh is loaded.
  103208. */
  103209. onControllerMeshLoadedObservable: Observable<WebVRController>;
  103210. /** Return this.onEnteringVRObservable
  103211. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  103212. */
  103213. readonly onEnteringVR: Observable<VRExperienceHelper>;
  103214. /** Return this.onExitingVRObservable
  103215. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  103216. */
  103217. readonly onExitingVR: Observable<VRExperienceHelper>;
  103218. /** Return this.onControllerMeshLoadedObservable
  103219. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  103220. */
  103221. readonly onControllerMeshLoaded: Observable<WebVRController>;
  103222. private _rayLength;
  103223. private _useCustomVRButton;
  103224. private _teleportationRequested;
  103225. private _teleportActive;
  103226. private _floorMeshName;
  103227. private _floorMeshesCollection;
  103228. private _rotationAllowed;
  103229. private _teleportBackwardsVector;
  103230. private _teleportationTarget;
  103231. private _isDefaultTeleportationTarget;
  103232. private _postProcessMove;
  103233. private _teleportationFillColor;
  103234. private _teleportationBorderColor;
  103235. private _rotationAngle;
  103236. private _haloCenter;
  103237. private _cameraGazer;
  103238. private _padSensibilityUp;
  103239. private _padSensibilityDown;
  103240. private _leftController;
  103241. private _rightController;
  103242. /**
  103243. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  103244. */
  103245. onNewMeshSelected: Observable<AbstractMesh>;
  103246. /**
  103247. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  103248. */
  103249. onNewMeshPicked: Observable<PickingInfo>;
  103250. private _circleEase;
  103251. /**
  103252. * Observable raised before camera teleportation
  103253. */
  103254. onBeforeCameraTeleport: Observable<Vector3>;
  103255. /**
  103256. * Observable raised after camera teleportation
  103257. */
  103258. onAfterCameraTeleport: Observable<Vector3>;
  103259. /**
  103260. * Observable raised when current selected mesh gets unselected
  103261. */
  103262. onSelectedMeshUnselected: Observable<AbstractMesh>;
  103263. private _raySelectionPredicate;
  103264. /**
  103265. * To be optionaly changed by user to define custom ray selection
  103266. */
  103267. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  103268. /**
  103269. * To be optionaly changed by user to define custom selection logic (after ray selection)
  103270. */
  103271. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103272. /**
  103273. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  103274. */
  103275. teleportationEnabled: boolean;
  103276. private _defaultHeight;
  103277. private _teleportationInitialized;
  103278. private _interactionsEnabled;
  103279. private _interactionsRequested;
  103280. private _displayGaze;
  103281. private _displayLaserPointer;
  103282. /**
  103283. * The mesh used to display where the user is going to teleport.
  103284. */
  103285. /**
  103286. * Sets the mesh to be used to display where the user is going to teleport.
  103287. */
  103288. teleportationTarget: Mesh;
  103289. /**
  103290. * 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
  103291. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  103292. * See http://doc.babylonjs.com/resources/baking_transformations
  103293. */
  103294. gazeTrackerMesh: Mesh;
  103295. /**
  103296. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  103297. */
  103298. updateGazeTrackerScale: boolean;
  103299. /**
  103300. * If the gaze trackers color should be updated when selecting meshes
  103301. */
  103302. updateGazeTrackerColor: boolean;
  103303. /**
  103304. * The gaze tracking mesh corresponding to the left controller
  103305. */
  103306. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  103307. /**
  103308. * The gaze tracking mesh corresponding to the right controller
  103309. */
  103310. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  103311. /**
  103312. * If the ray of the gaze should be displayed.
  103313. */
  103314. /**
  103315. * Sets if the ray of the gaze should be displayed.
  103316. */
  103317. displayGaze: boolean;
  103318. /**
  103319. * If the ray of the LaserPointer should be displayed.
  103320. */
  103321. /**
  103322. * Sets if the ray of the LaserPointer should be displayed.
  103323. */
  103324. displayLaserPointer: boolean;
  103325. /**
  103326. * The deviceOrientationCamera used as the camera when not in VR.
  103327. */
  103328. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  103329. /**
  103330. * Based on the current WebVR support, returns the current VR camera used.
  103331. */
  103332. readonly currentVRCamera: Nullable<Camera>;
  103333. /**
  103334. * The webVRCamera which is used when in VR.
  103335. */
  103336. readonly webVRCamera: WebVRFreeCamera;
  103337. /**
  103338. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  103339. */
  103340. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  103341. private readonly _teleportationRequestInitiated;
  103342. /**
  103343. * Defines wether or not Pointer lock should be requested when switching to
  103344. * full screen.
  103345. */
  103346. requestPointerLockOnFullScreen: boolean;
  103347. /**
  103348. * Instantiates a VRExperienceHelper.
  103349. * Helps to quickly add VR support to an existing scene.
  103350. * @param scene The scene the VRExperienceHelper belongs to.
  103351. * @param webVROptions Options to modify the vr experience helper's behavior.
  103352. */
  103353. constructor(scene: Scene,
  103354. /** Options to modify the vr experience helper's behavior. */
  103355. webVROptions?: VRExperienceHelperOptions);
  103356. private _onDefaultMeshLoaded;
  103357. private _onResize;
  103358. private _onFullscreenChange;
  103359. /**
  103360. * Gets a value indicating if we are currently in VR mode.
  103361. */
  103362. readonly isInVRMode: boolean;
  103363. private onVrDisplayPresentChange;
  103364. private onVRDisplayChanged;
  103365. private moveButtonToBottomRight;
  103366. private displayVRButton;
  103367. private updateButtonVisibility;
  103368. private _cachedAngularSensibility;
  103369. /**
  103370. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  103371. * Otherwise, will use the fullscreen API.
  103372. */
  103373. enterVR(): void;
  103374. /**
  103375. * Attempt to exit VR, or fullscreen.
  103376. */
  103377. exitVR(): void;
  103378. /**
  103379. * The position of the vr experience helper.
  103380. */
  103381. /**
  103382. * Sets the position of the vr experience helper.
  103383. */
  103384. position: Vector3;
  103385. /**
  103386. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  103387. */
  103388. enableInteractions(): void;
  103389. private readonly _noControllerIsActive;
  103390. private beforeRender;
  103391. private _isTeleportationFloor;
  103392. /**
  103393. * Adds a floor mesh to be used for teleportation.
  103394. * @param floorMesh the mesh to be used for teleportation.
  103395. */
  103396. addFloorMesh(floorMesh: Mesh): void;
  103397. /**
  103398. * Removes a floor mesh from being used for teleportation.
  103399. * @param floorMesh the mesh to be removed.
  103400. */
  103401. removeFloorMesh(floorMesh: Mesh): void;
  103402. /**
  103403. * Enables interactions and teleportation using the VR controllers and gaze.
  103404. * @param vrTeleportationOptions options to modify teleportation behavior.
  103405. */
  103406. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  103407. private _onNewGamepadConnected;
  103408. private _tryEnableInteractionOnController;
  103409. private _onNewGamepadDisconnected;
  103410. private _enableInteractionOnController;
  103411. private _checkTeleportWithRay;
  103412. private _checkRotate;
  103413. private _checkTeleportBackwards;
  103414. private _enableTeleportationOnController;
  103415. private _createTeleportationCircles;
  103416. private _displayTeleportationTarget;
  103417. private _hideTeleportationTarget;
  103418. private _rotateCamera;
  103419. private _moveTeleportationSelectorTo;
  103420. private _workingVector;
  103421. private _workingQuaternion;
  103422. private _workingMatrix;
  103423. /**
  103424. * Teleports the users feet to the desired location
  103425. * @param location The location where the user's feet should be placed
  103426. */
  103427. teleportCamera(location: Vector3): void;
  103428. private _convertNormalToDirectionOfRay;
  103429. private _castRayAndSelectObject;
  103430. private _notifySelectedMeshUnselected;
  103431. /**
  103432. * Sets the color of the laser ray from the vr controllers.
  103433. * @param color new color for the ray.
  103434. */
  103435. changeLaserColor(color: Color3): void;
  103436. /**
  103437. * Sets the color of the ray from the vr headsets gaze.
  103438. * @param color new color for the ray.
  103439. */
  103440. changeGazeColor(color: Color3): void;
  103441. /**
  103442. * Exits VR and disposes of the vr experience helper
  103443. */
  103444. dispose(): void;
  103445. /**
  103446. * Gets the name of the VRExperienceHelper class
  103447. * @returns "VRExperienceHelper"
  103448. */
  103449. getClassName(): string;
  103450. }
  103451. }
  103452. declare module BABYLON {
  103453. /**
  103454. * Manages an XRSession
  103455. * @see https://doc.babylonjs.com/how_to/webxr
  103456. */
  103457. export class WebXRSessionManager implements IDisposable {
  103458. private scene;
  103459. /**
  103460. * Fires every time a new xrFrame arrives which can be used to update the camera
  103461. */
  103462. onXRFrameObservable: Observable<any>;
  103463. /**
  103464. * Fires when the xr session is ended either by the device or manually done
  103465. */
  103466. onXRSessionEnded: Observable<any>;
  103467. /** @hidden */
  103468. _xrSession: XRSession;
  103469. /** @hidden */
  103470. _frameOfReference: XRFrameOfReference;
  103471. /** @hidden */
  103472. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  103473. /** @hidden */
  103474. _currentXRFrame: Nullable<XRFrame>;
  103475. private _xrNavigator;
  103476. private _xrDevice;
  103477. private _tmpMatrix;
  103478. /**
  103479. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  103480. * @param scene The scene which the session should be created for
  103481. */
  103482. constructor(scene: Scene);
  103483. /**
  103484. * Initializes the manager
  103485. * After initialization enterXR can be called to start an XR session
  103486. * @returns Promise which resolves after it is initialized
  103487. */
  103488. initializeAsync(): Promise<void>;
  103489. /**
  103490. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  103491. * @param sessionCreationOptions xr options to create the session with
  103492. * @param frameOfReferenceType option to configure how the xr pose is expressed
  103493. * @returns Promise which resolves after it enters XR
  103494. */
  103495. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  103496. /**
  103497. * Stops the xrSession and restores the renderloop
  103498. * @returns Promise which resolves after it exits XR
  103499. */
  103500. exitXRAsync(): Promise<void>;
  103501. /**
  103502. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  103503. * @param ray ray to cast into the environment
  103504. * @returns Promise which resolves with a collision point in the environment if it exists
  103505. */
  103506. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  103507. /**
  103508. * Checks if a session would be supported for the creation options specified
  103509. * @param options creation options to check if they are supported
  103510. * @returns true if supported
  103511. */
  103512. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103513. /**
  103514. * @hidden
  103515. * Converts the render layer of xrSession to a render target
  103516. * @param session session to create render target for
  103517. * @param scene scene the new render target should be created for
  103518. */
  103519. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  103520. /**
  103521. * Disposes of the session manager
  103522. */
  103523. dispose(): void;
  103524. }
  103525. }
  103526. declare module BABYLON {
  103527. /**
  103528. * WebXR Camera which holds the views for the xrSession
  103529. * @see https://doc.babylonjs.com/how_to/webxr
  103530. */
  103531. export class WebXRCamera extends FreeCamera {
  103532. private static _TmpMatrix;
  103533. /**
  103534. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  103535. * @param name the name of the camera
  103536. * @param scene the scene to add the camera to
  103537. */
  103538. constructor(name: string, scene: Scene);
  103539. private _updateNumberOfRigCameras;
  103540. /** @hidden */
  103541. _updateForDualEyeDebugging(pupilDistance?: number): void;
  103542. /**
  103543. * Updates the cameras position from the current pose information of the XR session
  103544. * @param xrSessionManager the session containing pose information
  103545. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  103546. */
  103547. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  103548. }
  103549. }
  103550. declare module BABYLON {
  103551. /**
  103552. * States of the webXR experience
  103553. */
  103554. export enum WebXRState {
  103555. /**
  103556. * Transitioning to being in XR mode
  103557. */
  103558. ENTERING_XR = 0,
  103559. /**
  103560. * Transitioning to non XR mode
  103561. */
  103562. EXITING_XR = 1,
  103563. /**
  103564. * In XR mode and presenting
  103565. */
  103566. IN_XR = 2,
  103567. /**
  103568. * Not entered XR mode
  103569. */
  103570. NOT_IN_XR = 3
  103571. }
  103572. /**
  103573. * Helper class used to enable XR
  103574. * @see https://doc.babylonjs.com/how_to/webxr
  103575. */
  103576. export class WebXRExperienceHelper implements IDisposable {
  103577. private scene;
  103578. /**
  103579. * 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
  103580. */
  103581. container: AbstractMesh;
  103582. /**
  103583. * Camera used to render xr content
  103584. */
  103585. camera: WebXRCamera;
  103586. /**
  103587. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  103588. */
  103589. state: WebXRState;
  103590. private _setState;
  103591. private static _TmpVector;
  103592. /**
  103593. * Fires when the state of the experience helper has changed
  103594. */
  103595. onStateChangedObservable: Observable<WebXRState>;
  103596. /** @hidden */
  103597. _sessionManager: WebXRSessionManager;
  103598. private _nonVRCamera;
  103599. private _originalSceneAutoClear;
  103600. private _supported;
  103601. /**
  103602. * Creates the experience helper
  103603. * @param scene the scene to attach the experience helper to
  103604. * @returns a promise for the experience helper
  103605. */
  103606. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  103607. /**
  103608. * Creates a WebXRExperienceHelper
  103609. * @param scene The scene the helper should be created in
  103610. */
  103611. private constructor();
  103612. /**
  103613. * Exits XR mode and returns the scene to its original state
  103614. * @returns promise that resolves after xr mode has exited
  103615. */
  103616. exitXRAsync(): Promise<void>;
  103617. /**
  103618. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  103619. * @param sessionCreationOptions options for the XR session
  103620. * @param frameOfReference frame of reference of the XR session
  103621. * @returns promise that resolves after xr mode has entered
  103622. */
  103623. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  103624. /**
  103625. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  103626. * @param ray ray to cast into the environment
  103627. * @returns Promise which resolves with a collision point in the environment if it exists
  103628. */
  103629. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  103630. /**
  103631. * Updates the global position of the camera by moving the camera's container
  103632. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  103633. * @param position The desired global position of the camera
  103634. */
  103635. setPositionOfCameraUsingContainer(position: Vector3): void;
  103636. /**
  103637. * Rotates the xr camera by rotating the camera's container around the camera's position
  103638. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  103639. * @param rotation the desired quaternion rotation to apply to the camera
  103640. */
  103641. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  103642. /**
  103643. * Checks if the creation options are supported by the xr session
  103644. * @param options creation options
  103645. * @returns true if supported
  103646. */
  103647. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103648. /**
  103649. * Disposes of the experience helper
  103650. */
  103651. dispose(): void;
  103652. }
  103653. }
  103654. declare module BABYLON {
  103655. /**
  103656. * Button which can be used to enter a different mode of XR
  103657. */
  103658. export class WebXREnterExitUIButton {
  103659. /** button element */
  103660. element: HTMLElement;
  103661. /** XR initialization options for the button */
  103662. initializationOptions: XRSessionCreationOptions;
  103663. /**
  103664. * Creates a WebXREnterExitUIButton
  103665. * @param element button element
  103666. * @param initializationOptions XR initialization options for the button
  103667. */
  103668. constructor(
  103669. /** button element */
  103670. element: HTMLElement,
  103671. /** XR initialization options for the button */
  103672. initializationOptions: XRSessionCreationOptions);
  103673. /**
  103674. * Overwritable function which can be used to update the button's visuals when the state changes
  103675. * @param activeButton the current active button in the UI
  103676. */
  103677. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  103678. }
  103679. /**
  103680. * Options to create the webXR UI
  103681. */
  103682. export class WebXREnterExitUIOptions {
  103683. /**
  103684. * Context to enter xr with
  103685. */
  103686. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  103687. /**
  103688. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  103689. */
  103690. customButtons?: Array<WebXREnterExitUIButton>;
  103691. }
  103692. /**
  103693. * UI to allow the user to enter/exit XR mode
  103694. */
  103695. export class WebXREnterExitUI implements IDisposable {
  103696. private scene;
  103697. private _overlay;
  103698. private _buttons;
  103699. private _activeButton;
  103700. /**
  103701. * Fired every time the active button is changed.
  103702. *
  103703. * When xr is entered via a button that launches xr that button will be the callback parameter
  103704. *
  103705. * When exiting xr the callback parameter will be null)
  103706. */
  103707. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  103708. /**
  103709. * Creates UI to allow the user to enter/exit XR mode
  103710. * @param scene the scene to add the ui to
  103711. * @param helper the xr experience helper to enter/exit xr with
  103712. * @param options options to configure the UI
  103713. * @returns the created ui
  103714. */
  103715. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  103716. private constructor();
  103717. private _updateButtons;
  103718. /**
  103719. * Disposes of the object
  103720. */
  103721. dispose(): void;
  103722. }
  103723. }
  103724. declare module BABYLON {
  103725. /**
  103726. * Represents an XR input
  103727. */
  103728. export class WebXRController {
  103729. /**
  103730. * 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
  103731. */
  103732. grip?: AbstractMesh;
  103733. /**
  103734. * Pointer which can be used to select objects or attach a visible laser to
  103735. */
  103736. pointer: AbstractMesh;
  103737. /**
  103738. * Creates the controller
  103739. * @see https://doc.babylonjs.com/how_to/webxr
  103740. * @param scene the scene which the controller should be associated to
  103741. */
  103742. constructor(scene: Scene);
  103743. /**
  103744. * Disposes of the object
  103745. */
  103746. dispose(): void;
  103747. }
  103748. /**
  103749. * XR input used to track XR inputs such as controllers/rays
  103750. */
  103751. export class WebXRInput implements IDisposable {
  103752. private helper;
  103753. /**
  103754. * XR controllers being tracked
  103755. */
  103756. controllers: Array<WebXRController>;
  103757. private _tmpMatrix;
  103758. private _frameObserver;
  103759. /**
  103760. * Initializes the WebXRInput
  103761. * @param helper experience helper which the input should be created for
  103762. */
  103763. constructor(helper: WebXRExperienceHelper);
  103764. /**
  103765. * Disposes of the object
  103766. */
  103767. dispose(): void;
  103768. }
  103769. }
  103770. declare module BABYLON {
  103771. /**
  103772. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  103773. */
  103774. export class WebXRManagedOutputCanvas implements IDisposable {
  103775. private _canvas;
  103776. /**
  103777. * xrpresent context of the canvas which can be used to display/mirror xr content
  103778. */
  103779. canvasContext: Nullable<WebGLRenderingContext>;
  103780. /**
  103781. * Initializes the canvas to be added/removed upon entering/exiting xr
  103782. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  103783. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  103784. */
  103785. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  103786. /**
  103787. * Disposes of the object
  103788. */
  103789. dispose(): void;
  103790. private _setManagedOutputCanvas;
  103791. private _addCanvas;
  103792. private _removeCanvas;
  103793. }
  103794. }
  103795. declare module BABYLON {
  103796. /**
  103797. * Contains an array of blocks representing the octree
  103798. */
  103799. export interface IOctreeContainer<T> {
  103800. /**
  103801. * Blocks within the octree
  103802. */
  103803. blocks: Array<OctreeBlock<T>>;
  103804. }
  103805. /**
  103806. * Class used to store a cell in an octree
  103807. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103808. */
  103809. export class OctreeBlock<T> {
  103810. /**
  103811. * Gets the content of the current block
  103812. */
  103813. entries: T[];
  103814. /**
  103815. * Gets the list of block children
  103816. */
  103817. blocks: Array<OctreeBlock<T>>;
  103818. private _depth;
  103819. private _maxDepth;
  103820. private _capacity;
  103821. private _minPoint;
  103822. private _maxPoint;
  103823. private _boundingVectors;
  103824. private _creationFunc;
  103825. /**
  103826. * Creates a new block
  103827. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  103828. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  103829. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103830. * @param depth defines the current depth of this block in the octree
  103831. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  103832. * @param creationFunc defines a callback to call when an element is added to the block
  103833. */
  103834. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  103835. /**
  103836. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103837. */
  103838. readonly capacity: number;
  103839. /**
  103840. * Gets the minimum vector (in world space) of the block's bounding box
  103841. */
  103842. readonly minPoint: Vector3;
  103843. /**
  103844. * Gets the maximum vector (in world space) of the block's bounding box
  103845. */
  103846. readonly maxPoint: Vector3;
  103847. /**
  103848. * Add a new element to this block
  103849. * @param entry defines the element to add
  103850. */
  103851. addEntry(entry: T): void;
  103852. /**
  103853. * Remove an element from this block
  103854. * @param entry defines the element to remove
  103855. */
  103856. removeEntry(entry: T): void;
  103857. /**
  103858. * Add an array of elements to this block
  103859. * @param entries defines the array of elements to add
  103860. */
  103861. addEntries(entries: T[]): void;
  103862. /**
  103863. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  103864. * @param frustumPlanes defines the frustum planes to test
  103865. * @param selection defines the array to store current content if selection is positive
  103866. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103867. */
  103868. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103869. /**
  103870. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  103871. * @param sphereCenter defines the bounding sphere center
  103872. * @param sphereRadius defines the bounding sphere radius
  103873. * @param selection defines the array to store current content if selection is positive
  103874. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103875. */
  103876. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103877. /**
  103878. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  103879. * @param ray defines the ray to test with
  103880. * @param selection defines the array to store current content if selection is positive
  103881. */
  103882. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  103883. /**
  103884. * Subdivide the content into child blocks (this block will then be empty)
  103885. */
  103886. createInnerBlocks(): void;
  103887. /**
  103888. * @hidden
  103889. */
  103890. 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;
  103891. }
  103892. }
  103893. declare module BABYLON {
  103894. /**
  103895. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  103896. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103897. */
  103898. export class Octree<T> {
  103899. /** 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.) */
  103900. maxDepth: number;
  103901. /**
  103902. * Blocks within the octree containing objects
  103903. */
  103904. blocks: Array<OctreeBlock<T>>;
  103905. /**
  103906. * Content stored in the octree
  103907. */
  103908. dynamicContent: T[];
  103909. private _maxBlockCapacity;
  103910. private _selectionContent;
  103911. private _creationFunc;
  103912. /**
  103913. * Creates a octree
  103914. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103915. * @param creationFunc function to be used to instatiate the octree
  103916. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103917. * @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.)
  103918. */
  103919. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103920. /** 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.) */
  103921. maxDepth?: number);
  103922. /**
  103923. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103924. * @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);
  103925. * @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);
  103926. * @param entries meshes to be added to the octree blocks
  103927. */
  103928. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103929. /**
  103930. * Adds a mesh to the octree
  103931. * @param entry Mesh to add to the octree
  103932. */
  103933. addMesh(entry: T): void;
  103934. /**
  103935. * Remove an element from the octree
  103936. * @param entry defines the element to remove
  103937. */
  103938. removeMesh(entry: T): void;
  103939. /**
  103940. * Selects an array of meshes within the frustum
  103941. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103942. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103943. * @returns array of meshes within the frustum
  103944. */
  103945. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103946. /**
  103947. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103948. * @param sphereCenter defines the bounding sphere center
  103949. * @param sphereRadius defines the bounding sphere radius
  103950. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103951. * @returns an array of objects that intersect the sphere
  103952. */
  103953. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103954. /**
  103955. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103956. * @param ray defines the ray to test with
  103957. * @returns array of intersected objects
  103958. */
  103959. intersectsRay(ray: Ray): SmartArray<T>;
  103960. /**
  103961. * Adds a mesh into the octree block if it intersects the block
  103962. */
  103963. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103964. /**
  103965. * Adds a submesh into the octree block if it intersects the block
  103966. */
  103967. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103968. }
  103969. }
  103970. declare module BABYLON {
  103971. interface Scene {
  103972. /**
  103973. * @hidden
  103974. * Backing Filed
  103975. */
  103976. _selectionOctree: Octree<AbstractMesh>;
  103977. /**
  103978. * Gets the octree used to boost mesh selection (picking)
  103979. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103980. */
  103981. selectionOctree: Octree<AbstractMesh>;
  103982. /**
  103983. * Creates or updates the octree used to boost selection (picking)
  103984. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103985. * @param maxCapacity defines the maximum capacity per leaf
  103986. * @param maxDepth defines the maximum depth of the octree
  103987. * @returns an octree of AbstractMesh
  103988. */
  103989. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103990. }
  103991. interface AbstractMesh {
  103992. /**
  103993. * @hidden
  103994. * Backing Field
  103995. */
  103996. _submeshesOctree: Octree<SubMesh>;
  103997. /**
  103998. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103999. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  104000. * @param maxCapacity defines the maximum size of each block (64 by default)
  104001. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  104002. * @returns the new octree
  104003. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  104004. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  104005. */
  104006. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  104007. }
  104008. /**
  104009. * Defines the octree scene component responsible to manage any octrees
  104010. * in a given scene.
  104011. */
  104012. export class OctreeSceneComponent {
  104013. /**
  104014. * The component name help to identify the component in the list of scene components.
  104015. */
  104016. readonly name: string;
  104017. /**
  104018. * The scene the component belongs to.
  104019. */
  104020. scene: Scene;
  104021. /**
  104022. * Indicates if the meshes have been checked to make sure they are isEnabled()
  104023. */
  104024. readonly checksIsEnabled: boolean;
  104025. /**
  104026. * Creates a new instance of the component for the given scene
  104027. * @param scene Defines the scene to register the component in
  104028. */
  104029. constructor(scene: Scene);
  104030. /**
  104031. * Registers the component in a given scene
  104032. */
  104033. register(): void;
  104034. /**
  104035. * Return the list of active meshes
  104036. * @returns the list of active meshes
  104037. */
  104038. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  104039. /**
  104040. * Return the list of active sub meshes
  104041. * @param mesh The mesh to get the candidates sub meshes from
  104042. * @returns the list of active sub meshes
  104043. */
  104044. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  104045. private _tempRay;
  104046. /**
  104047. * Return the list of sub meshes intersecting with a given local ray
  104048. * @param mesh defines the mesh to find the submesh for
  104049. * @param localRay defines the ray in local space
  104050. * @returns the list of intersecting sub meshes
  104051. */
  104052. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  104053. /**
  104054. * Return the list of sub meshes colliding with a collider
  104055. * @param mesh defines the mesh to find the submesh for
  104056. * @param collider defines the collider to evaluate the collision against
  104057. * @returns the list of colliding sub meshes
  104058. */
  104059. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  104060. /**
  104061. * Rebuilds the elements related to this component in case of
  104062. * context lost for instance.
  104063. */
  104064. rebuild(): void;
  104065. /**
  104066. * Disposes the component and the associated ressources.
  104067. */
  104068. dispose(): void;
  104069. }
  104070. }
  104071. declare module BABYLON {
  104072. /**
  104073. * Renders a layer on top of an existing scene
  104074. */
  104075. export class UtilityLayerRenderer implements IDisposable {
  104076. /** the original scene that will be rendered on top of */
  104077. originalScene: Scene;
  104078. private _pointerCaptures;
  104079. private _lastPointerEvents;
  104080. private static _DefaultUtilityLayer;
  104081. private static _DefaultKeepDepthUtilityLayer;
  104082. private _sharedGizmoLight;
  104083. private _renderCamera;
  104084. /**
  104085. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  104086. * @returns the camera that is used when rendering the utility layer
  104087. */
  104088. getRenderCamera(): Nullable<Camera>;
  104089. /**
  104090. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  104091. * @param cam the camera that should be used when rendering the utility layer
  104092. */
  104093. setRenderCamera(cam: Nullable<Camera>): void;
  104094. /**
  104095. * @hidden
  104096. * Light which used by gizmos to get light shading
  104097. */
  104098. _getSharedGizmoLight(): HemisphericLight;
  104099. /**
  104100. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  104101. */
  104102. pickUtilitySceneFirst: boolean;
  104103. /**
  104104. * 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)
  104105. */
  104106. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  104107. /**
  104108. * 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)
  104109. */
  104110. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  104111. /**
  104112. * The scene that is rendered on top of the original scene
  104113. */
  104114. utilityLayerScene: Scene;
  104115. /**
  104116. * If the utility layer should automatically be rendered on top of existing scene
  104117. */
  104118. shouldRender: boolean;
  104119. /**
  104120. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  104121. */
  104122. onlyCheckPointerDownEvents: boolean;
  104123. /**
  104124. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  104125. */
  104126. processAllEvents: boolean;
  104127. /**
  104128. * Observable raised when the pointer move from the utility layer scene to the main scene
  104129. */
  104130. onPointerOutObservable: Observable<number>;
  104131. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  104132. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  104133. private _afterRenderObserver;
  104134. private _sceneDisposeObserver;
  104135. private _originalPointerObserver;
  104136. /**
  104137. * Instantiates a UtilityLayerRenderer
  104138. * @param originalScene the original scene that will be rendered on top of
  104139. * @param handleEvents boolean indicating if the utility layer should handle events
  104140. */
  104141. constructor(
  104142. /** the original scene that will be rendered on top of */
  104143. originalScene: Scene, handleEvents?: boolean);
  104144. private _notifyObservers;
  104145. /**
  104146. * Renders the utility layers scene on top of the original scene
  104147. */
  104148. render(): void;
  104149. /**
  104150. * Disposes of the renderer
  104151. */
  104152. dispose(): void;
  104153. private _updateCamera;
  104154. }
  104155. }
  104156. declare module BABYLON {
  104157. /**
  104158. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  104159. */
  104160. export class Gizmo implements IDisposable {
  104161. /** The utility layer the gizmo will be added to */
  104162. gizmoLayer: UtilityLayerRenderer;
  104163. /**
  104164. * The root mesh of the gizmo
  104165. */
  104166. _rootMesh: Mesh;
  104167. private _attachedMesh;
  104168. /**
  104169. * Ratio for the scale of the gizmo (Default: 1)
  104170. */
  104171. scaleRatio: number;
  104172. /**
  104173. * If a custom mesh has been set (Default: false)
  104174. */
  104175. protected _customMeshSet: boolean;
  104176. /**
  104177. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  104178. * * When set, interactions will be enabled
  104179. */
  104180. attachedMesh: Nullable<AbstractMesh>;
  104181. /**
  104182. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  104183. * @param mesh The mesh to replace the default mesh of the gizmo
  104184. */
  104185. setCustomMesh(mesh: Mesh): void;
  104186. /**
  104187. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  104188. */
  104189. updateGizmoRotationToMatchAttachedMesh: boolean;
  104190. /**
  104191. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  104192. */
  104193. updateGizmoPositionToMatchAttachedMesh: boolean;
  104194. /**
  104195. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  104196. */
  104197. protected _updateScale: boolean;
  104198. protected _interactionsEnabled: boolean;
  104199. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104200. private _beforeRenderObserver;
  104201. private _tempVector;
  104202. /**
  104203. * Creates a gizmo
  104204. * @param gizmoLayer The utility layer the gizmo will be added to
  104205. */
  104206. constructor(
  104207. /** The utility layer the gizmo will be added to */
  104208. gizmoLayer?: UtilityLayerRenderer);
  104209. /**
  104210. * Updates the gizmo to match the attached mesh's position/rotation
  104211. */
  104212. protected _update(): void;
  104213. /**
  104214. * Disposes of the gizmo
  104215. */
  104216. dispose(): void;
  104217. }
  104218. }
  104219. declare module BABYLON {
  104220. /**
  104221. * Single plane drag gizmo
  104222. */
  104223. export class PlaneDragGizmo extends Gizmo {
  104224. /**
  104225. * Drag behavior responsible for the gizmos dragging interactions
  104226. */
  104227. dragBehavior: PointerDragBehavior;
  104228. private _pointerObserver;
  104229. /**
  104230. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104231. */
  104232. snapDistance: number;
  104233. /**
  104234. * Event that fires each time the gizmo snaps to a new location.
  104235. * * snapDistance is the the change in distance
  104236. */
  104237. onSnapObservable: Observable<{
  104238. snapDistance: number;
  104239. }>;
  104240. private _plane;
  104241. private _coloredMaterial;
  104242. private _hoverMaterial;
  104243. private _isEnabled;
  104244. private _parent;
  104245. /** @hidden */
  104246. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  104247. /** @hidden */
  104248. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104249. /**
  104250. * Creates a PlaneDragGizmo
  104251. * @param gizmoLayer The utility layer the gizmo will be added to
  104252. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  104253. * @param color The color of the gizmo
  104254. */
  104255. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104256. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104257. /**
  104258. * If the gizmo is enabled
  104259. */
  104260. isEnabled: boolean;
  104261. /**
  104262. * Disposes of the gizmo
  104263. */
  104264. dispose(): void;
  104265. }
  104266. }
  104267. declare module BABYLON {
  104268. /**
  104269. * Gizmo that enables dragging a mesh along 3 axis
  104270. */
  104271. export class PositionGizmo extends Gizmo {
  104272. /**
  104273. * Internal gizmo used for interactions on the x axis
  104274. */
  104275. xGizmo: AxisDragGizmo;
  104276. /**
  104277. * Internal gizmo used for interactions on the y axis
  104278. */
  104279. yGizmo: AxisDragGizmo;
  104280. /**
  104281. * Internal gizmo used for interactions on the z axis
  104282. */
  104283. zGizmo: AxisDragGizmo;
  104284. /**
  104285. * Internal gizmo used for interactions on the yz plane
  104286. */
  104287. xPlaneGizmo: PlaneDragGizmo;
  104288. /**
  104289. * Internal gizmo used for interactions on the xz plane
  104290. */
  104291. yPlaneGizmo: PlaneDragGizmo;
  104292. /**
  104293. * Internal gizmo used for interactions on the xy plane
  104294. */
  104295. zPlaneGizmo: PlaneDragGizmo;
  104296. /**
  104297. * private variables
  104298. */
  104299. private _meshAttached;
  104300. private _updateGizmoRotationToMatchAttachedMesh;
  104301. private _snapDistance;
  104302. private _scaleRatio;
  104303. /** Fires an event when any of it's sub gizmos are dragged */
  104304. onDragStartObservable: Observable<{}>;
  104305. /** Fires an event when any of it's sub gizmos are released from dragging */
  104306. onDragEndObservable: Observable<{}>;
  104307. /**
  104308. * If set to true, planar drag is enabled
  104309. */
  104310. private _planarGizmoEnabled;
  104311. attachedMesh: Nullable<AbstractMesh>;
  104312. /**
  104313. * Creates a PositionGizmo
  104314. * @param gizmoLayer The utility layer the gizmo will be added to
  104315. */
  104316. constructor(gizmoLayer?: UtilityLayerRenderer);
  104317. /**
  104318. * If the planar drag gizmo is enabled
  104319. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  104320. */
  104321. planarGizmoEnabled: boolean;
  104322. updateGizmoRotationToMatchAttachedMesh: boolean;
  104323. /**
  104324. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104325. */
  104326. snapDistance: number;
  104327. /**
  104328. * Ratio for the scale of the gizmo (Default: 1)
  104329. */
  104330. scaleRatio: number;
  104331. /**
  104332. * Disposes of the gizmo
  104333. */
  104334. dispose(): void;
  104335. /**
  104336. * CustomMeshes are not supported by this gizmo
  104337. * @param mesh The mesh to replace the default mesh of the gizmo
  104338. */
  104339. setCustomMesh(mesh: Mesh): void;
  104340. }
  104341. }
  104342. declare module BABYLON {
  104343. /**
  104344. * Single axis drag gizmo
  104345. */
  104346. export class AxisDragGizmo extends Gizmo {
  104347. /**
  104348. * Drag behavior responsible for the gizmos dragging interactions
  104349. */
  104350. dragBehavior: PointerDragBehavior;
  104351. private _pointerObserver;
  104352. /**
  104353. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104354. */
  104355. snapDistance: number;
  104356. /**
  104357. * Event that fires each time the gizmo snaps to a new location.
  104358. * * snapDistance is the the change in distance
  104359. */
  104360. onSnapObservable: Observable<{
  104361. snapDistance: number;
  104362. }>;
  104363. private _isEnabled;
  104364. private _parent;
  104365. private _arrow;
  104366. private _coloredMaterial;
  104367. private _hoverMaterial;
  104368. /** @hidden */
  104369. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  104370. /** @hidden */
  104371. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104372. /**
  104373. * Creates an AxisDragGizmo
  104374. * @param gizmoLayer The utility layer the gizmo will be added to
  104375. * @param dragAxis The axis which the gizmo will be able to drag on
  104376. * @param color The color of the gizmo
  104377. */
  104378. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104379. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104380. /**
  104381. * If the gizmo is enabled
  104382. */
  104383. isEnabled: boolean;
  104384. /**
  104385. * Disposes of the gizmo
  104386. */
  104387. dispose(): void;
  104388. }
  104389. }
  104390. declare module BABYLON.Debug {
  104391. /**
  104392. * The Axes viewer will show 3 axes in a specific point in space
  104393. */
  104394. export class AxesViewer {
  104395. private _xAxis;
  104396. private _yAxis;
  104397. private _zAxis;
  104398. private _scaleLinesFactor;
  104399. private _instanced;
  104400. /**
  104401. * Gets the hosting scene
  104402. */
  104403. scene: Scene;
  104404. /**
  104405. * Gets or sets a number used to scale line length
  104406. */
  104407. scaleLines: number;
  104408. /** Gets the node hierarchy used to render x-axis */
  104409. readonly xAxis: TransformNode;
  104410. /** Gets the node hierarchy used to render y-axis */
  104411. readonly yAxis: TransformNode;
  104412. /** Gets the node hierarchy used to render z-axis */
  104413. readonly zAxis: TransformNode;
  104414. /**
  104415. * Creates a new AxesViewer
  104416. * @param scene defines the hosting scene
  104417. * @param scaleLines defines a number used to scale line length (1 by default)
  104418. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  104419. * @param xAxis defines the node hierarchy used to render the x-axis
  104420. * @param yAxis defines the node hierarchy used to render the y-axis
  104421. * @param zAxis defines the node hierarchy used to render the z-axis
  104422. */
  104423. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  104424. /**
  104425. * Force the viewer to update
  104426. * @param position defines the position of the viewer
  104427. * @param xaxis defines the x axis of the viewer
  104428. * @param yaxis defines the y axis of the viewer
  104429. * @param zaxis defines the z axis of the viewer
  104430. */
  104431. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  104432. /**
  104433. * Creates an instance of this axes viewer.
  104434. * @returns a new axes viewer with instanced meshes
  104435. */
  104436. createInstance(): AxesViewer;
  104437. /** Releases resources */
  104438. dispose(): void;
  104439. private static _SetRenderingGroupId;
  104440. }
  104441. }
  104442. declare module BABYLON.Debug {
  104443. /**
  104444. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  104445. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  104446. */
  104447. export class BoneAxesViewer extends AxesViewer {
  104448. /**
  104449. * Gets or sets the target mesh where to display the axes viewer
  104450. */
  104451. mesh: Nullable<Mesh>;
  104452. /**
  104453. * Gets or sets the target bone where to display the axes viewer
  104454. */
  104455. bone: Nullable<Bone>;
  104456. /** Gets current position */
  104457. pos: Vector3;
  104458. /** Gets direction of X axis */
  104459. xaxis: Vector3;
  104460. /** Gets direction of Y axis */
  104461. yaxis: Vector3;
  104462. /** Gets direction of Z axis */
  104463. zaxis: Vector3;
  104464. /**
  104465. * Creates a new BoneAxesViewer
  104466. * @param scene defines the hosting scene
  104467. * @param bone defines the target bone
  104468. * @param mesh defines the target mesh
  104469. * @param scaleLines defines a scaling factor for line length (1 by default)
  104470. */
  104471. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  104472. /**
  104473. * Force the viewer to update
  104474. */
  104475. update(): void;
  104476. /** Releases resources */
  104477. dispose(): void;
  104478. }
  104479. }
  104480. declare module BABYLON {
  104481. /**
  104482. * Interface used to define scene explorer extensibility option
  104483. */
  104484. export interface IExplorerExtensibilityOption {
  104485. /**
  104486. * Define the option label
  104487. */
  104488. label: string;
  104489. /**
  104490. * Defines the action to execute on click
  104491. */
  104492. action: (entity: any) => void;
  104493. }
  104494. /**
  104495. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  104496. */
  104497. export interface IExplorerExtensibilityGroup {
  104498. /**
  104499. * Defines a predicate to test if a given type mut be extended
  104500. */
  104501. predicate: (entity: any) => boolean;
  104502. /**
  104503. * Gets the list of options added to a type
  104504. */
  104505. entries: IExplorerExtensibilityOption[];
  104506. }
  104507. /**
  104508. * Interface used to define the options to use to create the Inspector
  104509. */
  104510. export interface IInspectorOptions {
  104511. /**
  104512. * Display in overlay mode (default: false)
  104513. */
  104514. overlay?: boolean;
  104515. /**
  104516. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  104517. */
  104518. globalRoot?: HTMLElement;
  104519. /**
  104520. * Display the Scene explorer
  104521. */
  104522. showExplorer?: boolean;
  104523. /**
  104524. * Display the property inspector
  104525. */
  104526. showInspector?: boolean;
  104527. /**
  104528. * Display in embed mode (both panes on the right)
  104529. */
  104530. embedMode?: boolean;
  104531. /**
  104532. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  104533. */
  104534. handleResize?: boolean;
  104535. /**
  104536. * Allow the panes to popup (default: true)
  104537. */
  104538. enablePopup?: boolean;
  104539. /**
  104540. * Allow the panes to be closed by users (default: true)
  104541. */
  104542. enableClose?: boolean;
  104543. /**
  104544. * Optional list of extensibility entries
  104545. */
  104546. explorerExtensibility?: IExplorerExtensibilityGroup[];
  104547. /**
  104548. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  104549. */
  104550. inspectorURL?: string;
  104551. }
  104552. interface Scene {
  104553. /**
  104554. * @hidden
  104555. * Backing field
  104556. */
  104557. _debugLayer: DebugLayer;
  104558. /**
  104559. * Gets the debug layer (aka Inspector) associated with the scene
  104560. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104561. */
  104562. debugLayer: DebugLayer;
  104563. }
  104564. /**
  104565. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104566. * what is happening in your scene
  104567. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104568. */
  104569. export class DebugLayer {
  104570. /**
  104571. * Define the url to get the inspector script from.
  104572. * By default it uses the babylonjs CDN.
  104573. * @ignoreNaming
  104574. */
  104575. static InspectorURL: string;
  104576. private _scene;
  104577. private BJSINSPECTOR;
  104578. private _onPropertyChangedObservable?;
  104579. /**
  104580. * Observable triggered when a property is changed through the inspector.
  104581. */
  104582. readonly onPropertyChangedObservable: any;
  104583. /**
  104584. * Instantiates a new debug layer.
  104585. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104586. * what is happening in your scene
  104587. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104588. * @param scene Defines the scene to inspect
  104589. */
  104590. constructor(scene: Scene);
  104591. /** Creates the inspector window. */
  104592. private _createInspector;
  104593. /**
  104594. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  104595. * @param entity defines the entity to select
  104596. * @param lineContainerTitle defines the specific block to highlight
  104597. */
  104598. select(entity: any, lineContainerTitle?: string): void;
  104599. /** Get the inspector from bundle or global */
  104600. private _getGlobalInspector;
  104601. /**
  104602. * Get if the inspector is visible or not.
  104603. * @returns true if visible otherwise, false
  104604. */
  104605. isVisible(): boolean;
  104606. /**
  104607. * Hide the inspector and close its window.
  104608. */
  104609. hide(): void;
  104610. /**
  104611. * Launch the debugLayer.
  104612. * @param config Define the configuration of the inspector
  104613. * @return a promise fulfilled when the debug layer is visible
  104614. */
  104615. show(config?: IInspectorOptions): Promise<DebugLayer>;
  104616. }
  104617. }
  104618. declare module BABYLON {
  104619. /**
  104620. * Class containing static functions to help procedurally build meshes
  104621. */
  104622. export class BoxBuilder {
  104623. /**
  104624. * Creates a box mesh
  104625. * * The parameter `size` sets the size (float) of each box side (default 1)
  104626. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  104627. * * 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)
  104628. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104632. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  104633. * @param name defines the name of the mesh
  104634. * @param options defines the options used to create the mesh
  104635. * @param scene defines the hosting scene
  104636. * @returns the box mesh
  104637. */
  104638. static CreateBox(name: string, options: {
  104639. size?: number;
  104640. width?: number;
  104641. height?: number;
  104642. depth?: number;
  104643. faceUV?: Vector4[];
  104644. faceColors?: Color4[];
  104645. sideOrientation?: number;
  104646. frontUVs?: Vector4;
  104647. backUVs?: Vector4;
  104648. wrap?: boolean;
  104649. topBaseAt?: number;
  104650. bottomBaseAt?: number;
  104651. updatable?: boolean;
  104652. }, scene?: Nullable<Scene>): Mesh;
  104653. }
  104654. }
  104655. declare module BABYLON {
  104656. /**
  104657. * Class containing static functions to help procedurally build meshes
  104658. */
  104659. export class SphereBuilder {
  104660. /**
  104661. * Creates a sphere mesh
  104662. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104663. * * 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`)
  104664. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104665. * * 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
  104666. * * 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)
  104667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104668. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104670. * @param name defines the name of the mesh
  104671. * @param options defines the options used to create the mesh
  104672. * @param scene defines the hosting scene
  104673. * @returns the sphere mesh
  104674. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104675. */
  104676. static CreateSphere(name: string, options: {
  104677. segments?: number;
  104678. diameter?: number;
  104679. diameterX?: number;
  104680. diameterY?: number;
  104681. diameterZ?: number;
  104682. arc?: number;
  104683. slice?: number;
  104684. sideOrientation?: number;
  104685. frontUVs?: Vector4;
  104686. backUVs?: Vector4;
  104687. updatable?: boolean;
  104688. }, scene: any): Mesh;
  104689. }
  104690. }
  104691. declare module BABYLON.Debug {
  104692. /**
  104693. * Used to show the physics impostor around the specific mesh
  104694. */
  104695. export class PhysicsViewer {
  104696. /** @hidden */
  104697. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  104698. /** @hidden */
  104699. protected _meshes: Array<Nullable<AbstractMesh>>;
  104700. /** @hidden */
  104701. protected _scene: Nullable<Scene>;
  104702. /** @hidden */
  104703. protected _numMeshes: number;
  104704. /** @hidden */
  104705. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  104706. private _renderFunction;
  104707. private _utilityLayer;
  104708. private _debugBoxMesh;
  104709. private _debugSphereMesh;
  104710. private _debugCylinderMesh;
  104711. private _debugMaterial;
  104712. private _debugMeshMeshes;
  104713. /**
  104714. * Creates a new PhysicsViewer
  104715. * @param scene defines the hosting scene
  104716. */
  104717. constructor(scene: Scene);
  104718. /** @hidden */
  104719. protected _updateDebugMeshes(): void;
  104720. /**
  104721. * Renders a specified physic impostor
  104722. * @param impostor defines the impostor to render
  104723. * @param targetMesh defines the mesh represented by the impostor
  104724. * @returns the new debug mesh used to render the impostor
  104725. */
  104726. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  104727. /**
  104728. * Hides a specified physic impostor
  104729. * @param impostor defines the impostor to hide
  104730. */
  104731. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  104732. private _getDebugMaterial;
  104733. private _getDebugBoxMesh;
  104734. private _getDebugSphereMesh;
  104735. private _getDebugCylinderMesh;
  104736. private _getDebugMeshMesh;
  104737. private _getDebugMesh;
  104738. /** Releases all resources */
  104739. dispose(): void;
  104740. }
  104741. }
  104742. declare module BABYLON {
  104743. /**
  104744. * Class containing static functions to help procedurally build meshes
  104745. */
  104746. export class LinesBuilder {
  104747. /**
  104748. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104749. * * 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
  104750. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104751. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104752. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104753. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104754. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104755. * * 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
  104756. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104759. * @param name defines the name of the new line system
  104760. * @param options defines the options used to create the line system
  104761. * @param scene defines the hosting scene
  104762. * @returns a new line system mesh
  104763. */
  104764. static CreateLineSystem(name: string, options: {
  104765. lines: Vector3[][];
  104766. updatable?: boolean;
  104767. instance?: Nullable<LinesMesh>;
  104768. colors?: Nullable<Color4[][]>;
  104769. useVertexAlpha?: boolean;
  104770. }, scene: Nullable<Scene>): LinesMesh;
  104771. /**
  104772. * Creates a line mesh
  104773. * 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
  104774. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104775. * * The parameter `points` is an array successive Vector3
  104776. * * 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
  104777. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104778. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104779. * * When updating an instance, remember that only point positions can change, not the number of points
  104780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104781. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104782. * @param name defines the name of the new line system
  104783. * @param options defines the options used to create the line system
  104784. * @param scene defines the hosting scene
  104785. * @returns a new line mesh
  104786. */
  104787. static CreateLines(name: string, options: {
  104788. points: Vector3[];
  104789. updatable?: boolean;
  104790. instance?: Nullable<LinesMesh>;
  104791. colors?: Color4[];
  104792. useVertexAlpha?: boolean;
  104793. }, scene?: Nullable<Scene>): LinesMesh;
  104794. /**
  104795. * Creates a dashed line mesh
  104796. * * 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
  104797. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104798. * * The parameter `points` is an array successive Vector3
  104799. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104800. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104801. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104802. * * 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
  104803. * * When updating an instance, remember that only point positions can change, not the number of points
  104804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104805. * @param name defines the name of the mesh
  104806. * @param options defines the options used to create the mesh
  104807. * @param scene defines the hosting scene
  104808. * @returns the dashed line mesh
  104809. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104810. */
  104811. static CreateDashedLines(name: string, options: {
  104812. points: Vector3[];
  104813. dashSize?: number;
  104814. gapSize?: number;
  104815. dashNb?: number;
  104816. updatable?: boolean;
  104817. instance?: LinesMesh;
  104818. }, scene?: Nullable<Scene>): LinesMesh;
  104819. }
  104820. }
  104821. declare module BABYLON {
  104822. /**
  104823. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104824. * in order to better appreciate the issue one might have.
  104825. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104826. */
  104827. export class RayHelper {
  104828. /**
  104829. * Defines the ray we are currently tryin to visualize.
  104830. */
  104831. ray: Nullable<Ray>;
  104832. private _renderPoints;
  104833. private _renderLine;
  104834. private _renderFunction;
  104835. private _scene;
  104836. private _updateToMeshFunction;
  104837. private _attachedToMesh;
  104838. private _meshSpaceDirection;
  104839. private _meshSpaceOrigin;
  104840. /**
  104841. * Helper function to create a colored helper in a scene in one line.
  104842. * @param ray Defines the ray we are currently tryin to visualize
  104843. * @param scene Defines the scene the ray is used in
  104844. * @param color Defines the color we want to see the ray in
  104845. * @returns The newly created ray helper.
  104846. */
  104847. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  104848. /**
  104849. * Instantiate a new ray helper.
  104850. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104851. * in order to better appreciate the issue one might have.
  104852. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104853. * @param ray Defines the ray we are currently tryin to visualize
  104854. */
  104855. constructor(ray: Ray);
  104856. /**
  104857. * Shows the ray we are willing to debug.
  104858. * @param scene Defines the scene the ray needs to be rendered in
  104859. * @param color Defines the color the ray needs to be rendered in
  104860. */
  104861. show(scene: Scene, color?: Color3): void;
  104862. /**
  104863. * Hides the ray we are debugging.
  104864. */
  104865. hide(): void;
  104866. private _render;
  104867. /**
  104868. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  104869. * @param mesh Defines the mesh we want the helper attached to
  104870. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  104871. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  104872. * @param length Defines the length of the ray
  104873. */
  104874. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  104875. /**
  104876. * Detach the ray helper from the mesh it has previously been attached to.
  104877. */
  104878. detachFromMesh(): void;
  104879. private _updateToMesh;
  104880. /**
  104881. * Dispose the helper and release its associated resources.
  104882. */
  104883. dispose(): void;
  104884. }
  104885. }
  104886. declare module BABYLON.Debug {
  104887. /**
  104888. * Class used to render a debug view of a given skeleton
  104889. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  104890. */
  104891. export class SkeletonViewer {
  104892. /** defines the skeleton to render */
  104893. skeleton: Skeleton;
  104894. /** defines the mesh attached to the skeleton */
  104895. mesh: AbstractMesh;
  104896. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104897. autoUpdateBonesMatrices: boolean;
  104898. /** defines the rendering group id to use with the viewer */
  104899. renderingGroupId: number;
  104900. /** Gets or sets the color used to render the skeleton */
  104901. color: Color3;
  104902. private _scene;
  104903. private _debugLines;
  104904. private _debugMesh;
  104905. private _isEnabled;
  104906. private _renderFunction;
  104907. private _utilityLayer;
  104908. /**
  104909. * Returns the mesh used to render the bones
  104910. */
  104911. readonly debugMesh: Nullable<LinesMesh>;
  104912. /**
  104913. * Creates a new SkeletonViewer
  104914. * @param skeleton defines the skeleton to render
  104915. * @param mesh defines the mesh attached to the skeleton
  104916. * @param scene defines the hosting scene
  104917. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104918. * @param renderingGroupId defines the rendering group id to use with the viewer
  104919. */
  104920. constructor(
  104921. /** defines the skeleton to render */
  104922. skeleton: Skeleton,
  104923. /** defines the mesh attached to the skeleton */
  104924. mesh: AbstractMesh, scene: Scene,
  104925. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104926. autoUpdateBonesMatrices?: boolean,
  104927. /** defines the rendering group id to use with the viewer */
  104928. renderingGroupId?: number);
  104929. /** Gets or sets a boolean indicating if the viewer is enabled */
  104930. isEnabled: boolean;
  104931. private _getBonePosition;
  104932. private _getLinesForBonesWithLength;
  104933. private _getLinesForBonesNoLength;
  104934. /** Update the viewer to sync with current skeleton state */
  104935. update(): void;
  104936. /** Release associated resources */
  104937. dispose(): void;
  104938. }
  104939. }
  104940. declare module BABYLON {
  104941. /**
  104942. * Options to create the null engine
  104943. */
  104944. export class NullEngineOptions {
  104945. /**
  104946. * Render width (Default: 512)
  104947. */
  104948. renderWidth: number;
  104949. /**
  104950. * Render height (Default: 256)
  104951. */
  104952. renderHeight: number;
  104953. /**
  104954. * Texture size (Default: 512)
  104955. */
  104956. textureSize: number;
  104957. /**
  104958. * If delta time between frames should be constant
  104959. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104960. */
  104961. deterministicLockstep: boolean;
  104962. /**
  104963. * Maximum about of steps between frames (Default: 4)
  104964. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104965. */
  104966. lockstepMaxSteps: number;
  104967. }
  104968. /**
  104969. * The null engine class provides support for headless version of babylon.js.
  104970. * This can be used in server side scenario or for testing purposes
  104971. */
  104972. export class NullEngine extends Engine {
  104973. private _options;
  104974. /**
  104975. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104976. */
  104977. isDeterministicLockStep(): boolean;
  104978. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104979. getLockstepMaxSteps(): number;
  104980. /**
  104981. * Sets hardware scaling, used to save performance if needed
  104982. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104983. */
  104984. getHardwareScalingLevel(): number;
  104985. constructor(options?: NullEngineOptions);
  104986. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104987. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104988. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104989. getRenderWidth(useScreen?: boolean): number;
  104990. getRenderHeight(useScreen?: boolean): number;
  104991. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104992. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104993. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104994. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104995. bindSamplers(effect: Effect): void;
  104996. enableEffect(effect: Effect): void;
  104997. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104998. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104999. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  105000. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  105001. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  105002. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  105003. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  105004. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  105005. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  105006. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  105007. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  105008. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  105009. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  105010. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  105011. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  105012. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  105013. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  105014. setFloat(uniform: WebGLUniformLocation, value: number): void;
  105015. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  105016. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  105017. setBool(uniform: WebGLUniformLocation, bool: number): void;
  105018. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  105019. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  105020. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  105021. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  105022. bindBuffers(vertexBuffers: {
  105023. [key: string]: VertexBuffer;
  105024. }, indexBuffer: DataBuffer, effect: Effect): void;
  105025. wipeCaches(bruteForce?: boolean): void;
  105026. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  105027. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  105028. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105029. /** @hidden */
  105030. _createTexture(): WebGLTexture;
  105031. /** @hidden */
  105032. _releaseTexture(texture: InternalTexture): void;
  105033. 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;
  105034. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  105035. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  105036. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  105037. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  105038. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  105039. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  105040. areAllEffectsReady(): boolean;
  105041. /**
  105042. * @hidden
  105043. * Get the current error code of the webGL context
  105044. * @returns the error code
  105045. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105046. */
  105047. getError(): number;
  105048. /** @hidden */
  105049. _getUnpackAlignement(): number;
  105050. /** @hidden */
  105051. _unpackFlipY(value: boolean): void;
  105052. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  105053. /**
  105054. * Updates a dynamic vertex buffer.
  105055. * @param vertexBuffer the vertex buffer to update
  105056. * @param data the data used to update the vertex buffer
  105057. * @param byteOffset the byte offset of the data (optional)
  105058. * @param byteLength the byte length of the data (optional)
  105059. */
  105060. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  105061. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  105062. /** @hidden */
  105063. _bindTexture(channel: number, texture: InternalTexture): void;
  105064. /** @hidden */
  105065. _releaseBuffer(buffer: DataBuffer): boolean;
  105066. releaseEffects(): void;
  105067. displayLoadingUI(): void;
  105068. hideLoadingUI(): void;
  105069. /** @hidden */
  105070. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105071. /** @hidden */
  105072. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105073. /** @hidden */
  105074. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105075. /** @hidden */
  105076. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  105077. }
  105078. }
  105079. declare module BABYLON {
  105080. /** @hidden */
  105081. export class _OcclusionDataStorage {
  105082. /** @hidden */
  105083. occlusionInternalRetryCounter: number;
  105084. /** @hidden */
  105085. isOcclusionQueryInProgress: boolean;
  105086. /** @hidden */
  105087. isOccluded: boolean;
  105088. /** @hidden */
  105089. occlusionRetryCount: number;
  105090. /** @hidden */
  105091. occlusionType: number;
  105092. /** @hidden */
  105093. occlusionQueryAlgorithmType: number;
  105094. }
  105095. interface Engine {
  105096. /**
  105097. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  105098. * @return the new query
  105099. */
  105100. createQuery(): WebGLQuery;
  105101. /**
  105102. * Delete and release a webGL query
  105103. * @param query defines the query to delete
  105104. * @return the current engine
  105105. */
  105106. deleteQuery(query: WebGLQuery): Engine;
  105107. /**
  105108. * Check if a given query has resolved and got its value
  105109. * @param query defines the query to check
  105110. * @returns true if the query got its value
  105111. */
  105112. isQueryResultAvailable(query: WebGLQuery): boolean;
  105113. /**
  105114. * Gets the value of a given query
  105115. * @param query defines the query to check
  105116. * @returns the value of the query
  105117. */
  105118. getQueryResult(query: WebGLQuery): number;
  105119. /**
  105120. * Initiates an occlusion query
  105121. * @param algorithmType defines the algorithm to use
  105122. * @param query defines the query to use
  105123. * @returns the current engine
  105124. * @see http://doc.babylonjs.com/features/occlusionquery
  105125. */
  105126. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  105127. /**
  105128. * Ends an occlusion query
  105129. * @see http://doc.babylonjs.com/features/occlusionquery
  105130. * @param algorithmType defines the algorithm to use
  105131. * @returns the current engine
  105132. */
  105133. endOcclusionQuery(algorithmType: number): Engine;
  105134. /**
  105135. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  105136. * Please note that only one query can be issued at a time
  105137. * @returns a time token used to track the time span
  105138. */
  105139. startTimeQuery(): Nullable<_TimeToken>;
  105140. /**
  105141. * Ends a time query
  105142. * @param token defines the token used to measure the time span
  105143. * @returns the time spent (in ns)
  105144. */
  105145. endTimeQuery(token: _TimeToken): int;
  105146. /** @hidden */
  105147. _currentNonTimestampToken: Nullable<_TimeToken>;
  105148. /** @hidden */
  105149. _createTimeQuery(): WebGLQuery;
  105150. /** @hidden */
  105151. _deleteTimeQuery(query: WebGLQuery): void;
  105152. /** @hidden */
  105153. _getGlAlgorithmType(algorithmType: number): number;
  105154. /** @hidden */
  105155. _getTimeQueryResult(query: WebGLQuery): any;
  105156. /** @hidden */
  105157. _getTimeQueryAvailability(query: WebGLQuery): any;
  105158. }
  105159. interface AbstractMesh {
  105160. /**
  105161. * Backing filed
  105162. * @hidden
  105163. */
  105164. __occlusionDataStorage: _OcclusionDataStorage;
  105165. /**
  105166. * Access property
  105167. * @hidden
  105168. */
  105169. _occlusionDataStorage: _OcclusionDataStorage;
  105170. /**
  105171. * 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.
  105172. * The default value is -1 which means don't break the query and wait till the result
  105173. * @see http://doc.babylonjs.com/features/occlusionquery
  105174. */
  105175. occlusionRetryCount: number;
  105176. /**
  105177. * 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:
  105178. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  105179. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  105180. * * 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.
  105181. * @see http://doc.babylonjs.com/features/occlusionquery
  105182. */
  105183. occlusionType: number;
  105184. /**
  105185. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  105186. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  105187. * * 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.
  105188. * @see http://doc.babylonjs.com/features/occlusionquery
  105189. */
  105190. occlusionQueryAlgorithmType: number;
  105191. /**
  105192. * 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
  105193. * @see http://doc.babylonjs.com/features/occlusionquery
  105194. */
  105195. isOccluded: boolean;
  105196. /**
  105197. * Flag to check the progress status of the query
  105198. * @see http://doc.babylonjs.com/features/occlusionquery
  105199. */
  105200. isOcclusionQueryInProgress: boolean;
  105201. }
  105202. }
  105203. declare module BABYLON {
  105204. /** @hidden */
  105205. export var _forceTransformFeedbackToBundle: boolean;
  105206. interface Engine {
  105207. /**
  105208. * Creates a webGL transform feedback object
  105209. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  105210. * @returns the webGL transform feedback object
  105211. */
  105212. createTransformFeedback(): WebGLTransformFeedback;
  105213. /**
  105214. * Delete a webGL transform feedback object
  105215. * @param value defines the webGL transform feedback object to delete
  105216. */
  105217. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  105218. /**
  105219. * Bind a webGL transform feedback object to the webgl context
  105220. * @param value defines the webGL transform feedback object to bind
  105221. */
  105222. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  105223. /**
  105224. * Begins a transform feedback operation
  105225. * @param usePoints defines if points or triangles must be used
  105226. */
  105227. beginTransformFeedback(usePoints: boolean): void;
  105228. /**
  105229. * Ends a transform feedback operation
  105230. */
  105231. endTransformFeedback(): void;
  105232. /**
  105233. * Specify the varyings to use with transform feedback
  105234. * @param program defines the associated webGL program
  105235. * @param value defines the list of strings representing the varying names
  105236. */
  105237. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  105238. /**
  105239. * Bind a webGL buffer for a transform feedback operation
  105240. * @param value defines the webGL buffer to bind
  105241. */
  105242. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  105243. }
  105244. }
  105245. declare module BABYLON {
  105246. /**
  105247. * Creation options of the multi render target texture.
  105248. */
  105249. export interface IMultiRenderTargetOptions {
  105250. /**
  105251. * Define if the texture needs to create mip maps after render.
  105252. */
  105253. generateMipMaps?: boolean;
  105254. /**
  105255. * Define the types of all the draw buffers we want to create
  105256. */
  105257. types?: number[];
  105258. /**
  105259. * Define the sampling modes of all the draw buffers we want to create
  105260. */
  105261. samplingModes?: number[];
  105262. /**
  105263. * Define if a depth buffer is required
  105264. */
  105265. generateDepthBuffer?: boolean;
  105266. /**
  105267. * Define if a stencil buffer is required
  105268. */
  105269. generateStencilBuffer?: boolean;
  105270. /**
  105271. * Define if a depth texture is required instead of a depth buffer
  105272. */
  105273. generateDepthTexture?: boolean;
  105274. /**
  105275. * Define the number of desired draw buffers
  105276. */
  105277. textureCount?: number;
  105278. /**
  105279. * Define if aspect ratio should be adapted to the texture or stay the scene one
  105280. */
  105281. doNotChangeAspectRatio?: boolean;
  105282. /**
  105283. * Define the default type of the buffers we are creating
  105284. */
  105285. defaultType?: number;
  105286. }
  105287. /**
  105288. * A multi render target, like a render target provides the ability to render to a texture.
  105289. * Unlike the render target, it can render to several draw buffers in one draw.
  105290. * This is specially interesting in deferred rendering or for any effects requiring more than
  105291. * just one color from a single pass.
  105292. */
  105293. export class MultiRenderTarget extends RenderTargetTexture {
  105294. private _internalTextures;
  105295. private _textures;
  105296. private _multiRenderTargetOptions;
  105297. /**
  105298. * Get if draw buffers are currently supported by the used hardware and browser.
  105299. */
  105300. readonly isSupported: boolean;
  105301. /**
  105302. * Get the list of textures generated by the multi render target.
  105303. */
  105304. readonly textures: Texture[];
  105305. /**
  105306. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  105307. */
  105308. readonly depthTexture: Texture;
  105309. /**
  105310. * Set the wrapping mode on U of all the textures we are rendering to.
  105311. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  105312. */
  105313. wrapU: number;
  105314. /**
  105315. * Set the wrapping mode on V of all the textures we are rendering to.
  105316. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  105317. */
  105318. wrapV: number;
  105319. /**
  105320. * Instantiate a new multi render target texture.
  105321. * A multi render target, like a render target provides the ability to render to a texture.
  105322. * Unlike the render target, it can render to several draw buffers in one draw.
  105323. * This is specially interesting in deferred rendering or for any effects requiring more than
  105324. * just one color from a single pass.
  105325. * @param name Define the name of the texture
  105326. * @param size Define the size of the buffers to render to
  105327. * @param count Define the number of target we are rendering into
  105328. * @param scene Define the scene the texture belongs to
  105329. * @param options Define the options used to create the multi render target
  105330. */
  105331. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  105332. /** @hidden */
  105333. _rebuild(): void;
  105334. private _createInternalTextures;
  105335. private _createTextures;
  105336. /**
  105337. * Define the number of samples used if MSAA is enabled.
  105338. */
  105339. samples: number;
  105340. /**
  105341. * Resize all the textures in the multi render target.
  105342. * Be carrefull as it will recreate all the data in the new texture.
  105343. * @param size Define the new size
  105344. */
  105345. resize(size: any): void;
  105346. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  105347. /**
  105348. * Dispose the render targets and their associated resources
  105349. */
  105350. dispose(): void;
  105351. /**
  105352. * Release all the underlying texture used as draw buffers.
  105353. */
  105354. releaseInternalTextures(): void;
  105355. }
  105356. }
  105357. declare module BABYLON {
  105358. interface Engine {
  105359. /**
  105360. * Unbind a list of render target textures from the webGL context
  105361. * This is used only when drawBuffer extension or webGL2 are active
  105362. * @param textures defines the render target textures to unbind
  105363. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105364. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105365. */
  105366. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  105367. /**
  105368. * Create a multi render target texture
  105369. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  105370. * @param size defines the size of the texture
  105371. * @param options defines the creation options
  105372. * @returns the cube texture as an InternalTexture
  105373. */
  105374. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  105375. /**
  105376. * Update the sample count for a given multiple render target texture
  105377. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  105378. * @param textures defines the textures to update
  105379. * @param samples defines the sample count to set
  105380. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  105381. */
  105382. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  105383. }
  105384. }
  105385. declare module BABYLON {
  105386. /**
  105387. * Gather the list of clipboard event types as constants.
  105388. */
  105389. export class ClipboardEventTypes {
  105390. /**
  105391. * The clipboard event is fired when a copy command is active (pressed).
  105392. */
  105393. static readonly COPY: number;
  105394. /**
  105395. * The clipboard event is fired when a cut command is active (pressed).
  105396. */
  105397. static readonly CUT: number;
  105398. /**
  105399. * The clipboard event is fired when a paste command is active (pressed).
  105400. */
  105401. static readonly PASTE: number;
  105402. }
  105403. /**
  105404. * This class is used to store clipboard related info for the onClipboardObservable event.
  105405. */
  105406. export class ClipboardInfo {
  105407. /**
  105408. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105409. */
  105410. type: number;
  105411. /**
  105412. * Defines the related dom event
  105413. */
  105414. event: ClipboardEvent;
  105415. /**
  105416. *Creates an instance of ClipboardInfo.
  105417. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  105418. * @param event Defines the related dom event
  105419. */
  105420. constructor(
  105421. /**
  105422. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105423. */
  105424. type: number,
  105425. /**
  105426. * Defines the related dom event
  105427. */
  105428. event: ClipboardEvent);
  105429. /**
  105430. * Get the clipboard event's type from the keycode.
  105431. * @param keyCode Defines the keyCode for the current keyboard event.
  105432. * @return {number}
  105433. */
  105434. static GetTypeFromCharacter(keyCode: number): number;
  105435. }
  105436. }
  105437. declare module BABYLON {
  105438. /**
  105439. * Class used to represent data loading progression
  105440. */
  105441. export class SceneLoaderProgressEvent {
  105442. /** defines if data length to load can be evaluated */
  105443. readonly lengthComputable: boolean;
  105444. /** defines the loaded data length */
  105445. readonly loaded: number;
  105446. /** defines the data length to load */
  105447. readonly total: number;
  105448. /**
  105449. * Create a new progress event
  105450. * @param lengthComputable defines if data length to load can be evaluated
  105451. * @param loaded defines the loaded data length
  105452. * @param total defines the data length to load
  105453. */
  105454. constructor(
  105455. /** defines if data length to load can be evaluated */
  105456. lengthComputable: boolean,
  105457. /** defines the loaded data length */
  105458. loaded: number,
  105459. /** defines the data length to load */
  105460. total: number);
  105461. /**
  105462. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  105463. * @param event defines the source event
  105464. * @returns a new SceneLoaderProgressEvent
  105465. */
  105466. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105467. }
  105468. /**
  105469. * Interface used by SceneLoader plugins to define supported file extensions
  105470. */
  105471. export interface ISceneLoaderPluginExtensions {
  105472. /**
  105473. * Defines the list of supported extensions
  105474. */
  105475. [extension: string]: {
  105476. isBinary: boolean;
  105477. };
  105478. }
  105479. /**
  105480. * Interface used by SceneLoader plugin factory
  105481. */
  105482. export interface ISceneLoaderPluginFactory {
  105483. /**
  105484. * Defines the name of the factory
  105485. */
  105486. name: string;
  105487. /**
  105488. * Function called to create a new plugin
  105489. * @return the new plugin
  105490. */
  105491. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105492. /**
  105493. * Boolean indicating if the plugin can direct load specific data
  105494. */
  105495. canDirectLoad?: (data: string) => boolean;
  105496. }
  105497. /**
  105498. * Interface used to define a SceneLoader plugin
  105499. */
  105500. export interface ISceneLoaderPlugin {
  105501. /**
  105502. * The friendly name of this plugin.
  105503. */
  105504. name: string;
  105505. /**
  105506. * The file extensions supported by this plugin.
  105507. */
  105508. extensions: string | ISceneLoaderPluginExtensions;
  105509. /**
  105510. * Import meshes into a scene.
  105511. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105512. * @param scene The scene to import into
  105513. * @param data The data to import
  105514. * @param rootUrl The root url for scene and resources
  105515. * @param meshes The meshes array to import into
  105516. * @param particleSystems The particle systems array to import into
  105517. * @param skeletons The skeletons array to import into
  105518. * @param onError The callback when import fails
  105519. * @returns True if successful or false otherwise
  105520. */
  105521. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105522. /**
  105523. * Load into a scene.
  105524. * @param scene The scene to load into
  105525. * @param data The data to import
  105526. * @param rootUrl The root url for scene and resources
  105527. * @param onError The callback when import fails
  105528. * @returns true if successful or false otherwise
  105529. */
  105530. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105531. /**
  105532. * The callback that returns true if the data can be directly loaded.
  105533. */
  105534. canDirectLoad?: (data: string) => boolean;
  105535. /**
  105536. * The callback that allows custom handling of the root url based on the response url.
  105537. */
  105538. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105539. /**
  105540. * Load into an asset container.
  105541. * @param scene The scene to load into
  105542. * @param data The data to import
  105543. * @param rootUrl The root url for scene and resources
  105544. * @param onError The callback when import fails
  105545. * @returns The loaded asset container
  105546. */
  105547. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105548. }
  105549. /**
  105550. * Interface used to define an async SceneLoader plugin
  105551. */
  105552. export interface ISceneLoaderPluginAsync {
  105553. /**
  105554. * The friendly name of this plugin.
  105555. */
  105556. name: string;
  105557. /**
  105558. * The file extensions supported by this plugin.
  105559. */
  105560. extensions: string | ISceneLoaderPluginExtensions;
  105561. /**
  105562. * Import meshes into a scene.
  105563. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105564. * @param scene The scene to import into
  105565. * @param data The data to import
  105566. * @param rootUrl The root url for scene and resources
  105567. * @param onProgress The callback when the load progresses
  105568. * @param fileName Defines the name of the file to load
  105569. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105570. */
  105571. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105572. meshes: AbstractMesh[];
  105573. particleSystems: IParticleSystem[];
  105574. skeletons: Skeleton[];
  105575. animationGroups: AnimationGroup[];
  105576. }>;
  105577. /**
  105578. * Load into a scene.
  105579. * @param scene The scene to load into
  105580. * @param data The data to import
  105581. * @param rootUrl The root url for scene and resources
  105582. * @param onProgress The callback when the load progresses
  105583. * @param fileName Defines the name of the file to load
  105584. * @returns Nothing
  105585. */
  105586. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105587. /**
  105588. * The callback that returns true if the data can be directly loaded.
  105589. */
  105590. canDirectLoad?: (data: string) => boolean;
  105591. /**
  105592. * The callback that allows custom handling of the root url based on the response url.
  105593. */
  105594. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105595. /**
  105596. * Load into an asset container.
  105597. * @param scene The scene to load into
  105598. * @param data The data to import
  105599. * @param rootUrl The root url for scene and resources
  105600. * @param onProgress The callback when the load progresses
  105601. * @param fileName Defines the name of the file to load
  105602. * @returns The loaded asset container
  105603. */
  105604. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105605. }
  105606. /**
  105607. * Class used to load scene from various file formats using registered plugins
  105608. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105609. */
  105610. export class SceneLoader {
  105611. /**
  105612. * No logging while loading
  105613. */
  105614. static readonly NO_LOGGING: number;
  105615. /**
  105616. * Minimal logging while loading
  105617. */
  105618. static readonly MINIMAL_LOGGING: number;
  105619. /**
  105620. * Summary logging while loading
  105621. */
  105622. static readonly SUMMARY_LOGGING: number;
  105623. /**
  105624. * Detailled logging while loading
  105625. */
  105626. static readonly DETAILED_LOGGING: number;
  105627. /**
  105628. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105629. */
  105630. static ForceFullSceneLoadingForIncremental: boolean;
  105631. /**
  105632. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105633. */
  105634. static ShowLoadingScreen: boolean;
  105635. /**
  105636. * Defines the current logging level (while loading the scene)
  105637. * @ignorenaming
  105638. */
  105639. static loggingLevel: number;
  105640. /**
  105641. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105642. */
  105643. static CleanBoneMatrixWeights: boolean;
  105644. /**
  105645. * Event raised when a plugin is used to load a scene
  105646. */
  105647. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105648. private static _registeredPlugins;
  105649. private static _getDefaultPlugin;
  105650. private static _getPluginForExtension;
  105651. private static _getPluginForDirectLoad;
  105652. private static _getPluginForFilename;
  105653. private static _getDirectLoad;
  105654. private static _loadData;
  105655. private static _getFileInfo;
  105656. /**
  105657. * Gets a plugin that can load the given extension
  105658. * @param extension defines the extension to load
  105659. * @returns a plugin or null if none works
  105660. */
  105661. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105662. /**
  105663. * Gets a boolean indicating that the given extension can be loaded
  105664. * @param extension defines the extension to load
  105665. * @returns true if the extension is supported
  105666. */
  105667. static IsPluginForExtensionAvailable(extension: string): boolean;
  105668. /**
  105669. * Adds a new plugin to the list of registered plugins
  105670. * @param plugin defines the plugin to add
  105671. */
  105672. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105673. /**
  105674. * Import meshes into a scene
  105675. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105676. * @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)
  105677. * @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)
  105678. * @param scene the instance of BABYLON.Scene to append to
  105679. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105680. * @param onProgress a callback with a progress event for each file being loaded
  105681. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105682. * @param pluginExtension the extension used to determine the plugin
  105683. * @returns The loaded plugin
  105684. */
  105685. 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>;
  105686. /**
  105687. * Import meshes into a scene
  105688. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105689. * @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)
  105690. * @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)
  105691. * @param scene the instance of BABYLON.Scene to append to
  105692. * @param onProgress a callback with a progress event for each file being loaded
  105693. * @param pluginExtension the extension used to determine the plugin
  105694. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105695. */
  105696. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105697. meshes: AbstractMesh[];
  105698. particleSystems: IParticleSystem[];
  105699. skeletons: Skeleton[];
  105700. animationGroups: AnimationGroup[];
  105701. }>;
  105702. /**
  105703. * Load a scene
  105704. * @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)
  105705. * @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)
  105706. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105707. * @param onSuccess a callback with the scene when import succeeds
  105708. * @param onProgress a callback with a progress event for each file being loaded
  105709. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105710. * @param pluginExtension the extension used to determine the plugin
  105711. * @returns The loaded plugin
  105712. */
  105713. 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>;
  105714. /**
  105715. * Load a scene
  105716. * @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)
  105717. * @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)
  105718. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105719. * @param onProgress a callback with a progress event for each file being loaded
  105720. * @param pluginExtension the extension used to determine the plugin
  105721. * @returns The loaded scene
  105722. */
  105723. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105724. /**
  105725. * Append a scene
  105726. * @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)
  105727. * @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)
  105728. * @param scene is the instance of BABYLON.Scene to append to
  105729. * @param onSuccess a callback with the scene when import succeeds
  105730. * @param onProgress a callback with a progress event for each file being loaded
  105731. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105732. * @param pluginExtension the extension used to determine the plugin
  105733. * @returns The loaded plugin
  105734. */
  105735. 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>;
  105736. /**
  105737. * Append a scene
  105738. * @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)
  105739. * @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)
  105740. * @param scene is the instance of BABYLON.Scene to append to
  105741. * @param onProgress a callback with a progress event for each file being loaded
  105742. * @param pluginExtension the extension used to determine the plugin
  105743. * @returns The given scene
  105744. */
  105745. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105746. /**
  105747. * Load a scene into an asset container
  105748. * @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)
  105749. * @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)
  105750. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105751. * @param onSuccess a callback with the scene when import succeeds
  105752. * @param onProgress a callback with a progress event for each file being loaded
  105753. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105754. * @param pluginExtension the extension used to determine the plugin
  105755. * @returns The loaded plugin
  105756. */
  105757. 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>;
  105758. /**
  105759. * Load a scene into an asset container
  105760. * @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)
  105761. * @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)
  105762. * @param scene is the instance of Scene to append to
  105763. * @param onProgress a callback with a progress event for each file being loaded
  105764. * @param pluginExtension the extension used to determine the plugin
  105765. * @returns The loaded asset container
  105766. */
  105767. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105768. }
  105769. }
  105770. declare module BABYLON {
  105771. /**
  105772. * Google Daydream controller
  105773. */
  105774. export class DaydreamController extends WebVRController {
  105775. /**
  105776. * Base Url for the controller model.
  105777. */
  105778. static MODEL_BASE_URL: string;
  105779. /**
  105780. * File name for the controller model.
  105781. */
  105782. static MODEL_FILENAME: string;
  105783. /**
  105784. * Gamepad Id prefix used to identify Daydream Controller.
  105785. */
  105786. static readonly GAMEPAD_ID_PREFIX: string;
  105787. /**
  105788. * Creates a new DaydreamController from a gamepad
  105789. * @param vrGamepad the gamepad that the controller should be created from
  105790. */
  105791. constructor(vrGamepad: any);
  105792. /**
  105793. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105794. * @param scene scene in which to add meshes
  105795. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105796. */
  105797. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105798. /**
  105799. * Called once for each button that changed state since the last frame
  105800. * @param buttonIdx Which button index changed
  105801. * @param state New state of the button
  105802. * @param changes Which properties on the state changed since last frame
  105803. */
  105804. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105805. }
  105806. }
  105807. declare module BABYLON {
  105808. /**
  105809. * Gear VR Controller
  105810. */
  105811. export class GearVRController extends WebVRController {
  105812. /**
  105813. * Base Url for the controller model.
  105814. */
  105815. static MODEL_BASE_URL: string;
  105816. /**
  105817. * File name for the controller model.
  105818. */
  105819. static MODEL_FILENAME: string;
  105820. /**
  105821. * Gamepad Id prefix used to identify this controller.
  105822. */
  105823. static readonly GAMEPAD_ID_PREFIX: string;
  105824. private readonly _buttonIndexToObservableNameMap;
  105825. /**
  105826. * Creates a new GearVRController from a gamepad
  105827. * @param vrGamepad the gamepad that the controller should be created from
  105828. */
  105829. constructor(vrGamepad: any);
  105830. /**
  105831. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105832. * @param scene scene in which to add meshes
  105833. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105834. */
  105835. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105836. /**
  105837. * Called once for each button that changed state since the last frame
  105838. * @param buttonIdx Which button index changed
  105839. * @param state New state of the button
  105840. * @param changes Which properties on the state changed since last frame
  105841. */
  105842. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105843. }
  105844. }
  105845. declare module BABYLON {
  105846. /**
  105847. * Generic Controller
  105848. */
  105849. export class GenericController extends WebVRController {
  105850. /**
  105851. * Base Url for the controller model.
  105852. */
  105853. static readonly MODEL_BASE_URL: string;
  105854. /**
  105855. * File name for the controller model.
  105856. */
  105857. static readonly MODEL_FILENAME: string;
  105858. /**
  105859. * Creates a new GenericController from a gamepad
  105860. * @param vrGamepad the gamepad that the controller should be created from
  105861. */
  105862. constructor(vrGamepad: any);
  105863. /**
  105864. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105865. * @param scene scene in which to add meshes
  105866. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105867. */
  105868. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105869. /**
  105870. * Called once for each button that changed state since the last frame
  105871. * @param buttonIdx Which button index changed
  105872. * @param state New state of the button
  105873. * @param changes Which properties on the state changed since last frame
  105874. */
  105875. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105876. }
  105877. }
  105878. declare module BABYLON {
  105879. /**
  105880. * Oculus Touch Controller
  105881. */
  105882. export class OculusTouchController extends WebVRController {
  105883. /**
  105884. * Base Url for the controller model.
  105885. */
  105886. static MODEL_BASE_URL: string;
  105887. /**
  105888. * File name for the left controller model.
  105889. */
  105890. static MODEL_LEFT_FILENAME: string;
  105891. /**
  105892. * File name for the right controller model.
  105893. */
  105894. static MODEL_RIGHT_FILENAME: string;
  105895. /**
  105896. * Base Url for the Quest controller model.
  105897. */
  105898. static QUEST_MODEL_BASE_URL: string;
  105899. /**
  105900. * @hidden
  105901. * If the controllers are running on a device that needs the updated Quest controller models
  105902. */
  105903. static _IsQuest: boolean;
  105904. /**
  105905. * Fired when the secondary trigger on this controller is modified
  105906. */
  105907. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105908. /**
  105909. * Fired when the thumb rest on this controller is modified
  105910. */
  105911. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105912. /**
  105913. * Creates a new OculusTouchController from a gamepad
  105914. * @param vrGamepad the gamepad that the controller should be created from
  105915. */
  105916. constructor(vrGamepad: any);
  105917. /**
  105918. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105919. * @param scene scene in which to add meshes
  105920. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105921. */
  105922. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105923. /**
  105924. * Fired when the A button on this controller is modified
  105925. */
  105926. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105927. /**
  105928. * Fired when the B button on this controller is modified
  105929. */
  105930. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105931. /**
  105932. * Fired when the X button on this controller is modified
  105933. */
  105934. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105935. /**
  105936. * Fired when the Y button on this controller is modified
  105937. */
  105938. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105939. /**
  105940. * Called once for each button that changed state since the last frame
  105941. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105942. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105943. * 2) secondary trigger (same)
  105944. * 3) A (right) X (left), touch, pressed = value
  105945. * 4) B / Y
  105946. * 5) thumb rest
  105947. * @param buttonIdx Which button index changed
  105948. * @param state New state of the button
  105949. * @param changes Which properties on the state changed since last frame
  105950. */
  105951. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105952. }
  105953. }
  105954. declare module BABYLON {
  105955. /**
  105956. * Vive Controller
  105957. */
  105958. export class ViveController extends WebVRController {
  105959. /**
  105960. * Base Url for the controller model.
  105961. */
  105962. static MODEL_BASE_URL: string;
  105963. /**
  105964. * File name for the controller model.
  105965. */
  105966. static MODEL_FILENAME: string;
  105967. /**
  105968. * Creates a new ViveController from a gamepad
  105969. * @param vrGamepad the gamepad that the controller should be created from
  105970. */
  105971. constructor(vrGamepad: any);
  105972. /**
  105973. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105974. * @param scene scene in which to add meshes
  105975. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105976. */
  105977. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105978. /**
  105979. * Fired when the left button on this controller is modified
  105980. */
  105981. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105982. /**
  105983. * Fired when the right button on this controller is modified
  105984. */
  105985. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105986. /**
  105987. * Fired when the menu button on this controller is modified
  105988. */
  105989. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105990. /**
  105991. * Called once for each button that changed state since the last frame
  105992. * Vive mapping:
  105993. * 0: touchpad
  105994. * 1: trigger
  105995. * 2: left AND right buttons
  105996. * 3: menu button
  105997. * @param buttonIdx Which button index changed
  105998. * @param state New state of the button
  105999. * @param changes Which properties on the state changed since last frame
  106000. */
  106001. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106002. }
  106003. }
  106004. declare module BABYLON {
  106005. /**
  106006. * Defines the WindowsMotionController object that the state of the windows motion controller
  106007. */
  106008. export class WindowsMotionController extends WebVRController {
  106009. /**
  106010. * The base url used to load the left and right controller models
  106011. */
  106012. static MODEL_BASE_URL: string;
  106013. /**
  106014. * The name of the left controller model file
  106015. */
  106016. static MODEL_LEFT_FILENAME: string;
  106017. /**
  106018. * The name of the right controller model file
  106019. */
  106020. static MODEL_RIGHT_FILENAME: string;
  106021. /**
  106022. * The controller name prefix for this controller type
  106023. */
  106024. static readonly GAMEPAD_ID_PREFIX: string;
  106025. /**
  106026. * The controller id pattern for this controller type
  106027. */
  106028. private static readonly GAMEPAD_ID_PATTERN;
  106029. private _loadedMeshInfo;
  106030. private readonly _mapping;
  106031. /**
  106032. * Fired when the trackpad on this controller is clicked
  106033. */
  106034. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  106035. /**
  106036. * Fired when the trackpad on this controller is modified
  106037. */
  106038. onTrackpadValuesChangedObservable: Observable<StickValues>;
  106039. /**
  106040. * The current x and y values of this controller's trackpad
  106041. */
  106042. trackpad: StickValues;
  106043. /**
  106044. * Creates a new WindowsMotionController from a gamepad
  106045. * @param vrGamepad the gamepad that the controller should be created from
  106046. */
  106047. constructor(vrGamepad: any);
  106048. /**
  106049. * Fired when the trigger on this controller is modified
  106050. */
  106051. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106052. /**
  106053. * Fired when the menu button on this controller is modified
  106054. */
  106055. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106056. /**
  106057. * Fired when the grip button on this controller is modified
  106058. */
  106059. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106060. /**
  106061. * Fired when the thumbstick button on this controller is modified
  106062. */
  106063. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106064. /**
  106065. * Fired when the touchpad button on this controller is modified
  106066. */
  106067. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106068. /**
  106069. * Fired when the touchpad values on this controller are modified
  106070. */
  106071. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  106072. private _updateTrackpad;
  106073. /**
  106074. * Called once per frame by the engine.
  106075. */
  106076. update(): void;
  106077. /**
  106078. * Called once for each button that changed state since the last frame
  106079. * @param buttonIdx Which button index changed
  106080. * @param state New state of the button
  106081. * @param changes Which properties on the state changed since last frame
  106082. */
  106083. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106084. /**
  106085. * Moves the buttons on the controller mesh based on their current state
  106086. * @param buttonName the name of the button to move
  106087. * @param buttonValue the value of the button which determines the buttons new position
  106088. */
  106089. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  106090. /**
  106091. * Moves the axis on the controller mesh based on its current state
  106092. * @param axis the index of the axis
  106093. * @param axisValue the value of the axis which determines the meshes new position
  106094. * @hidden
  106095. */
  106096. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  106097. /**
  106098. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106099. * @param scene scene in which to add meshes
  106100. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106101. */
  106102. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  106103. /**
  106104. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  106105. * can be transformed by button presses and axes values, based on this._mapping.
  106106. *
  106107. * @param scene scene in which the meshes exist
  106108. * @param meshes list of meshes that make up the controller model to process
  106109. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  106110. */
  106111. private processModel;
  106112. private createMeshInfo;
  106113. /**
  106114. * Gets the ray of the controller in the direction the controller is pointing
  106115. * @param length the length the resulting ray should be
  106116. * @returns a ray in the direction the controller is pointing
  106117. */
  106118. getForwardRay(length?: number): Ray;
  106119. /**
  106120. * Disposes of the controller
  106121. */
  106122. dispose(): void;
  106123. }
  106124. }
  106125. declare module BABYLON {
  106126. /**
  106127. * Class containing static functions to help procedurally build meshes
  106128. */
  106129. export class PolyhedronBuilder {
  106130. /**
  106131. * Creates a polyhedron mesh
  106132. * * 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
  106133. * * The parameter `size` (positive float, default 1) sets the polygon size
  106134. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106135. * * 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`
  106136. * * 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
  106137. * * 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)`)
  106138. * * 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
  106139. * * 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
  106140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106143. * @param name defines the name of the mesh
  106144. * @param options defines the options used to create the mesh
  106145. * @param scene defines the hosting scene
  106146. * @returns the polyhedron mesh
  106147. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106148. */
  106149. static CreatePolyhedron(name: string, options: {
  106150. type?: number;
  106151. size?: number;
  106152. sizeX?: number;
  106153. sizeY?: number;
  106154. sizeZ?: number;
  106155. custom?: any;
  106156. faceUV?: Vector4[];
  106157. faceColors?: Color4[];
  106158. flat?: boolean;
  106159. updatable?: boolean;
  106160. sideOrientation?: number;
  106161. frontUVs?: Vector4;
  106162. backUVs?: Vector4;
  106163. }, scene?: Nullable<Scene>): Mesh;
  106164. }
  106165. }
  106166. declare module BABYLON {
  106167. /**
  106168. * Gizmo that enables scaling a mesh along 3 axis
  106169. */
  106170. export class ScaleGizmo extends Gizmo {
  106171. /**
  106172. * Internal gizmo used for interactions on the x axis
  106173. */
  106174. xGizmo: AxisScaleGizmo;
  106175. /**
  106176. * Internal gizmo used for interactions on the y axis
  106177. */
  106178. yGizmo: AxisScaleGizmo;
  106179. /**
  106180. * Internal gizmo used for interactions on the z axis
  106181. */
  106182. zGizmo: AxisScaleGizmo;
  106183. /**
  106184. * Internal gizmo used to scale all axis equally
  106185. */
  106186. uniformScaleGizmo: AxisScaleGizmo;
  106187. private _meshAttached;
  106188. private _updateGizmoRotationToMatchAttachedMesh;
  106189. private _snapDistance;
  106190. private _scaleRatio;
  106191. private _uniformScalingMesh;
  106192. private _octahedron;
  106193. /** Fires an event when any of it's sub gizmos are dragged */
  106194. onDragStartObservable: Observable<{}>;
  106195. /** Fires an event when any of it's sub gizmos are released from dragging */
  106196. onDragEndObservable: Observable<{}>;
  106197. attachedMesh: Nullable<AbstractMesh>;
  106198. /**
  106199. * Creates a ScaleGizmo
  106200. * @param gizmoLayer The utility layer the gizmo will be added to
  106201. */
  106202. constructor(gizmoLayer?: UtilityLayerRenderer);
  106203. updateGizmoRotationToMatchAttachedMesh: boolean;
  106204. /**
  106205. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106206. */
  106207. snapDistance: number;
  106208. /**
  106209. * Ratio for the scale of the gizmo (Default: 1)
  106210. */
  106211. scaleRatio: number;
  106212. /**
  106213. * Disposes of the gizmo
  106214. */
  106215. dispose(): void;
  106216. }
  106217. }
  106218. declare module BABYLON {
  106219. /**
  106220. * Single axis scale gizmo
  106221. */
  106222. export class AxisScaleGizmo extends Gizmo {
  106223. /**
  106224. * Drag behavior responsible for the gizmos dragging interactions
  106225. */
  106226. dragBehavior: PointerDragBehavior;
  106227. private _pointerObserver;
  106228. /**
  106229. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106230. */
  106231. snapDistance: number;
  106232. /**
  106233. * Event that fires each time the gizmo snaps to a new location.
  106234. * * snapDistance is the the change in distance
  106235. */
  106236. onSnapObservable: Observable<{
  106237. snapDistance: number;
  106238. }>;
  106239. /**
  106240. * If the scaling operation should be done on all axis (default: false)
  106241. */
  106242. uniformScaling: boolean;
  106243. private _isEnabled;
  106244. private _parent;
  106245. private _arrow;
  106246. private _coloredMaterial;
  106247. private _hoverMaterial;
  106248. /**
  106249. * Creates an AxisScaleGizmo
  106250. * @param gizmoLayer The utility layer the gizmo will be added to
  106251. * @param dragAxis The axis which the gizmo will be able to scale on
  106252. * @param color The color of the gizmo
  106253. */
  106254. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  106255. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106256. /**
  106257. * If the gizmo is enabled
  106258. */
  106259. isEnabled: boolean;
  106260. /**
  106261. * Disposes of the gizmo
  106262. */
  106263. dispose(): void;
  106264. /**
  106265. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  106266. * @param mesh The mesh to replace the default mesh of the gizmo
  106267. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  106268. */
  106269. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  106270. }
  106271. }
  106272. declare module BABYLON {
  106273. /**
  106274. * Bounding box gizmo
  106275. */
  106276. export class BoundingBoxGizmo extends Gizmo {
  106277. private _lineBoundingBox;
  106278. private _rotateSpheresParent;
  106279. private _scaleBoxesParent;
  106280. private _boundingDimensions;
  106281. private _renderObserver;
  106282. private _pointerObserver;
  106283. private _scaleDragSpeed;
  106284. private _tmpQuaternion;
  106285. private _tmpVector;
  106286. private _tmpRotationMatrix;
  106287. /**
  106288. * 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)
  106289. */
  106290. ignoreChildren: boolean;
  106291. /**
  106292. * 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)
  106293. */
  106294. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  106295. /**
  106296. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  106297. */
  106298. rotationSphereSize: number;
  106299. /**
  106300. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  106301. */
  106302. scaleBoxSize: number;
  106303. /**
  106304. * 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)
  106305. */
  106306. fixedDragMeshScreenSize: boolean;
  106307. /**
  106308. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  106309. */
  106310. fixedDragMeshScreenSizeDistanceFactor: number;
  106311. /**
  106312. * Fired when a rotation sphere or scale box is dragged
  106313. */
  106314. onDragStartObservable: Observable<{}>;
  106315. /**
  106316. * Fired when a scale box is dragged
  106317. */
  106318. onScaleBoxDragObservable: Observable<{}>;
  106319. /**
  106320. * Fired when a scale box drag is ended
  106321. */
  106322. onScaleBoxDragEndObservable: Observable<{}>;
  106323. /**
  106324. * Fired when a rotation sphere is dragged
  106325. */
  106326. onRotationSphereDragObservable: Observable<{}>;
  106327. /**
  106328. * Fired when a rotation sphere drag is ended
  106329. */
  106330. onRotationSphereDragEndObservable: Observable<{}>;
  106331. /**
  106332. * 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)
  106333. */
  106334. scalePivot: Nullable<Vector3>;
  106335. /**
  106336. * Mesh used as a pivot to rotate the attached mesh
  106337. */
  106338. private _anchorMesh;
  106339. private _existingMeshScale;
  106340. private _dragMesh;
  106341. private pointerDragBehavior;
  106342. private coloredMaterial;
  106343. private hoverColoredMaterial;
  106344. /**
  106345. * Sets the color of the bounding box gizmo
  106346. * @param color the color to set
  106347. */
  106348. setColor(color: Color3): void;
  106349. /**
  106350. * Creates an BoundingBoxGizmo
  106351. * @param gizmoLayer The utility layer the gizmo will be added to
  106352. * @param color The color of the gizmo
  106353. */
  106354. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  106355. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106356. private _selectNode;
  106357. /**
  106358. * Updates the bounding box information for the Gizmo
  106359. */
  106360. updateBoundingBox(): void;
  106361. private _updateRotationSpheres;
  106362. private _updateScaleBoxes;
  106363. /**
  106364. * Enables rotation on the specified axis and disables rotation on the others
  106365. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  106366. */
  106367. setEnabledRotationAxis(axis: string): void;
  106368. /**
  106369. * Enables/disables scaling
  106370. * @param enable if scaling should be enabled
  106371. */
  106372. setEnabledScaling(enable: boolean): void;
  106373. private _updateDummy;
  106374. /**
  106375. * Enables a pointer drag behavior on the bounding box of the gizmo
  106376. */
  106377. enableDragBehavior(): void;
  106378. /**
  106379. * Disposes of the gizmo
  106380. */
  106381. dispose(): void;
  106382. /**
  106383. * 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)
  106384. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  106385. * @returns the bounding box mesh with the passed in mesh as a child
  106386. */
  106387. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  106388. /**
  106389. * CustomMeshes are not supported by this gizmo
  106390. * @param mesh The mesh to replace the default mesh of the gizmo
  106391. */
  106392. setCustomMesh(mesh: Mesh): void;
  106393. }
  106394. }
  106395. declare module BABYLON {
  106396. /**
  106397. * Single plane rotation gizmo
  106398. */
  106399. export class PlaneRotationGizmo extends Gizmo {
  106400. /**
  106401. * Drag behavior responsible for the gizmos dragging interactions
  106402. */
  106403. dragBehavior: PointerDragBehavior;
  106404. private _pointerObserver;
  106405. /**
  106406. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  106407. */
  106408. snapDistance: number;
  106409. /**
  106410. * Event that fires each time the gizmo snaps to a new location.
  106411. * * snapDistance is the the change in distance
  106412. */
  106413. onSnapObservable: Observable<{
  106414. snapDistance: number;
  106415. }>;
  106416. private _isEnabled;
  106417. private _parent;
  106418. /**
  106419. * Creates a PlaneRotationGizmo
  106420. * @param gizmoLayer The utility layer the gizmo will be added to
  106421. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  106422. * @param color The color of the gizmo
  106423. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106424. */
  106425. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  106426. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106427. /**
  106428. * If the gizmo is enabled
  106429. */
  106430. isEnabled: boolean;
  106431. /**
  106432. * Disposes of the gizmo
  106433. */
  106434. dispose(): void;
  106435. }
  106436. }
  106437. declare module BABYLON {
  106438. /**
  106439. * Gizmo that enables rotating a mesh along 3 axis
  106440. */
  106441. export class RotationGizmo extends Gizmo {
  106442. /**
  106443. * Internal gizmo used for interactions on the x axis
  106444. */
  106445. xGizmo: PlaneRotationGizmo;
  106446. /**
  106447. * Internal gizmo used for interactions on the y axis
  106448. */
  106449. yGizmo: PlaneRotationGizmo;
  106450. /**
  106451. * Internal gizmo used for interactions on the z axis
  106452. */
  106453. zGizmo: PlaneRotationGizmo;
  106454. /** Fires an event when any of it's sub gizmos are dragged */
  106455. onDragStartObservable: Observable<{}>;
  106456. /** Fires an event when any of it's sub gizmos are released from dragging */
  106457. onDragEndObservable: Observable<{}>;
  106458. private _meshAttached;
  106459. attachedMesh: Nullable<AbstractMesh>;
  106460. /**
  106461. * Creates a RotationGizmo
  106462. * @param gizmoLayer The utility layer the gizmo will be added to
  106463. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106464. */
  106465. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  106466. updateGizmoRotationToMatchAttachedMesh: boolean;
  106467. /**
  106468. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106469. */
  106470. snapDistance: number;
  106471. /**
  106472. * Ratio for the scale of the gizmo (Default: 1)
  106473. */
  106474. scaleRatio: number;
  106475. /**
  106476. * Disposes of the gizmo
  106477. */
  106478. dispose(): void;
  106479. /**
  106480. * CustomMeshes are not supported by this gizmo
  106481. * @param mesh The mesh to replace the default mesh of the gizmo
  106482. */
  106483. setCustomMesh(mesh: Mesh): void;
  106484. }
  106485. }
  106486. declare module BABYLON {
  106487. /**
  106488. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  106489. */
  106490. export class GizmoManager implements IDisposable {
  106491. private scene;
  106492. /**
  106493. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  106494. */
  106495. gizmos: {
  106496. positionGizmo: Nullable<PositionGizmo>;
  106497. rotationGizmo: Nullable<RotationGizmo>;
  106498. scaleGizmo: Nullable<ScaleGizmo>;
  106499. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  106500. };
  106501. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  106502. clearGizmoOnEmptyPointerEvent: boolean;
  106503. /** Fires an event when the manager is attached to a mesh */
  106504. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  106505. private _gizmosEnabled;
  106506. private _pointerObserver;
  106507. private _attachedMesh;
  106508. private _boundingBoxColor;
  106509. private _defaultUtilityLayer;
  106510. private _defaultKeepDepthUtilityLayer;
  106511. /**
  106512. * When bounding box gizmo is enabled, this can be used to track drag/end events
  106513. */
  106514. boundingBoxDragBehavior: SixDofDragBehavior;
  106515. /**
  106516. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  106517. */
  106518. attachableMeshes: Nullable<Array<AbstractMesh>>;
  106519. /**
  106520. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  106521. */
  106522. usePointerToAttachGizmos: boolean;
  106523. /**
  106524. * Utility layer that the bounding box gizmo belongs to
  106525. */
  106526. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  106527. /**
  106528. * Utility layer that all gizmos besides bounding box belong to
  106529. */
  106530. readonly utilityLayer: UtilityLayerRenderer;
  106531. /**
  106532. * Instatiates a gizmo manager
  106533. * @param scene the scene to overlay the gizmos on top of
  106534. */
  106535. constructor(scene: Scene);
  106536. /**
  106537. * Attaches a set of gizmos to the specified mesh
  106538. * @param mesh The mesh the gizmo's should be attached to
  106539. */
  106540. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  106541. /**
  106542. * If the position gizmo is enabled
  106543. */
  106544. positionGizmoEnabled: boolean;
  106545. /**
  106546. * If the rotation gizmo is enabled
  106547. */
  106548. rotationGizmoEnabled: boolean;
  106549. /**
  106550. * If the scale gizmo is enabled
  106551. */
  106552. scaleGizmoEnabled: boolean;
  106553. /**
  106554. * If the boundingBox gizmo is enabled
  106555. */
  106556. boundingBoxGizmoEnabled: boolean;
  106557. /**
  106558. * Disposes of the gizmo manager
  106559. */
  106560. dispose(): void;
  106561. }
  106562. }
  106563. declare module BABYLON {
  106564. /**
  106565. * A directional light is defined by a direction (what a surprise!).
  106566. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  106567. * 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.
  106568. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106569. */
  106570. export class DirectionalLight extends ShadowLight {
  106571. private _shadowFrustumSize;
  106572. /**
  106573. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  106574. */
  106575. /**
  106576. * Specifies a fix frustum size for the shadow generation.
  106577. */
  106578. shadowFrustumSize: number;
  106579. private _shadowOrthoScale;
  106580. /**
  106581. * Gets the shadow projection scale against the optimal computed one.
  106582. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106583. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106584. */
  106585. /**
  106586. * Sets the shadow projection scale against the optimal computed one.
  106587. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106588. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106589. */
  106590. shadowOrthoScale: number;
  106591. /**
  106592. * Automatically compute the projection matrix to best fit (including all the casters)
  106593. * on each frame.
  106594. */
  106595. autoUpdateExtends: boolean;
  106596. private _orthoLeft;
  106597. private _orthoRight;
  106598. private _orthoTop;
  106599. private _orthoBottom;
  106600. /**
  106601. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  106602. * The directional light is emitted from everywhere in the given direction.
  106603. * It can cast shadows.
  106604. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106605. * @param name The friendly name of the light
  106606. * @param direction The direction of the light
  106607. * @param scene The scene the light belongs to
  106608. */
  106609. constructor(name: string, direction: Vector3, scene: Scene);
  106610. /**
  106611. * Returns the string "DirectionalLight".
  106612. * @return The class name
  106613. */
  106614. getClassName(): string;
  106615. /**
  106616. * Returns the integer 1.
  106617. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106618. */
  106619. getTypeID(): number;
  106620. /**
  106621. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  106622. * Returns the DirectionalLight Shadow projection matrix.
  106623. */
  106624. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106625. /**
  106626. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  106627. * Returns the DirectionalLight Shadow projection matrix.
  106628. */
  106629. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  106630. /**
  106631. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  106632. * Returns the DirectionalLight Shadow projection matrix.
  106633. */
  106634. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106635. protected _buildUniformLayout(): void;
  106636. /**
  106637. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  106638. * @param effect The effect to update
  106639. * @param lightIndex The index of the light in the effect to update
  106640. * @returns The directional light
  106641. */
  106642. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  106643. /**
  106644. * Gets the minZ used for shadow according to both the scene and the light.
  106645. *
  106646. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106647. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106648. * @param activeCamera The camera we are returning the min for
  106649. * @returns the depth min z
  106650. */
  106651. getDepthMinZ(activeCamera: Camera): number;
  106652. /**
  106653. * Gets the maxZ used for shadow according to both the scene and the light.
  106654. *
  106655. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106656. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106657. * @param activeCamera The camera we are returning the max for
  106658. * @returns the depth max z
  106659. */
  106660. getDepthMaxZ(activeCamera: Camera): number;
  106661. /**
  106662. * Prepares the list of defines specific to the light type.
  106663. * @param defines the list of defines
  106664. * @param lightIndex defines the index of the light for the effect
  106665. */
  106666. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106667. }
  106668. }
  106669. declare module BABYLON {
  106670. /**
  106671. * Class containing static functions to help procedurally build meshes
  106672. */
  106673. export class HemisphereBuilder {
  106674. /**
  106675. * Creates a hemisphere mesh
  106676. * @param name defines the name of the mesh
  106677. * @param options defines the options used to create the mesh
  106678. * @param scene defines the hosting scene
  106679. * @returns the hemisphere mesh
  106680. */
  106681. static CreateHemisphere(name: string, options: {
  106682. segments?: number;
  106683. diameter?: number;
  106684. sideOrientation?: number;
  106685. }, scene: any): Mesh;
  106686. }
  106687. }
  106688. declare module BABYLON {
  106689. /**
  106690. * A spot light is defined by a position, a direction, an angle, and an exponent.
  106691. * These values define a cone of light starting from the position, emitting toward the direction.
  106692. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  106693. * and the exponent defines the speed of the decay of the light with distance (reach).
  106694. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106695. */
  106696. export class SpotLight extends ShadowLight {
  106697. private _angle;
  106698. private _innerAngle;
  106699. private _cosHalfAngle;
  106700. private _lightAngleScale;
  106701. private _lightAngleOffset;
  106702. /**
  106703. * Gets the cone angle of the spot light in Radians.
  106704. */
  106705. /**
  106706. * Sets the cone angle of the spot light in Radians.
  106707. */
  106708. angle: number;
  106709. /**
  106710. * Only used in gltf falloff mode, this defines the angle where
  106711. * the directional falloff will start before cutting at angle which could be seen
  106712. * as outer angle.
  106713. */
  106714. /**
  106715. * Only used in gltf falloff mode, this defines the angle where
  106716. * the directional falloff will start before cutting at angle which could be seen
  106717. * as outer angle.
  106718. */
  106719. innerAngle: number;
  106720. private _shadowAngleScale;
  106721. /**
  106722. * Allows scaling the angle of the light for shadow generation only.
  106723. */
  106724. /**
  106725. * Allows scaling the angle of the light for shadow generation only.
  106726. */
  106727. shadowAngleScale: number;
  106728. /**
  106729. * The light decay speed with the distance from the emission spot.
  106730. */
  106731. exponent: number;
  106732. private _projectionTextureMatrix;
  106733. /**
  106734. * Allows reading the projecton texture
  106735. */
  106736. readonly projectionTextureMatrix: Matrix;
  106737. protected _projectionTextureLightNear: number;
  106738. /**
  106739. * Gets the near clip of the Spotlight for texture projection.
  106740. */
  106741. /**
  106742. * Sets the near clip of the Spotlight for texture projection.
  106743. */
  106744. projectionTextureLightNear: number;
  106745. protected _projectionTextureLightFar: number;
  106746. /**
  106747. * Gets the far clip of the Spotlight for texture projection.
  106748. */
  106749. /**
  106750. * Sets the far clip of the Spotlight for texture projection.
  106751. */
  106752. projectionTextureLightFar: number;
  106753. protected _projectionTextureUpDirection: Vector3;
  106754. /**
  106755. * Gets the Up vector of the Spotlight for texture projection.
  106756. */
  106757. /**
  106758. * Sets the Up vector of the Spotlight for texture projection.
  106759. */
  106760. projectionTextureUpDirection: Vector3;
  106761. private _projectionTexture;
  106762. /**
  106763. * Gets the projection texture of the light.
  106764. */
  106765. /**
  106766. * Sets the projection texture of the light.
  106767. */
  106768. projectionTexture: Nullable<BaseTexture>;
  106769. private _projectionTextureViewLightDirty;
  106770. private _projectionTextureProjectionLightDirty;
  106771. private _projectionTextureDirty;
  106772. private _projectionTextureViewTargetVector;
  106773. private _projectionTextureViewLightMatrix;
  106774. private _projectionTextureProjectionLightMatrix;
  106775. private _projectionTextureScalingMatrix;
  106776. /**
  106777. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  106778. * It can cast shadows.
  106779. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106780. * @param name The light friendly name
  106781. * @param position The position of the spot light in the scene
  106782. * @param direction The direction of the light in the scene
  106783. * @param angle The cone angle of the light in Radians
  106784. * @param exponent The light decay speed with the distance from the emission spot
  106785. * @param scene The scene the lights belongs to
  106786. */
  106787. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  106788. /**
  106789. * Returns the string "SpotLight".
  106790. * @returns the class name
  106791. */
  106792. getClassName(): string;
  106793. /**
  106794. * Returns the integer 2.
  106795. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106796. */
  106797. getTypeID(): number;
  106798. /**
  106799. * Overrides the direction setter to recompute the projection texture view light Matrix.
  106800. */
  106801. protected _setDirection(value: Vector3): void;
  106802. /**
  106803. * Overrides the position setter to recompute the projection texture view light Matrix.
  106804. */
  106805. protected _setPosition(value: Vector3): void;
  106806. /**
  106807. * 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.
  106808. * Returns the SpotLight.
  106809. */
  106810. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106811. protected _computeProjectionTextureViewLightMatrix(): void;
  106812. protected _computeProjectionTextureProjectionLightMatrix(): void;
  106813. /**
  106814. * Main function for light texture projection matrix computing.
  106815. */
  106816. protected _computeProjectionTextureMatrix(): void;
  106817. protected _buildUniformLayout(): void;
  106818. private _computeAngleValues;
  106819. /**
  106820. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  106821. * @param effect The effect to update
  106822. * @param lightIndex The index of the light in the effect to update
  106823. * @returns The spot light
  106824. */
  106825. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  106826. /**
  106827. * Disposes the light and the associated resources.
  106828. */
  106829. dispose(): void;
  106830. /**
  106831. * Prepares the list of defines specific to the light type.
  106832. * @param defines the list of defines
  106833. * @param lightIndex defines the index of the light for the effect
  106834. */
  106835. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106836. }
  106837. }
  106838. declare module BABYLON {
  106839. /**
  106840. * Gizmo that enables viewing a light
  106841. */
  106842. export class LightGizmo extends Gizmo {
  106843. private _lightMesh;
  106844. private _material;
  106845. private cachedPosition;
  106846. private cachedForward;
  106847. /**
  106848. * Creates a LightGizmo
  106849. * @param gizmoLayer The utility layer the gizmo will be added to
  106850. */
  106851. constructor(gizmoLayer?: UtilityLayerRenderer);
  106852. private _light;
  106853. /**
  106854. * The light that the gizmo is attached to
  106855. */
  106856. light: Nullable<Light>;
  106857. /**
  106858. * @hidden
  106859. * Updates the gizmo to match the attached mesh's position/rotation
  106860. */
  106861. protected _update(): void;
  106862. private static _Scale;
  106863. /**
  106864. * Creates the lines for a light mesh
  106865. */
  106866. private static _createLightLines;
  106867. /**
  106868. * Disposes of the light gizmo
  106869. */
  106870. dispose(): void;
  106871. private static _CreateHemisphericLightMesh;
  106872. private static _CreatePointLightMesh;
  106873. private static _CreateSpotLightMesh;
  106874. private static _CreateDirectionalLightMesh;
  106875. }
  106876. }
  106877. declare module BABYLON {
  106878. /** @hidden */
  106879. export var backgroundFragmentDeclaration: {
  106880. name: string;
  106881. shader: string;
  106882. };
  106883. }
  106884. declare module BABYLON {
  106885. /** @hidden */
  106886. export var backgroundUboDeclaration: {
  106887. name: string;
  106888. shader: string;
  106889. };
  106890. }
  106891. declare module BABYLON {
  106892. /** @hidden */
  106893. export var backgroundPixelShader: {
  106894. name: string;
  106895. shader: string;
  106896. };
  106897. }
  106898. declare module BABYLON {
  106899. /** @hidden */
  106900. export var backgroundVertexDeclaration: {
  106901. name: string;
  106902. shader: string;
  106903. };
  106904. }
  106905. declare module BABYLON {
  106906. /** @hidden */
  106907. export var backgroundVertexShader: {
  106908. name: string;
  106909. shader: string;
  106910. };
  106911. }
  106912. declare module BABYLON {
  106913. /**
  106914. * Background material used to create an efficient environement around your scene.
  106915. */
  106916. export class BackgroundMaterial extends PushMaterial {
  106917. /**
  106918. * Standard reflectance value at parallel view angle.
  106919. */
  106920. static StandardReflectance0: number;
  106921. /**
  106922. * Standard reflectance value at grazing angle.
  106923. */
  106924. static StandardReflectance90: number;
  106925. protected _primaryColor: Color3;
  106926. /**
  106927. * Key light Color (multiply against the environement texture)
  106928. */
  106929. primaryColor: Color3;
  106930. protected __perceptualColor: Nullable<Color3>;
  106931. /**
  106932. * Experimental Internal Use Only.
  106933. *
  106934. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106935. * This acts as a helper to set the primary color to a more "human friendly" value.
  106936. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106937. * output color as close as possible from the chosen value.
  106938. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106939. * part of lighting setup.)
  106940. */
  106941. _perceptualColor: Nullable<Color3>;
  106942. protected _primaryColorShadowLevel: float;
  106943. /**
  106944. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106945. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106946. */
  106947. primaryColorShadowLevel: float;
  106948. protected _primaryColorHighlightLevel: float;
  106949. /**
  106950. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106951. * The primary color is used at the level chosen to define what the white area would look.
  106952. */
  106953. primaryColorHighlightLevel: float;
  106954. protected _reflectionTexture: Nullable<BaseTexture>;
  106955. /**
  106956. * Reflection Texture used in the material.
  106957. * Should be author in a specific way for the best result (refer to the documentation).
  106958. */
  106959. reflectionTexture: Nullable<BaseTexture>;
  106960. protected _reflectionBlur: float;
  106961. /**
  106962. * Reflection Texture level of blur.
  106963. *
  106964. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106965. * texture twice.
  106966. */
  106967. reflectionBlur: float;
  106968. protected _diffuseTexture: Nullable<BaseTexture>;
  106969. /**
  106970. * Diffuse Texture used in the material.
  106971. * Should be author in a specific way for the best result (refer to the documentation).
  106972. */
  106973. diffuseTexture: Nullable<BaseTexture>;
  106974. protected _shadowLights: Nullable<IShadowLight[]>;
  106975. /**
  106976. * Specify the list of lights casting shadow on the material.
  106977. * All scene shadow lights will be included if null.
  106978. */
  106979. shadowLights: Nullable<IShadowLight[]>;
  106980. protected _shadowLevel: float;
  106981. /**
  106982. * Helps adjusting the shadow to a softer level if required.
  106983. * 0 means black shadows and 1 means no shadows.
  106984. */
  106985. shadowLevel: float;
  106986. protected _sceneCenter: Vector3;
  106987. /**
  106988. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106989. * It is usually zero but might be interesting to modify according to your setup.
  106990. */
  106991. sceneCenter: Vector3;
  106992. protected _opacityFresnel: boolean;
  106993. /**
  106994. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106995. * This helps ensuring a nice transition when the camera goes under the ground.
  106996. */
  106997. opacityFresnel: boolean;
  106998. protected _reflectionFresnel: boolean;
  106999. /**
  107000. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  107001. * This helps adding a mirror texture on the ground.
  107002. */
  107003. reflectionFresnel: boolean;
  107004. protected _reflectionFalloffDistance: number;
  107005. /**
  107006. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  107007. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  107008. */
  107009. reflectionFalloffDistance: number;
  107010. protected _reflectionAmount: number;
  107011. /**
  107012. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  107013. */
  107014. reflectionAmount: number;
  107015. protected _reflectionReflectance0: number;
  107016. /**
  107017. * This specifies the weight of the reflection at grazing angle.
  107018. */
  107019. reflectionReflectance0: number;
  107020. protected _reflectionReflectance90: number;
  107021. /**
  107022. * This specifies the weight of the reflection at a perpendicular point of view.
  107023. */
  107024. reflectionReflectance90: number;
  107025. /**
  107026. * Sets the reflection reflectance fresnel values according to the default standard
  107027. * empirically know to work well :-)
  107028. */
  107029. reflectionStandardFresnelWeight: number;
  107030. protected _useRGBColor: boolean;
  107031. /**
  107032. * Helps to directly use the maps channels instead of their level.
  107033. */
  107034. useRGBColor: boolean;
  107035. protected _enableNoise: boolean;
  107036. /**
  107037. * This helps reducing the banding effect that could occur on the background.
  107038. */
  107039. enableNoise: boolean;
  107040. /**
  107041. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107042. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  107043. * Recommended to be keep at 1.0 except for special cases.
  107044. */
  107045. fovMultiplier: number;
  107046. private _fovMultiplier;
  107047. /**
  107048. * Enable the FOV adjustment feature controlled by fovMultiplier.
  107049. */
  107050. useEquirectangularFOV: boolean;
  107051. private _maxSimultaneousLights;
  107052. /**
  107053. * Number of Simultaneous lights allowed on the material.
  107054. */
  107055. maxSimultaneousLights: int;
  107056. /**
  107057. * Default configuration related to image processing available in the Background Material.
  107058. */
  107059. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107060. /**
  107061. * Keep track of the image processing observer to allow dispose and replace.
  107062. */
  107063. private _imageProcessingObserver;
  107064. /**
  107065. * Attaches a new image processing configuration to the PBR Material.
  107066. * @param configuration (if null the scene configuration will be use)
  107067. */
  107068. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107069. /**
  107070. * Gets the image processing configuration used either in this material.
  107071. */
  107072. /**
  107073. * Sets the Default image processing configuration used either in the this material.
  107074. *
  107075. * If sets to null, the scene one is in use.
  107076. */
  107077. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  107078. /**
  107079. * Gets wether the color curves effect is enabled.
  107080. */
  107081. /**
  107082. * Sets wether the color curves effect is enabled.
  107083. */
  107084. cameraColorCurvesEnabled: boolean;
  107085. /**
  107086. * Gets wether the color grading effect is enabled.
  107087. */
  107088. /**
  107089. * Gets wether the color grading effect is enabled.
  107090. */
  107091. cameraColorGradingEnabled: boolean;
  107092. /**
  107093. * Gets wether tonemapping is enabled or not.
  107094. */
  107095. /**
  107096. * Sets wether tonemapping is enabled or not
  107097. */
  107098. cameraToneMappingEnabled: boolean;
  107099. /**
  107100. * The camera exposure used on this material.
  107101. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107102. * This corresponds to a photographic exposure.
  107103. */
  107104. /**
  107105. * The camera exposure used on this material.
  107106. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107107. * This corresponds to a photographic exposure.
  107108. */
  107109. cameraExposure: float;
  107110. /**
  107111. * Gets The camera contrast used on this material.
  107112. */
  107113. /**
  107114. * Sets The camera contrast used on this material.
  107115. */
  107116. cameraContrast: float;
  107117. /**
  107118. * Gets the Color Grading 2D Lookup Texture.
  107119. */
  107120. /**
  107121. * Sets the Color Grading 2D Lookup Texture.
  107122. */
  107123. cameraColorGradingTexture: Nullable<BaseTexture>;
  107124. /**
  107125. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107126. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107127. * 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;
  107128. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107129. */
  107130. /**
  107131. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107132. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107133. * 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;
  107134. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107135. */
  107136. cameraColorCurves: Nullable<ColorCurves>;
  107137. /**
  107138. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  107139. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  107140. */
  107141. switchToBGR: boolean;
  107142. private _renderTargets;
  107143. private _reflectionControls;
  107144. private _white;
  107145. private _primaryShadowColor;
  107146. private _primaryHighlightColor;
  107147. /**
  107148. * Instantiates a Background Material in the given scene
  107149. * @param name The friendly name of the material
  107150. * @param scene The scene to add the material to
  107151. */
  107152. constructor(name: string, scene: Scene);
  107153. /**
  107154. * Gets a boolean indicating that current material needs to register RTT
  107155. */
  107156. readonly hasRenderTargetTextures: boolean;
  107157. /**
  107158. * The entire material has been created in order to prevent overdraw.
  107159. * @returns false
  107160. */
  107161. needAlphaTesting(): boolean;
  107162. /**
  107163. * The entire material has been created in order to prevent overdraw.
  107164. * @returns true if blending is enable
  107165. */
  107166. needAlphaBlending(): boolean;
  107167. /**
  107168. * Checks wether the material is ready to be rendered for a given mesh.
  107169. * @param mesh The mesh to render
  107170. * @param subMesh The submesh to check against
  107171. * @param useInstances Specify wether or not the material is used with instances
  107172. * @returns true if all the dependencies are ready (Textures, Effects...)
  107173. */
  107174. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107175. /**
  107176. * Compute the primary color according to the chosen perceptual color.
  107177. */
  107178. private _computePrimaryColorFromPerceptualColor;
  107179. /**
  107180. * Compute the highlights and shadow colors according to their chosen levels.
  107181. */
  107182. private _computePrimaryColors;
  107183. /**
  107184. * Build the uniform buffer used in the material.
  107185. */
  107186. buildUniformLayout(): void;
  107187. /**
  107188. * Unbind the material.
  107189. */
  107190. unbind(): void;
  107191. /**
  107192. * Bind only the world matrix to the material.
  107193. * @param world The world matrix to bind.
  107194. */
  107195. bindOnlyWorldMatrix(world: Matrix): void;
  107196. /**
  107197. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  107198. * @param world The world matrix to bind.
  107199. * @param subMesh The submesh to bind for.
  107200. */
  107201. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107202. /**
  107203. * Dispose the material.
  107204. * @param forceDisposeEffect Force disposal of the associated effect.
  107205. * @param forceDisposeTextures Force disposal of the associated textures.
  107206. */
  107207. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107208. /**
  107209. * Clones the material.
  107210. * @param name The cloned name.
  107211. * @returns The cloned material.
  107212. */
  107213. clone(name: string): BackgroundMaterial;
  107214. /**
  107215. * Serializes the current material to its JSON representation.
  107216. * @returns The JSON representation.
  107217. */
  107218. serialize(): any;
  107219. /**
  107220. * Gets the class name of the material
  107221. * @returns "BackgroundMaterial"
  107222. */
  107223. getClassName(): string;
  107224. /**
  107225. * Parse a JSON input to create back a background material.
  107226. * @param source The JSON data to parse
  107227. * @param scene The scene to create the parsed material in
  107228. * @param rootUrl The root url of the assets the material depends upon
  107229. * @returns the instantiated BackgroundMaterial.
  107230. */
  107231. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  107232. }
  107233. }
  107234. declare module BABYLON {
  107235. /**
  107236. * Represents the different options available during the creation of
  107237. * a Environment helper.
  107238. *
  107239. * This can control the default ground, skybox and image processing setup of your scene.
  107240. */
  107241. export interface IEnvironmentHelperOptions {
  107242. /**
  107243. * Specifies wether or not to create a ground.
  107244. * True by default.
  107245. */
  107246. createGround: boolean;
  107247. /**
  107248. * Specifies the ground size.
  107249. * 15 by default.
  107250. */
  107251. groundSize: number;
  107252. /**
  107253. * The texture used on the ground for the main color.
  107254. * Comes from the BabylonJS CDN by default.
  107255. *
  107256. * Remarks: Can be either a texture or a url.
  107257. */
  107258. groundTexture: string | BaseTexture;
  107259. /**
  107260. * The color mixed in the ground texture by default.
  107261. * BabylonJS clearColor by default.
  107262. */
  107263. groundColor: Color3;
  107264. /**
  107265. * Specifies the ground opacity.
  107266. * 1 by default.
  107267. */
  107268. groundOpacity: number;
  107269. /**
  107270. * Enables the ground to receive shadows.
  107271. * True by default.
  107272. */
  107273. enableGroundShadow: boolean;
  107274. /**
  107275. * Helps preventing the shadow to be fully black on the ground.
  107276. * 0.5 by default.
  107277. */
  107278. groundShadowLevel: number;
  107279. /**
  107280. * Creates a mirror texture attach to the ground.
  107281. * false by default.
  107282. */
  107283. enableGroundMirror: boolean;
  107284. /**
  107285. * Specifies the ground mirror size ratio.
  107286. * 0.3 by default as the default kernel is 64.
  107287. */
  107288. groundMirrorSizeRatio: number;
  107289. /**
  107290. * Specifies the ground mirror blur kernel size.
  107291. * 64 by default.
  107292. */
  107293. groundMirrorBlurKernel: number;
  107294. /**
  107295. * Specifies the ground mirror visibility amount.
  107296. * 1 by default
  107297. */
  107298. groundMirrorAmount: number;
  107299. /**
  107300. * Specifies the ground mirror reflectance weight.
  107301. * This uses the standard weight of the background material to setup the fresnel effect
  107302. * of the mirror.
  107303. * 1 by default.
  107304. */
  107305. groundMirrorFresnelWeight: number;
  107306. /**
  107307. * Specifies the ground mirror Falloff distance.
  107308. * This can helps reducing the size of the reflection.
  107309. * 0 by Default.
  107310. */
  107311. groundMirrorFallOffDistance: number;
  107312. /**
  107313. * Specifies the ground mirror texture type.
  107314. * Unsigned Int by Default.
  107315. */
  107316. groundMirrorTextureType: number;
  107317. /**
  107318. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  107319. * the shown objects.
  107320. */
  107321. groundYBias: number;
  107322. /**
  107323. * Specifies wether or not to create a skybox.
  107324. * True by default.
  107325. */
  107326. createSkybox: boolean;
  107327. /**
  107328. * Specifies the skybox size.
  107329. * 20 by default.
  107330. */
  107331. skyboxSize: number;
  107332. /**
  107333. * The texture used on the skybox for the main color.
  107334. * Comes from the BabylonJS CDN by default.
  107335. *
  107336. * Remarks: Can be either a texture or a url.
  107337. */
  107338. skyboxTexture: string | BaseTexture;
  107339. /**
  107340. * The color mixed in the skybox texture by default.
  107341. * BabylonJS clearColor by default.
  107342. */
  107343. skyboxColor: Color3;
  107344. /**
  107345. * The background rotation around the Y axis of the scene.
  107346. * This helps aligning the key lights of your scene with the background.
  107347. * 0 by default.
  107348. */
  107349. backgroundYRotation: number;
  107350. /**
  107351. * Compute automatically the size of the elements to best fit with the scene.
  107352. */
  107353. sizeAuto: boolean;
  107354. /**
  107355. * Default position of the rootMesh if autoSize is not true.
  107356. */
  107357. rootPosition: Vector3;
  107358. /**
  107359. * Sets up the image processing in the scene.
  107360. * true by default.
  107361. */
  107362. setupImageProcessing: boolean;
  107363. /**
  107364. * The texture used as your environment texture in the scene.
  107365. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  107366. *
  107367. * Remarks: Can be either a texture or a url.
  107368. */
  107369. environmentTexture: string | BaseTexture;
  107370. /**
  107371. * The value of the exposure to apply to the scene.
  107372. * 0.6 by default if setupImageProcessing is true.
  107373. */
  107374. cameraExposure: number;
  107375. /**
  107376. * The value of the contrast to apply to the scene.
  107377. * 1.6 by default if setupImageProcessing is true.
  107378. */
  107379. cameraContrast: number;
  107380. /**
  107381. * Specifies wether or not tonemapping should be enabled in the scene.
  107382. * true by default if setupImageProcessing is true.
  107383. */
  107384. toneMappingEnabled: boolean;
  107385. }
  107386. /**
  107387. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  107388. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  107389. * It also helps with the default setup of your imageProcessing configuration.
  107390. */
  107391. export class EnvironmentHelper {
  107392. /**
  107393. * Default ground texture URL.
  107394. */
  107395. private static _groundTextureCDNUrl;
  107396. /**
  107397. * Default skybox texture URL.
  107398. */
  107399. private static _skyboxTextureCDNUrl;
  107400. /**
  107401. * Default environment texture URL.
  107402. */
  107403. private static _environmentTextureCDNUrl;
  107404. /**
  107405. * Creates the default options for the helper.
  107406. */
  107407. private static _getDefaultOptions;
  107408. private _rootMesh;
  107409. /**
  107410. * Gets the root mesh created by the helper.
  107411. */
  107412. readonly rootMesh: Mesh;
  107413. private _skybox;
  107414. /**
  107415. * Gets the skybox created by the helper.
  107416. */
  107417. readonly skybox: Nullable<Mesh>;
  107418. private _skyboxTexture;
  107419. /**
  107420. * Gets the skybox texture created by the helper.
  107421. */
  107422. readonly skyboxTexture: Nullable<BaseTexture>;
  107423. private _skyboxMaterial;
  107424. /**
  107425. * Gets the skybox material created by the helper.
  107426. */
  107427. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  107428. private _ground;
  107429. /**
  107430. * Gets the ground mesh created by the helper.
  107431. */
  107432. readonly ground: Nullable<Mesh>;
  107433. private _groundTexture;
  107434. /**
  107435. * Gets the ground texture created by the helper.
  107436. */
  107437. readonly groundTexture: Nullable<BaseTexture>;
  107438. private _groundMirror;
  107439. /**
  107440. * Gets the ground mirror created by the helper.
  107441. */
  107442. readonly groundMirror: Nullable<MirrorTexture>;
  107443. /**
  107444. * Gets the ground mirror render list to helps pushing the meshes
  107445. * you wish in the ground reflection.
  107446. */
  107447. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  107448. private _groundMaterial;
  107449. /**
  107450. * Gets the ground material created by the helper.
  107451. */
  107452. readonly groundMaterial: Nullable<BackgroundMaterial>;
  107453. /**
  107454. * Stores the creation options.
  107455. */
  107456. private readonly _scene;
  107457. private _options;
  107458. /**
  107459. * This observable will be notified with any error during the creation of the environment,
  107460. * mainly texture creation errors.
  107461. */
  107462. onErrorObservable: Observable<{
  107463. message?: string;
  107464. exception?: any;
  107465. }>;
  107466. /**
  107467. * constructor
  107468. * @param options Defines the options we want to customize the helper
  107469. * @param scene The scene to add the material to
  107470. */
  107471. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  107472. /**
  107473. * Updates the background according to the new options
  107474. * @param options
  107475. */
  107476. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  107477. /**
  107478. * Sets the primary color of all the available elements.
  107479. * @param color the main color to affect to the ground and the background
  107480. */
  107481. setMainColor(color: Color3): void;
  107482. /**
  107483. * Setup the image processing according to the specified options.
  107484. */
  107485. private _setupImageProcessing;
  107486. /**
  107487. * Setup the environment texture according to the specified options.
  107488. */
  107489. private _setupEnvironmentTexture;
  107490. /**
  107491. * Setup the background according to the specified options.
  107492. */
  107493. private _setupBackground;
  107494. /**
  107495. * Get the scene sizes according to the setup.
  107496. */
  107497. private _getSceneSize;
  107498. /**
  107499. * Setup the ground according to the specified options.
  107500. */
  107501. private _setupGround;
  107502. /**
  107503. * Setup the ground material according to the specified options.
  107504. */
  107505. private _setupGroundMaterial;
  107506. /**
  107507. * Setup the ground diffuse texture according to the specified options.
  107508. */
  107509. private _setupGroundDiffuseTexture;
  107510. /**
  107511. * Setup the ground mirror texture according to the specified options.
  107512. */
  107513. private _setupGroundMirrorTexture;
  107514. /**
  107515. * Setup the ground to receive the mirror texture.
  107516. */
  107517. private _setupMirrorInGroundMaterial;
  107518. /**
  107519. * Setup the skybox according to the specified options.
  107520. */
  107521. private _setupSkybox;
  107522. /**
  107523. * Setup the skybox material according to the specified options.
  107524. */
  107525. private _setupSkyboxMaterial;
  107526. /**
  107527. * Setup the skybox reflection texture according to the specified options.
  107528. */
  107529. private _setupSkyboxReflectionTexture;
  107530. private _errorHandler;
  107531. /**
  107532. * Dispose all the elements created by the Helper.
  107533. */
  107534. dispose(): void;
  107535. }
  107536. }
  107537. declare module BABYLON {
  107538. /**
  107539. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  107540. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  107541. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  107542. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  107543. */
  107544. export class PhotoDome extends TransformNode {
  107545. /**
  107546. * Define the image as a Monoscopic panoramic 360 image.
  107547. */
  107548. static readonly MODE_MONOSCOPIC: number;
  107549. /**
  107550. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107551. */
  107552. static readonly MODE_TOPBOTTOM: number;
  107553. /**
  107554. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107555. */
  107556. static readonly MODE_SIDEBYSIDE: number;
  107557. private _useDirectMapping;
  107558. /**
  107559. * The texture being displayed on the sphere
  107560. */
  107561. protected _photoTexture: Texture;
  107562. /**
  107563. * Gets or sets the texture being displayed on the sphere
  107564. */
  107565. photoTexture: Texture;
  107566. /**
  107567. * Observable raised when an error occured while loading the 360 image
  107568. */
  107569. onLoadErrorObservable: Observable<string>;
  107570. /**
  107571. * The skybox material
  107572. */
  107573. protected _material: BackgroundMaterial;
  107574. /**
  107575. * The surface used for the skybox
  107576. */
  107577. protected _mesh: Mesh;
  107578. /**
  107579. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107580. * Also see the options.resolution property.
  107581. */
  107582. fovMultiplier: number;
  107583. private _imageMode;
  107584. /**
  107585. * Gets or set the current video mode for the video. It can be:
  107586. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  107587. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107588. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107589. */
  107590. imageMode: number;
  107591. /**
  107592. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  107593. * @param name Element's name, child elements will append suffixes for their own names.
  107594. * @param urlsOfPhoto defines the url of the photo to display
  107595. * @param options defines an object containing optional or exposed sub element properties
  107596. * @param onError defines a callback called when an error occured while loading the texture
  107597. */
  107598. constructor(name: string, urlOfPhoto: string, options: {
  107599. resolution?: number;
  107600. size?: number;
  107601. useDirectMapping?: boolean;
  107602. faceForward?: boolean;
  107603. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  107604. private _onBeforeCameraRenderObserver;
  107605. private _changeImageMode;
  107606. /**
  107607. * Releases resources associated with this node.
  107608. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107609. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107610. */
  107611. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107612. }
  107613. }
  107614. declare module BABYLON {
  107615. /** @hidden */
  107616. export var rgbdDecodePixelShader: {
  107617. name: string;
  107618. shader: string;
  107619. };
  107620. }
  107621. declare module BABYLON {
  107622. /**
  107623. * Class used to host texture specific utilities
  107624. */
  107625. export class BRDFTextureTools {
  107626. /**
  107627. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  107628. * @param texture the texture to expand.
  107629. */
  107630. private static _ExpandDefaultBRDFTexture;
  107631. /**
  107632. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  107633. * @param scene defines the hosting scene
  107634. * @returns the environment BRDF texture
  107635. */
  107636. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  107637. private static _environmentBRDFBase64Texture;
  107638. }
  107639. }
  107640. declare module BABYLON {
  107641. /**
  107642. * @hidden
  107643. */
  107644. export interface IMaterialClearCoatDefines {
  107645. CLEARCOAT: boolean;
  107646. CLEARCOAT_DEFAULTIOR: boolean;
  107647. CLEARCOAT_TEXTURE: boolean;
  107648. CLEARCOAT_TEXTUREDIRECTUV: number;
  107649. CLEARCOAT_BUMP: boolean;
  107650. CLEARCOAT_BUMPDIRECTUV: number;
  107651. CLEARCOAT_TINT: boolean;
  107652. CLEARCOAT_TINT_TEXTURE: boolean;
  107653. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107654. /** @hidden */
  107655. _areTexturesDirty: boolean;
  107656. }
  107657. /**
  107658. * Define the code related to the clear coat parameters of the pbr material.
  107659. */
  107660. export class PBRClearCoatConfiguration {
  107661. /**
  107662. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107663. * The default fits with a polyurethane material.
  107664. */
  107665. private static readonly _DefaultIndexOfRefraction;
  107666. private _isEnabled;
  107667. /**
  107668. * Defines if the clear coat is enabled in the material.
  107669. */
  107670. isEnabled: boolean;
  107671. /**
  107672. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  107673. */
  107674. intensity: number;
  107675. /**
  107676. * Defines the clear coat layer roughness.
  107677. */
  107678. roughness: number;
  107679. private _indexOfRefraction;
  107680. /**
  107681. * Defines the index of refraction of the clear coat.
  107682. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107683. * The default fits with a polyurethane material.
  107684. * Changing the default value is more performance intensive.
  107685. */
  107686. indexOfRefraction: number;
  107687. private _texture;
  107688. /**
  107689. * Stores the clear coat values in a texture.
  107690. */
  107691. texture: Nullable<BaseTexture>;
  107692. private _bumpTexture;
  107693. /**
  107694. * Define the clear coat specific bump texture.
  107695. */
  107696. bumpTexture: Nullable<BaseTexture>;
  107697. private _isTintEnabled;
  107698. /**
  107699. * Defines if the clear coat tint is enabled in the material.
  107700. */
  107701. isTintEnabled: boolean;
  107702. /**
  107703. * Defines the clear coat tint of the material.
  107704. * This is only use if tint is enabled
  107705. */
  107706. tintColor: Color3;
  107707. /**
  107708. * Defines the distance at which the tint color should be found in the
  107709. * clear coat media.
  107710. * This is only use if tint is enabled
  107711. */
  107712. tintColorAtDistance: number;
  107713. /**
  107714. * Defines the clear coat layer thickness.
  107715. * This is only use if tint is enabled
  107716. */
  107717. tintThickness: number;
  107718. private _tintTexture;
  107719. /**
  107720. * Stores the clear tint values in a texture.
  107721. * rgb is tint
  107722. * a is a thickness factor
  107723. */
  107724. tintTexture: Nullable<BaseTexture>;
  107725. /** @hidden */
  107726. private _internalMarkAllSubMeshesAsTexturesDirty;
  107727. /** @hidden */
  107728. _markAllSubMeshesAsTexturesDirty(): void;
  107729. /**
  107730. * Instantiate a new istance of clear coat configuration.
  107731. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107732. */
  107733. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107734. /**
  107735. * Gets wehter the submesh is ready to be used or not.
  107736. * @param defines the list of "defines" to update.
  107737. * @param scene defines the scene the material belongs to.
  107738. * @param engine defines the engine the material belongs to.
  107739. * @param disableBumpMap defines wether the material disables bump or not.
  107740. * @returns - boolean indicating that the submesh is ready or not.
  107741. */
  107742. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  107743. /**
  107744. * Checks to see if a texture is used in the material.
  107745. * @param defines the list of "defines" to update.
  107746. * @param scene defines the scene to the material belongs to.
  107747. */
  107748. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  107749. /**
  107750. * Binds the material data.
  107751. * @param uniformBuffer defines the Uniform buffer to fill in.
  107752. * @param scene defines the scene the material belongs to.
  107753. * @param engine defines the engine the material belongs to.
  107754. * @param disableBumpMap defines wether the material disables bump or not.
  107755. * @param isFrozen defines wether the material is frozen or not.
  107756. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107757. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107758. */
  107759. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  107760. /**
  107761. * Checks to see if a texture is used in the material.
  107762. * @param texture - Base texture to use.
  107763. * @returns - Boolean specifying if a texture is used in the material.
  107764. */
  107765. hasTexture(texture: BaseTexture): boolean;
  107766. /**
  107767. * Returns an array of the actively used textures.
  107768. * @param activeTextures Array of BaseTextures
  107769. */
  107770. getActiveTextures(activeTextures: BaseTexture[]): void;
  107771. /**
  107772. * Returns the animatable textures.
  107773. * @param animatables Array of animatable textures.
  107774. */
  107775. getAnimatables(animatables: IAnimatable[]): void;
  107776. /**
  107777. * Disposes the resources of the material.
  107778. * @param forceDisposeTextures - Forces the disposal of all textures.
  107779. */
  107780. dispose(forceDisposeTextures?: boolean): void;
  107781. /**
  107782. * Get the current class name of the texture useful for serialization or dynamic coding.
  107783. * @returns "PBRClearCoatConfiguration"
  107784. */
  107785. getClassName(): string;
  107786. /**
  107787. * Add fallbacks to the effect fallbacks list.
  107788. * @param defines defines the Base texture to use.
  107789. * @param fallbacks defines the current fallback list.
  107790. * @param currentRank defines the current fallback rank.
  107791. * @returns the new fallback rank.
  107792. */
  107793. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107794. /**
  107795. * Add the required uniforms to the current list.
  107796. * @param uniforms defines the current uniform list.
  107797. */
  107798. static AddUniforms(uniforms: string[]): void;
  107799. /**
  107800. * Add the required samplers to the current list.
  107801. * @param samplers defines the current sampler list.
  107802. */
  107803. static AddSamplers(samplers: string[]): void;
  107804. /**
  107805. * Add the required uniforms to the current buffer.
  107806. * @param uniformBuffer defines the current uniform buffer.
  107807. */
  107808. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107809. /**
  107810. * Makes a duplicate of the current configuration into another one.
  107811. * @param clearCoatConfiguration define the config where to copy the info
  107812. */
  107813. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  107814. /**
  107815. * Serializes this clear coat configuration.
  107816. * @returns - An object with the serialized config.
  107817. */
  107818. serialize(): any;
  107819. /**
  107820. * Parses a anisotropy Configuration from a serialized object.
  107821. * @param source - Serialized object.
  107822. * @param scene Defines the scene we are parsing for
  107823. * @param rootUrl Defines the rootUrl to load from
  107824. */
  107825. parse(source: any, scene: Scene, rootUrl: string): void;
  107826. }
  107827. }
  107828. declare module BABYLON {
  107829. /**
  107830. * @hidden
  107831. */
  107832. export interface IMaterialAnisotropicDefines {
  107833. ANISOTROPIC: boolean;
  107834. ANISOTROPIC_TEXTURE: boolean;
  107835. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107836. MAINUV1: boolean;
  107837. _areTexturesDirty: boolean;
  107838. _needUVs: boolean;
  107839. }
  107840. /**
  107841. * Define the code related to the anisotropic parameters of the pbr material.
  107842. */
  107843. export class PBRAnisotropicConfiguration {
  107844. private _isEnabled;
  107845. /**
  107846. * Defines if the anisotropy is enabled in the material.
  107847. */
  107848. isEnabled: boolean;
  107849. /**
  107850. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  107851. */
  107852. intensity: number;
  107853. /**
  107854. * Defines if the effect is along the tangents, bitangents or in between.
  107855. * By default, the effect is "strectching" the highlights along the tangents.
  107856. */
  107857. direction: Vector2;
  107858. private _texture;
  107859. /**
  107860. * Stores the anisotropy values in a texture.
  107861. * rg is direction (like normal from -1 to 1)
  107862. * b is a intensity
  107863. */
  107864. texture: Nullable<BaseTexture>;
  107865. /** @hidden */
  107866. private _internalMarkAllSubMeshesAsTexturesDirty;
  107867. /** @hidden */
  107868. _markAllSubMeshesAsTexturesDirty(): void;
  107869. /**
  107870. * Instantiate a new istance of anisotropy configuration.
  107871. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107872. */
  107873. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107874. /**
  107875. * Specifies that the submesh is ready to be used.
  107876. * @param defines the list of "defines" to update.
  107877. * @param scene defines the scene the material belongs to.
  107878. * @returns - boolean indicating that the submesh is ready or not.
  107879. */
  107880. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  107881. /**
  107882. * Checks to see if a texture is used in the material.
  107883. * @param defines the list of "defines" to update.
  107884. * @param mesh the mesh we are preparing the defines for.
  107885. * @param scene defines the scene the material belongs to.
  107886. */
  107887. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  107888. /**
  107889. * Binds the material data.
  107890. * @param uniformBuffer defines the Uniform buffer to fill in.
  107891. * @param scene defines the scene the material belongs to.
  107892. * @param isFrozen defines wether the material is frozen or not.
  107893. */
  107894. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107895. /**
  107896. * Checks to see if a texture is used in the material.
  107897. * @param texture - Base texture to use.
  107898. * @returns - Boolean specifying if a texture is used in the material.
  107899. */
  107900. hasTexture(texture: BaseTexture): boolean;
  107901. /**
  107902. * Returns an array of the actively used textures.
  107903. * @param activeTextures Array of BaseTextures
  107904. */
  107905. getActiveTextures(activeTextures: BaseTexture[]): void;
  107906. /**
  107907. * Returns the animatable textures.
  107908. * @param animatables Array of animatable textures.
  107909. */
  107910. getAnimatables(animatables: IAnimatable[]): void;
  107911. /**
  107912. * Disposes the resources of the material.
  107913. * @param forceDisposeTextures - Forces the disposal of all textures.
  107914. */
  107915. dispose(forceDisposeTextures?: boolean): void;
  107916. /**
  107917. * Get the current class name of the texture useful for serialization or dynamic coding.
  107918. * @returns "PBRAnisotropicConfiguration"
  107919. */
  107920. getClassName(): string;
  107921. /**
  107922. * Add fallbacks to the effect fallbacks list.
  107923. * @param defines defines the Base texture to use.
  107924. * @param fallbacks defines the current fallback list.
  107925. * @param currentRank defines the current fallback rank.
  107926. * @returns the new fallback rank.
  107927. */
  107928. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107929. /**
  107930. * Add the required uniforms to the current list.
  107931. * @param uniforms defines the current uniform list.
  107932. */
  107933. static AddUniforms(uniforms: string[]): void;
  107934. /**
  107935. * Add the required uniforms to the current buffer.
  107936. * @param uniformBuffer defines the current uniform buffer.
  107937. */
  107938. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107939. /**
  107940. * Add the required samplers to the current list.
  107941. * @param samplers defines the current sampler list.
  107942. */
  107943. static AddSamplers(samplers: string[]): void;
  107944. /**
  107945. * Makes a duplicate of the current configuration into another one.
  107946. * @param anisotropicConfiguration define the config where to copy the info
  107947. */
  107948. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107949. /**
  107950. * Serializes this anisotropy configuration.
  107951. * @returns - An object with the serialized config.
  107952. */
  107953. serialize(): any;
  107954. /**
  107955. * Parses a anisotropy Configuration from a serialized object.
  107956. * @param source - Serialized object.
  107957. * @param scene Defines the scene we are parsing for
  107958. * @param rootUrl Defines the rootUrl to load from
  107959. */
  107960. parse(source: any, scene: Scene, rootUrl: string): void;
  107961. }
  107962. }
  107963. declare module BABYLON {
  107964. /**
  107965. * @hidden
  107966. */
  107967. export interface IMaterialBRDFDefines {
  107968. BRDF_V_HEIGHT_CORRELATED: boolean;
  107969. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107970. SPHERICAL_HARMONICS: boolean;
  107971. /** @hidden */
  107972. _areMiscDirty: boolean;
  107973. }
  107974. /**
  107975. * Define the code related to the BRDF parameters of the pbr material.
  107976. */
  107977. export class PBRBRDFConfiguration {
  107978. /**
  107979. * Default value used for the energy conservation.
  107980. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107981. */
  107982. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107983. /**
  107984. * Default value used for the Smith Visibility Height Correlated mode.
  107985. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107986. */
  107987. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107988. /**
  107989. * Default value used for the IBL diffuse part.
  107990. * This can help switching back to the polynomials mode globally which is a tiny bit
  107991. * less GPU intensive at the drawback of a lower quality.
  107992. */
  107993. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107994. private _useEnergyConservation;
  107995. /**
  107996. * Defines if the material uses energy conservation.
  107997. */
  107998. useEnergyConservation: boolean;
  107999. private _useSmithVisibilityHeightCorrelated;
  108000. /**
  108001. * LEGACY Mode set to false
  108002. * Defines if the material uses height smith correlated visibility term.
  108003. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  108004. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  108005. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  108006. * Not relying on height correlated will also disable energy conservation.
  108007. */
  108008. useSmithVisibilityHeightCorrelated: boolean;
  108009. private _useSphericalHarmonics;
  108010. /**
  108011. * LEGACY Mode set to false
  108012. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  108013. * diffuse part of the IBL.
  108014. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  108015. * to the ground truth.
  108016. */
  108017. useSphericalHarmonics: boolean;
  108018. /** @hidden */
  108019. private _internalMarkAllSubMeshesAsMiscDirty;
  108020. /** @hidden */
  108021. _markAllSubMeshesAsMiscDirty(): void;
  108022. /**
  108023. * Instantiate a new istance of clear coat configuration.
  108024. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  108025. */
  108026. constructor(markAllSubMeshesAsMiscDirty: () => void);
  108027. /**
  108028. * Checks to see if a texture is used in the material.
  108029. * @param defines the list of "defines" to update.
  108030. */
  108031. prepareDefines(defines: IMaterialBRDFDefines): void;
  108032. /**
  108033. * Get the current class name of the texture useful for serialization or dynamic coding.
  108034. * @returns "PBRClearCoatConfiguration"
  108035. */
  108036. getClassName(): string;
  108037. /**
  108038. * Makes a duplicate of the current configuration into another one.
  108039. * @param brdfConfiguration define the config where to copy the info
  108040. */
  108041. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  108042. /**
  108043. * Serializes this BRDF configuration.
  108044. * @returns - An object with the serialized config.
  108045. */
  108046. serialize(): any;
  108047. /**
  108048. * Parses a anisotropy Configuration from a serialized object.
  108049. * @param source - Serialized object.
  108050. * @param scene Defines the scene we are parsing for
  108051. * @param rootUrl Defines the rootUrl to load from
  108052. */
  108053. parse(source: any, scene: Scene, rootUrl: string): void;
  108054. }
  108055. }
  108056. declare module BABYLON {
  108057. /**
  108058. * @hidden
  108059. */
  108060. export interface IMaterialSheenDefines {
  108061. SHEEN: boolean;
  108062. SHEEN_TEXTURE: boolean;
  108063. SHEEN_TEXTUREDIRECTUV: number;
  108064. SHEEN_LINKWITHALBEDO: boolean;
  108065. /** @hidden */
  108066. _areTexturesDirty: boolean;
  108067. }
  108068. /**
  108069. * Define the code related to the Sheen parameters of the pbr material.
  108070. */
  108071. export class PBRSheenConfiguration {
  108072. private _isEnabled;
  108073. /**
  108074. * Defines if the material uses sheen.
  108075. */
  108076. isEnabled: boolean;
  108077. private _linkSheenWithAlbedo;
  108078. /**
  108079. * Defines if the sheen is linked to the sheen color.
  108080. */
  108081. linkSheenWithAlbedo: boolean;
  108082. /**
  108083. * Defines the sheen intensity.
  108084. */
  108085. intensity: number;
  108086. /**
  108087. * Defines the sheen color.
  108088. */
  108089. color: Color3;
  108090. private _texture;
  108091. /**
  108092. * Stores the sheen tint values in a texture.
  108093. * rgb is tint
  108094. * a is a intensity
  108095. */
  108096. texture: Nullable<BaseTexture>;
  108097. /** @hidden */
  108098. private _internalMarkAllSubMeshesAsTexturesDirty;
  108099. /** @hidden */
  108100. _markAllSubMeshesAsTexturesDirty(): void;
  108101. /**
  108102. * Instantiate a new istance of clear coat configuration.
  108103. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108104. */
  108105. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108106. /**
  108107. * Specifies that the submesh is ready to be used.
  108108. * @param defines the list of "defines" to update.
  108109. * @param scene defines the scene the material belongs to.
  108110. * @returns - boolean indicating that the submesh is ready or not.
  108111. */
  108112. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  108113. /**
  108114. * Checks to see if a texture is used in the material.
  108115. * @param defines the list of "defines" to update.
  108116. * @param scene defines the scene the material belongs to.
  108117. */
  108118. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  108119. /**
  108120. * Binds the material data.
  108121. * @param uniformBuffer defines the Uniform buffer to fill in.
  108122. * @param scene defines the scene the material belongs to.
  108123. * @param isFrozen defines wether the material is frozen or not.
  108124. */
  108125. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  108126. /**
  108127. * Checks to see if a texture is used in the material.
  108128. * @param texture - Base texture to use.
  108129. * @returns - Boolean specifying if a texture is used in the material.
  108130. */
  108131. hasTexture(texture: BaseTexture): boolean;
  108132. /**
  108133. * Returns an array of the actively used textures.
  108134. * @param activeTextures Array of BaseTextures
  108135. */
  108136. getActiveTextures(activeTextures: BaseTexture[]): void;
  108137. /**
  108138. * Returns the animatable textures.
  108139. * @param animatables Array of animatable textures.
  108140. */
  108141. getAnimatables(animatables: IAnimatable[]): void;
  108142. /**
  108143. * Disposes the resources of the material.
  108144. * @param forceDisposeTextures - Forces the disposal of all textures.
  108145. */
  108146. dispose(forceDisposeTextures?: boolean): void;
  108147. /**
  108148. * Get the current class name of the texture useful for serialization or dynamic coding.
  108149. * @returns "PBRSheenConfiguration"
  108150. */
  108151. getClassName(): string;
  108152. /**
  108153. * Add fallbacks to the effect fallbacks list.
  108154. * @param defines defines the Base texture to use.
  108155. * @param fallbacks defines the current fallback list.
  108156. * @param currentRank defines the current fallback rank.
  108157. * @returns the new fallback rank.
  108158. */
  108159. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108160. /**
  108161. * Add the required uniforms to the current list.
  108162. * @param uniforms defines the current uniform list.
  108163. */
  108164. static AddUniforms(uniforms: string[]): void;
  108165. /**
  108166. * Add the required uniforms to the current buffer.
  108167. * @param uniformBuffer defines the current uniform buffer.
  108168. */
  108169. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108170. /**
  108171. * Add the required samplers to the current list.
  108172. * @param samplers defines the current sampler list.
  108173. */
  108174. static AddSamplers(samplers: string[]): void;
  108175. /**
  108176. * Makes a duplicate of the current configuration into another one.
  108177. * @param sheenConfiguration define the config where to copy the info
  108178. */
  108179. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  108180. /**
  108181. * Serializes this BRDF configuration.
  108182. * @returns - An object with the serialized config.
  108183. */
  108184. serialize(): any;
  108185. /**
  108186. * Parses a anisotropy Configuration from a serialized object.
  108187. * @param source - Serialized object.
  108188. * @param scene Defines the scene we are parsing for
  108189. * @param rootUrl Defines the rootUrl to load from
  108190. */
  108191. parse(source: any, scene: Scene, rootUrl: string): void;
  108192. }
  108193. }
  108194. declare module BABYLON {
  108195. /**
  108196. * @hidden
  108197. */
  108198. export interface IMaterialSubSurfaceDefines {
  108199. SUBSURFACE: boolean;
  108200. SS_REFRACTION: boolean;
  108201. SS_TRANSLUCENCY: boolean;
  108202. SS_SCATERRING: boolean;
  108203. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108204. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108205. SS_REFRACTIONMAP_3D: boolean;
  108206. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108207. SS_LODINREFRACTIONALPHA: boolean;
  108208. SS_GAMMAREFRACTION: boolean;
  108209. SS_RGBDREFRACTION: boolean;
  108210. SS_LINEARSPECULARREFRACTION: boolean;
  108211. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108212. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108213. /** @hidden */
  108214. _areTexturesDirty: boolean;
  108215. }
  108216. /**
  108217. * Define the code related to the sub surface parameters of the pbr material.
  108218. */
  108219. export class PBRSubSurfaceConfiguration {
  108220. private _isRefractionEnabled;
  108221. /**
  108222. * Defines if the refraction is enabled in the material.
  108223. */
  108224. isRefractionEnabled: boolean;
  108225. private _isTranslucencyEnabled;
  108226. /**
  108227. * Defines if the translucency is enabled in the material.
  108228. */
  108229. isTranslucencyEnabled: boolean;
  108230. private _isScatteringEnabled;
  108231. /**
  108232. * Defines the refraction intensity of the material.
  108233. * The refraction when enabled replaces the Diffuse part of the material.
  108234. * The intensity helps transitionning between diffuse and refraction.
  108235. */
  108236. refractionIntensity: number;
  108237. /**
  108238. * Defines the translucency intensity of the material.
  108239. * When translucency has been enabled, this defines how much of the "translucency"
  108240. * is addded to the diffuse part of the material.
  108241. */
  108242. translucencyIntensity: number;
  108243. /**
  108244. * Defines the scattering intensity of the material.
  108245. * When scattering has been enabled, this defines how much of the "scattered light"
  108246. * is addded to the diffuse part of the material.
  108247. */
  108248. scatteringIntensity: number;
  108249. private _thicknessTexture;
  108250. /**
  108251. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  108252. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  108253. * 0 would mean minimumThickness
  108254. * 1 would mean maximumThickness
  108255. * The other channels might be use as a mask to vary the different effects intensity.
  108256. */
  108257. thicknessTexture: Nullable<BaseTexture>;
  108258. private _refractionTexture;
  108259. /**
  108260. * Defines the texture to use for refraction.
  108261. */
  108262. refractionTexture: Nullable<BaseTexture>;
  108263. private _indexOfRefraction;
  108264. /**
  108265. * Defines the index of refraction used in the material.
  108266. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  108267. */
  108268. indexOfRefraction: number;
  108269. private _invertRefractionY;
  108270. /**
  108271. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108272. */
  108273. invertRefractionY: boolean;
  108274. private _linkRefractionWithTransparency;
  108275. /**
  108276. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108277. * Materials half opaque for instance using refraction could benefit from this control.
  108278. */
  108279. linkRefractionWithTransparency: boolean;
  108280. /**
  108281. * Defines the minimum thickness stored in the thickness map.
  108282. * If no thickness map is defined, this value will be used to simulate thickness.
  108283. */
  108284. minimumThickness: number;
  108285. /**
  108286. * Defines the maximum thickness stored in the thickness map.
  108287. */
  108288. maximumThickness: number;
  108289. /**
  108290. * Defines the volume tint of the material.
  108291. * This is used for both translucency and scattering.
  108292. */
  108293. tintColor: Color3;
  108294. /**
  108295. * Defines the distance at which the tint color should be found in the media.
  108296. * This is used for refraction only.
  108297. */
  108298. tintColorAtDistance: number;
  108299. /**
  108300. * Defines how far each channel transmit through the media.
  108301. * It is defined as a color to simplify it selection.
  108302. */
  108303. diffusionDistance: Color3;
  108304. private _useMaskFromThicknessTexture;
  108305. /**
  108306. * Stores the intensity of the different subsurface effects in the thickness texture.
  108307. * * the green channel is the translucency intensity.
  108308. * * the blue channel is the scattering intensity.
  108309. * * the alpha channel is the refraction intensity.
  108310. */
  108311. useMaskFromThicknessTexture: boolean;
  108312. /** @hidden */
  108313. private _internalMarkAllSubMeshesAsTexturesDirty;
  108314. /** @hidden */
  108315. _markAllSubMeshesAsTexturesDirty(): void;
  108316. /**
  108317. * Instantiate a new istance of sub surface configuration.
  108318. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108319. */
  108320. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108321. /**
  108322. * Gets wehter the submesh is ready to be used or not.
  108323. * @param defines the list of "defines" to update.
  108324. * @param scene defines the scene the material belongs to.
  108325. * @returns - boolean indicating that the submesh is ready or not.
  108326. */
  108327. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  108328. /**
  108329. * Checks to see if a texture is used in the material.
  108330. * @param defines the list of "defines" to update.
  108331. * @param scene defines the scene to the material belongs to.
  108332. */
  108333. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  108334. /**
  108335. * Binds the material data.
  108336. * @param uniformBuffer defines the Uniform buffer to fill in.
  108337. * @param scene defines the scene the material belongs to.
  108338. * @param engine defines the engine the material belongs to.
  108339. * @param isFrozen defines wether the material is frozen or not.
  108340. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  108341. */
  108342. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  108343. /**
  108344. * Unbinds the material from the mesh.
  108345. * @param activeEffect defines the effect that should be unbound from.
  108346. * @returns true if unbound, otherwise false
  108347. */
  108348. unbind(activeEffect: Effect): boolean;
  108349. /**
  108350. * Returns the texture used for refraction or null if none is used.
  108351. * @param scene defines the scene the material belongs to.
  108352. * @returns - Refraction texture if present. If no refraction texture and refraction
  108353. * is linked with transparency, returns environment texture. Otherwise, returns null.
  108354. */
  108355. private _getRefractionTexture;
  108356. /**
  108357. * Returns true if alpha blending should be disabled.
  108358. */
  108359. readonly disableAlphaBlending: boolean;
  108360. /**
  108361. * Fills the list of render target textures.
  108362. * @param renderTargets the list of render targets to update
  108363. */
  108364. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  108365. /**
  108366. * Checks to see if a texture is used in the material.
  108367. * @param texture - Base texture to use.
  108368. * @returns - Boolean specifying if a texture is used in the material.
  108369. */
  108370. hasTexture(texture: BaseTexture): boolean;
  108371. /**
  108372. * Gets a boolean indicating that current material needs to register RTT
  108373. * @returns true if this uses a render target otherwise false.
  108374. */
  108375. hasRenderTargetTextures(): boolean;
  108376. /**
  108377. * Returns an array of the actively used textures.
  108378. * @param activeTextures Array of BaseTextures
  108379. */
  108380. getActiveTextures(activeTextures: BaseTexture[]): void;
  108381. /**
  108382. * Returns the animatable textures.
  108383. * @param animatables Array of animatable textures.
  108384. */
  108385. getAnimatables(animatables: IAnimatable[]): void;
  108386. /**
  108387. * Disposes the resources of the material.
  108388. * @param forceDisposeTextures - Forces the disposal of all textures.
  108389. */
  108390. dispose(forceDisposeTextures?: boolean): void;
  108391. /**
  108392. * Get the current class name of the texture useful for serialization or dynamic coding.
  108393. * @returns "PBRSubSurfaceConfiguration"
  108394. */
  108395. getClassName(): string;
  108396. /**
  108397. * Add fallbacks to the effect fallbacks list.
  108398. * @param defines defines the Base texture to use.
  108399. * @param fallbacks defines the current fallback list.
  108400. * @param currentRank defines the current fallback rank.
  108401. * @returns the new fallback rank.
  108402. */
  108403. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108404. /**
  108405. * Add the required uniforms to the current list.
  108406. * @param uniforms defines the current uniform list.
  108407. */
  108408. static AddUniforms(uniforms: string[]): void;
  108409. /**
  108410. * Add the required samplers to the current list.
  108411. * @param samplers defines the current sampler list.
  108412. */
  108413. static AddSamplers(samplers: string[]): void;
  108414. /**
  108415. * Add the required uniforms to the current buffer.
  108416. * @param uniformBuffer defines the current uniform buffer.
  108417. */
  108418. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108419. /**
  108420. * Makes a duplicate of the current configuration into another one.
  108421. * @param configuration define the config where to copy the info
  108422. */
  108423. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  108424. /**
  108425. * Serializes this Sub Surface configuration.
  108426. * @returns - An object with the serialized config.
  108427. */
  108428. serialize(): any;
  108429. /**
  108430. * Parses a anisotropy Configuration from a serialized object.
  108431. * @param source - Serialized object.
  108432. * @param scene Defines the scene we are parsing for
  108433. * @param rootUrl Defines the rootUrl to load from
  108434. */
  108435. parse(source: any, scene: Scene, rootUrl: string): void;
  108436. }
  108437. }
  108438. declare module BABYLON {
  108439. /** @hidden */
  108440. export var pbrFragmentDeclaration: {
  108441. name: string;
  108442. shader: string;
  108443. };
  108444. }
  108445. declare module BABYLON {
  108446. /** @hidden */
  108447. export var pbrUboDeclaration: {
  108448. name: string;
  108449. shader: string;
  108450. };
  108451. }
  108452. declare module BABYLON {
  108453. /** @hidden */
  108454. export var pbrFragmentExtraDeclaration: {
  108455. name: string;
  108456. shader: string;
  108457. };
  108458. }
  108459. declare module BABYLON {
  108460. /** @hidden */
  108461. export var pbrFragmentSamplersDeclaration: {
  108462. name: string;
  108463. shader: string;
  108464. };
  108465. }
  108466. declare module BABYLON {
  108467. /** @hidden */
  108468. export var pbrHelperFunctions: {
  108469. name: string;
  108470. shader: string;
  108471. };
  108472. }
  108473. declare module BABYLON {
  108474. /** @hidden */
  108475. export var harmonicsFunctions: {
  108476. name: string;
  108477. shader: string;
  108478. };
  108479. }
  108480. declare module BABYLON {
  108481. /** @hidden */
  108482. export var pbrDirectLightingSetupFunctions: {
  108483. name: string;
  108484. shader: string;
  108485. };
  108486. }
  108487. declare module BABYLON {
  108488. /** @hidden */
  108489. export var pbrDirectLightingFalloffFunctions: {
  108490. name: string;
  108491. shader: string;
  108492. };
  108493. }
  108494. declare module BABYLON {
  108495. /** @hidden */
  108496. export var pbrBRDFFunctions: {
  108497. name: string;
  108498. shader: string;
  108499. };
  108500. }
  108501. declare module BABYLON {
  108502. /** @hidden */
  108503. export var pbrDirectLightingFunctions: {
  108504. name: string;
  108505. shader: string;
  108506. };
  108507. }
  108508. declare module BABYLON {
  108509. /** @hidden */
  108510. export var pbrIBLFunctions: {
  108511. name: string;
  108512. shader: string;
  108513. };
  108514. }
  108515. declare module BABYLON {
  108516. /** @hidden */
  108517. export var pbrDebug: {
  108518. name: string;
  108519. shader: string;
  108520. };
  108521. }
  108522. declare module BABYLON {
  108523. /** @hidden */
  108524. export var pbrPixelShader: {
  108525. name: string;
  108526. shader: string;
  108527. };
  108528. }
  108529. declare module BABYLON {
  108530. /** @hidden */
  108531. export var pbrVertexDeclaration: {
  108532. name: string;
  108533. shader: string;
  108534. };
  108535. }
  108536. declare module BABYLON {
  108537. /** @hidden */
  108538. export var pbrVertexShader: {
  108539. name: string;
  108540. shader: string;
  108541. };
  108542. }
  108543. declare module BABYLON {
  108544. /**
  108545. * Manages the defines for the PBR Material.
  108546. * @hidden
  108547. */
  108548. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  108549. PBR: boolean;
  108550. MAINUV1: boolean;
  108551. MAINUV2: boolean;
  108552. UV1: boolean;
  108553. UV2: boolean;
  108554. ALBEDO: boolean;
  108555. ALBEDODIRECTUV: number;
  108556. VERTEXCOLOR: boolean;
  108557. AMBIENT: boolean;
  108558. AMBIENTDIRECTUV: number;
  108559. AMBIENTINGRAYSCALE: boolean;
  108560. OPACITY: boolean;
  108561. VERTEXALPHA: boolean;
  108562. OPACITYDIRECTUV: number;
  108563. OPACITYRGB: boolean;
  108564. ALPHATEST: boolean;
  108565. DEPTHPREPASS: boolean;
  108566. ALPHABLEND: boolean;
  108567. ALPHAFROMALBEDO: boolean;
  108568. ALPHATESTVALUE: string;
  108569. SPECULAROVERALPHA: boolean;
  108570. RADIANCEOVERALPHA: boolean;
  108571. ALPHAFRESNEL: boolean;
  108572. LINEARALPHAFRESNEL: boolean;
  108573. PREMULTIPLYALPHA: boolean;
  108574. EMISSIVE: boolean;
  108575. EMISSIVEDIRECTUV: number;
  108576. REFLECTIVITY: boolean;
  108577. REFLECTIVITYDIRECTUV: number;
  108578. SPECULARTERM: boolean;
  108579. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  108580. MICROSURFACEAUTOMATIC: boolean;
  108581. LODBASEDMICROSFURACE: boolean;
  108582. MICROSURFACEMAP: boolean;
  108583. MICROSURFACEMAPDIRECTUV: number;
  108584. METALLICWORKFLOW: boolean;
  108585. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  108586. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  108587. METALLNESSSTOREINMETALMAPBLUE: boolean;
  108588. AOSTOREINMETALMAPRED: boolean;
  108589. ENVIRONMENTBRDF: boolean;
  108590. ENVIRONMENTBRDF_RGBD: boolean;
  108591. NORMAL: boolean;
  108592. TANGENT: boolean;
  108593. BUMP: boolean;
  108594. BUMPDIRECTUV: number;
  108595. OBJECTSPACE_NORMALMAP: boolean;
  108596. PARALLAX: boolean;
  108597. PARALLAXOCCLUSION: boolean;
  108598. NORMALXYSCALE: boolean;
  108599. LIGHTMAP: boolean;
  108600. LIGHTMAPDIRECTUV: number;
  108601. USELIGHTMAPASSHADOWMAP: boolean;
  108602. GAMMALIGHTMAP: boolean;
  108603. REFLECTION: boolean;
  108604. REFLECTIONMAP_3D: boolean;
  108605. REFLECTIONMAP_SPHERICAL: boolean;
  108606. REFLECTIONMAP_PLANAR: boolean;
  108607. REFLECTIONMAP_CUBIC: boolean;
  108608. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108609. REFLECTIONMAP_PROJECTION: boolean;
  108610. REFLECTIONMAP_SKYBOX: boolean;
  108611. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108612. REFLECTIONMAP_EXPLICIT: boolean;
  108613. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108614. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108615. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108616. INVERTCUBICMAP: boolean;
  108617. USESPHERICALFROMREFLECTIONMAP: boolean;
  108618. USEIRRADIANCEMAP: boolean;
  108619. SPHERICAL_HARMONICS: boolean;
  108620. USESPHERICALINVERTEX: boolean;
  108621. REFLECTIONMAP_OPPOSITEZ: boolean;
  108622. LODINREFLECTIONALPHA: boolean;
  108623. GAMMAREFLECTION: boolean;
  108624. RGBDREFLECTION: boolean;
  108625. LINEARSPECULARREFLECTION: boolean;
  108626. RADIANCEOCCLUSION: boolean;
  108627. HORIZONOCCLUSION: boolean;
  108628. INSTANCES: boolean;
  108629. NUM_BONE_INFLUENCERS: number;
  108630. BonesPerMesh: number;
  108631. BONETEXTURE: boolean;
  108632. NONUNIFORMSCALING: boolean;
  108633. MORPHTARGETS: boolean;
  108634. MORPHTARGETS_NORMAL: boolean;
  108635. MORPHTARGETS_TANGENT: boolean;
  108636. MORPHTARGETS_UV: boolean;
  108637. NUM_MORPH_INFLUENCERS: number;
  108638. IMAGEPROCESSING: boolean;
  108639. VIGNETTE: boolean;
  108640. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108641. VIGNETTEBLENDMODEOPAQUE: boolean;
  108642. TONEMAPPING: boolean;
  108643. TONEMAPPING_ACES: boolean;
  108644. CONTRAST: boolean;
  108645. COLORCURVES: boolean;
  108646. COLORGRADING: boolean;
  108647. COLORGRADING3D: boolean;
  108648. SAMPLER3DGREENDEPTH: boolean;
  108649. SAMPLER3DBGRMAP: boolean;
  108650. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108651. EXPOSURE: boolean;
  108652. MULTIVIEW: boolean;
  108653. USEPHYSICALLIGHTFALLOFF: boolean;
  108654. USEGLTFLIGHTFALLOFF: boolean;
  108655. TWOSIDEDLIGHTING: boolean;
  108656. SHADOWFLOAT: boolean;
  108657. CLIPPLANE: boolean;
  108658. CLIPPLANE2: boolean;
  108659. CLIPPLANE3: boolean;
  108660. CLIPPLANE4: boolean;
  108661. POINTSIZE: boolean;
  108662. FOG: boolean;
  108663. LOGARITHMICDEPTH: boolean;
  108664. FORCENORMALFORWARD: boolean;
  108665. SPECULARAA: boolean;
  108666. CLEARCOAT: boolean;
  108667. CLEARCOAT_DEFAULTIOR: boolean;
  108668. CLEARCOAT_TEXTURE: boolean;
  108669. CLEARCOAT_TEXTUREDIRECTUV: number;
  108670. CLEARCOAT_BUMP: boolean;
  108671. CLEARCOAT_BUMPDIRECTUV: number;
  108672. CLEARCOAT_TINT: boolean;
  108673. CLEARCOAT_TINT_TEXTURE: boolean;
  108674. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108675. ANISOTROPIC: boolean;
  108676. ANISOTROPIC_TEXTURE: boolean;
  108677. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108678. BRDF_V_HEIGHT_CORRELATED: boolean;
  108679. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108680. SHEEN: boolean;
  108681. SHEEN_TEXTURE: boolean;
  108682. SHEEN_TEXTUREDIRECTUV: number;
  108683. SHEEN_LINKWITHALBEDO: boolean;
  108684. SUBSURFACE: boolean;
  108685. SS_REFRACTION: boolean;
  108686. SS_TRANSLUCENCY: boolean;
  108687. SS_SCATERRING: boolean;
  108688. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108689. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108690. SS_REFRACTIONMAP_3D: boolean;
  108691. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108692. SS_LODINREFRACTIONALPHA: boolean;
  108693. SS_GAMMAREFRACTION: boolean;
  108694. SS_RGBDREFRACTION: boolean;
  108695. SS_LINEARSPECULARREFRACTION: boolean;
  108696. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108697. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108698. UNLIT: boolean;
  108699. DEBUGMODE: number;
  108700. /**
  108701. * Initializes the PBR Material defines.
  108702. */
  108703. constructor();
  108704. /**
  108705. * Resets the PBR Material defines.
  108706. */
  108707. reset(): void;
  108708. }
  108709. /**
  108710. * The Physically based material base class of BJS.
  108711. *
  108712. * This offers the main features of a standard PBR material.
  108713. * For more information, please refer to the documentation :
  108714. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108715. */
  108716. export abstract class PBRBaseMaterial extends PushMaterial {
  108717. /**
  108718. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108719. */
  108720. static readonly PBRMATERIAL_OPAQUE: number;
  108721. /**
  108722. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108723. */
  108724. static readonly PBRMATERIAL_ALPHATEST: number;
  108725. /**
  108726. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108727. */
  108728. static readonly PBRMATERIAL_ALPHABLEND: number;
  108729. /**
  108730. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108731. * They are also discarded below the alpha cutoff threshold to improve performances.
  108732. */
  108733. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108734. /**
  108735. * Defines the default value of how much AO map is occluding the analytical lights
  108736. * (point spot...).
  108737. */
  108738. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108739. /**
  108740. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  108741. */
  108742. static readonly LIGHTFALLOFF_PHYSICAL: number;
  108743. /**
  108744. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  108745. * to enhance interoperability with other engines.
  108746. */
  108747. static readonly LIGHTFALLOFF_GLTF: number;
  108748. /**
  108749. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  108750. * to enhance interoperability with other materials.
  108751. */
  108752. static readonly LIGHTFALLOFF_STANDARD: number;
  108753. /**
  108754. * Intensity of the direct lights e.g. the four lights available in your scene.
  108755. * This impacts both the direct diffuse and specular highlights.
  108756. */
  108757. protected _directIntensity: number;
  108758. /**
  108759. * Intensity of the emissive part of the material.
  108760. * This helps controlling the emissive effect without modifying the emissive color.
  108761. */
  108762. protected _emissiveIntensity: number;
  108763. /**
  108764. * Intensity of the environment e.g. how much the environment will light the object
  108765. * either through harmonics for rough material or through the refelction for shiny ones.
  108766. */
  108767. protected _environmentIntensity: number;
  108768. /**
  108769. * This is a special control allowing the reduction of the specular highlights coming from the
  108770. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108771. */
  108772. protected _specularIntensity: number;
  108773. /**
  108774. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  108775. */
  108776. private _lightingInfos;
  108777. /**
  108778. * Debug Control allowing disabling the bump map on this material.
  108779. */
  108780. protected _disableBumpMap: boolean;
  108781. /**
  108782. * AKA Diffuse Texture in standard nomenclature.
  108783. */
  108784. protected _albedoTexture: Nullable<BaseTexture>;
  108785. /**
  108786. * AKA Occlusion Texture in other nomenclature.
  108787. */
  108788. protected _ambientTexture: Nullable<BaseTexture>;
  108789. /**
  108790. * AKA Occlusion Texture Intensity in other nomenclature.
  108791. */
  108792. protected _ambientTextureStrength: number;
  108793. /**
  108794. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108795. * 1 means it completely occludes it
  108796. * 0 mean it has no impact
  108797. */
  108798. protected _ambientTextureImpactOnAnalyticalLights: number;
  108799. /**
  108800. * Stores the alpha values in a texture.
  108801. */
  108802. protected _opacityTexture: Nullable<BaseTexture>;
  108803. /**
  108804. * Stores the reflection values in a texture.
  108805. */
  108806. protected _reflectionTexture: Nullable<BaseTexture>;
  108807. /**
  108808. * Stores the emissive values in a texture.
  108809. */
  108810. protected _emissiveTexture: Nullable<BaseTexture>;
  108811. /**
  108812. * AKA Specular texture in other nomenclature.
  108813. */
  108814. protected _reflectivityTexture: Nullable<BaseTexture>;
  108815. /**
  108816. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108817. */
  108818. protected _metallicTexture: Nullable<BaseTexture>;
  108819. /**
  108820. * Specifies the metallic scalar of the metallic/roughness workflow.
  108821. * Can also be used to scale the metalness values of the metallic texture.
  108822. */
  108823. protected _metallic: Nullable<number>;
  108824. /**
  108825. * Specifies the roughness scalar of the metallic/roughness workflow.
  108826. * Can also be used to scale the roughness values of the metallic texture.
  108827. */
  108828. protected _roughness: Nullable<number>;
  108829. /**
  108830. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108831. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108832. */
  108833. protected _microSurfaceTexture: Nullable<BaseTexture>;
  108834. /**
  108835. * Stores surface normal data used to displace a mesh in a texture.
  108836. */
  108837. protected _bumpTexture: Nullable<BaseTexture>;
  108838. /**
  108839. * Stores the pre-calculated light information of a mesh in a texture.
  108840. */
  108841. protected _lightmapTexture: Nullable<BaseTexture>;
  108842. /**
  108843. * The color of a material in ambient lighting.
  108844. */
  108845. protected _ambientColor: Color3;
  108846. /**
  108847. * AKA Diffuse Color in other nomenclature.
  108848. */
  108849. protected _albedoColor: Color3;
  108850. /**
  108851. * AKA Specular Color in other nomenclature.
  108852. */
  108853. protected _reflectivityColor: Color3;
  108854. /**
  108855. * The color applied when light is reflected from a material.
  108856. */
  108857. protected _reflectionColor: Color3;
  108858. /**
  108859. * The color applied when light is emitted from a material.
  108860. */
  108861. protected _emissiveColor: Color3;
  108862. /**
  108863. * AKA Glossiness in other nomenclature.
  108864. */
  108865. protected _microSurface: number;
  108866. /**
  108867. * Specifies that the material will use the light map as a show map.
  108868. */
  108869. protected _useLightmapAsShadowmap: boolean;
  108870. /**
  108871. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108872. * makes the reflect vector face the model (under horizon).
  108873. */
  108874. protected _useHorizonOcclusion: boolean;
  108875. /**
  108876. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108877. * too much the area relying on ambient texture to define their ambient occlusion.
  108878. */
  108879. protected _useRadianceOcclusion: boolean;
  108880. /**
  108881. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108882. */
  108883. protected _useAlphaFromAlbedoTexture: boolean;
  108884. /**
  108885. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  108886. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108887. */
  108888. protected _useSpecularOverAlpha: boolean;
  108889. /**
  108890. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108891. */
  108892. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108893. /**
  108894. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108895. */
  108896. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  108897. /**
  108898. * Specifies if the metallic texture contains the roughness information in its green channel.
  108899. */
  108900. protected _useRoughnessFromMetallicTextureGreen: boolean;
  108901. /**
  108902. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108903. */
  108904. protected _useMetallnessFromMetallicTextureBlue: boolean;
  108905. /**
  108906. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108907. */
  108908. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108909. /**
  108910. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108911. */
  108912. protected _useAmbientInGrayScale: boolean;
  108913. /**
  108914. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108915. * The material will try to infer what glossiness each pixel should be.
  108916. */
  108917. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108918. /**
  108919. * Defines the falloff type used in this material.
  108920. * It by default is Physical.
  108921. */
  108922. protected _lightFalloff: number;
  108923. /**
  108924. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108925. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108926. */
  108927. protected _useRadianceOverAlpha: boolean;
  108928. /**
  108929. * Allows using an object space normal map (instead of tangent space).
  108930. */
  108931. protected _useObjectSpaceNormalMap: boolean;
  108932. /**
  108933. * Allows using the bump map in parallax mode.
  108934. */
  108935. protected _useParallax: boolean;
  108936. /**
  108937. * Allows using the bump map in parallax occlusion mode.
  108938. */
  108939. protected _useParallaxOcclusion: boolean;
  108940. /**
  108941. * Controls the scale bias of the parallax mode.
  108942. */
  108943. protected _parallaxScaleBias: number;
  108944. /**
  108945. * If sets to true, disables all the lights affecting the material.
  108946. */
  108947. protected _disableLighting: boolean;
  108948. /**
  108949. * Number of Simultaneous lights allowed on the material.
  108950. */
  108951. protected _maxSimultaneousLights: number;
  108952. /**
  108953. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108954. */
  108955. protected _invertNormalMapX: boolean;
  108956. /**
  108957. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108958. */
  108959. protected _invertNormalMapY: boolean;
  108960. /**
  108961. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108962. */
  108963. protected _twoSidedLighting: boolean;
  108964. /**
  108965. * Defines the alpha limits in alpha test mode.
  108966. */
  108967. protected _alphaCutOff: number;
  108968. /**
  108969. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108970. */
  108971. protected _forceAlphaTest: boolean;
  108972. /**
  108973. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108974. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108975. */
  108976. protected _useAlphaFresnel: boolean;
  108977. /**
  108978. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108979. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108980. */
  108981. protected _useLinearAlphaFresnel: boolean;
  108982. /**
  108983. * The transparency mode of the material.
  108984. */
  108985. protected _transparencyMode: Nullable<number>;
  108986. /**
  108987. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108988. * from cos thetav and roughness:
  108989. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108990. */
  108991. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108992. /**
  108993. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108994. */
  108995. protected _forceIrradianceInFragment: boolean;
  108996. /**
  108997. * Force normal to face away from face.
  108998. */
  108999. protected _forceNormalForward: boolean;
  109000. /**
  109001. * Enables specular anti aliasing in the PBR shader.
  109002. * It will both interacts on the Geometry for analytical and IBL lighting.
  109003. * It also prefilter the roughness map based on the bump values.
  109004. */
  109005. protected _enableSpecularAntiAliasing: boolean;
  109006. /**
  109007. * Default configuration related to image processing available in the PBR Material.
  109008. */
  109009. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109010. /**
  109011. * Keep track of the image processing observer to allow dispose and replace.
  109012. */
  109013. private _imageProcessingObserver;
  109014. /**
  109015. * Attaches a new image processing configuration to the PBR Material.
  109016. * @param configuration
  109017. */
  109018. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109019. /**
  109020. * Stores the available render targets.
  109021. */
  109022. private _renderTargets;
  109023. /**
  109024. * Sets the global ambient color for the material used in lighting calculations.
  109025. */
  109026. private _globalAmbientColor;
  109027. /**
  109028. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  109029. */
  109030. private _useLogarithmicDepth;
  109031. /**
  109032. * If set to true, no lighting calculations will be applied.
  109033. */
  109034. private _unlit;
  109035. private _debugMode;
  109036. /**
  109037. * @hidden
  109038. * This is reserved for the inspector.
  109039. * Defines the material debug mode.
  109040. * It helps seeing only some components of the material while troubleshooting.
  109041. */
  109042. debugMode: number;
  109043. /**
  109044. * @hidden
  109045. * This is reserved for the inspector.
  109046. * Specify from where on screen the debug mode should start.
  109047. * The value goes from -1 (full screen) to 1 (not visible)
  109048. * It helps with side by side comparison against the final render
  109049. * This defaults to -1
  109050. */
  109051. private debugLimit;
  109052. /**
  109053. * @hidden
  109054. * This is reserved for the inspector.
  109055. * As the default viewing range might not be enough (if the ambient is really small for instance)
  109056. * You can use the factor to better multiply the final value.
  109057. */
  109058. private debugFactor;
  109059. /**
  109060. * Defines the clear coat layer parameters for the material.
  109061. */
  109062. readonly clearCoat: PBRClearCoatConfiguration;
  109063. /**
  109064. * Defines the anisotropic parameters for the material.
  109065. */
  109066. readonly anisotropy: PBRAnisotropicConfiguration;
  109067. /**
  109068. * Defines the BRDF parameters for the material.
  109069. */
  109070. readonly brdf: PBRBRDFConfiguration;
  109071. /**
  109072. * Defines the Sheen parameters for the material.
  109073. */
  109074. readonly sheen: PBRSheenConfiguration;
  109075. /**
  109076. * Defines the SubSurface parameters for the material.
  109077. */
  109078. readonly subSurface: PBRSubSurfaceConfiguration;
  109079. /**
  109080. * Custom callback helping to override the default shader used in the material.
  109081. */
  109082. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  109083. /**
  109084. * Instantiates a new PBRMaterial instance.
  109085. *
  109086. * @param name The material name
  109087. * @param scene The scene the material will be use in.
  109088. */
  109089. constructor(name: string, scene: Scene);
  109090. /**
  109091. * Gets a boolean indicating that current material needs to register RTT
  109092. */
  109093. readonly hasRenderTargetTextures: boolean;
  109094. /**
  109095. * Gets the name of the material class.
  109096. */
  109097. getClassName(): string;
  109098. /**
  109099. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  109100. */
  109101. /**
  109102. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  109103. */
  109104. useLogarithmicDepth: boolean;
  109105. /**
  109106. * Gets the current transparency mode.
  109107. */
  109108. /**
  109109. * Sets the transparency mode of the material.
  109110. *
  109111. * | Value | Type | Description |
  109112. * | ----- | ----------------------------------- | ----------- |
  109113. * | 0 | OPAQUE | |
  109114. * | 1 | ALPHATEST | |
  109115. * | 2 | ALPHABLEND | |
  109116. * | 3 | ALPHATESTANDBLEND | |
  109117. *
  109118. */
  109119. transparencyMode: Nullable<number>;
  109120. /**
  109121. * Returns true if alpha blending should be disabled.
  109122. */
  109123. private readonly _disableAlphaBlending;
  109124. /**
  109125. * Specifies whether or not this material should be rendered in alpha blend mode.
  109126. */
  109127. needAlphaBlending(): boolean;
  109128. /**
  109129. * Specifies if the mesh will require alpha blending.
  109130. * @param mesh - BJS mesh.
  109131. */
  109132. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  109133. /**
  109134. * Specifies whether or not this material should be rendered in alpha test mode.
  109135. */
  109136. needAlphaTesting(): boolean;
  109137. /**
  109138. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  109139. */
  109140. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  109141. /**
  109142. * Gets the texture used for the alpha test.
  109143. */
  109144. getAlphaTestTexture(): Nullable<BaseTexture>;
  109145. /**
  109146. * Specifies that the submesh is ready to be used.
  109147. * @param mesh - BJS mesh.
  109148. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  109149. * @param useInstances - Specifies that instances should be used.
  109150. * @returns - boolean indicating that the submesh is ready or not.
  109151. */
  109152. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109153. /**
  109154. * Specifies if the material uses metallic roughness workflow.
  109155. * @returns boolean specifiying if the material uses metallic roughness workflow.
  109156. */
  109157. isMetallicWorkflow(): boolean;
  109158. private _prepareEffect;
  109159. private _prepareDefines;
  109160. /**
  109161. * Force shader compilation
  109162. */
  109163. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  109164. clipPlane: boolean;
  109165. }>): void;
  109166. /**
  109167. * Initializes the uniform buffer layout for the shader.
  109168. */
  109169. buildUniformLayout(): void;
  109170. /**
  109171. * Unbinds the material from the mesh
  109172. */
  109173. unbind(): void;
  109174. /**
  109175. * Binds the submesh data.
  109176. * @param world - The world matrix.
  109177. * @param mesh - The BJS mesh.
  109178. * @param subMesh - A submesh of the BJS mesh.
  109179. */
  109180. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109181. /**
  109182. * Returns the animatable textures.
  109183. * @returns - Array of animatable textures.
  109184. */
  109185. getAnimatables(): IAnimatable[];
  109186. /**
  109187. * Returns the texture used for reflections.
  109188. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  109189. */
  109190. private _getReflectionTexture;
  109191. /**
  109192. * Returns an array of the actively used textures.
  109193. * @returns - Array of BaseTextures
  109194. */
  109195. getActiveTextures(): BaseTexture[];
  109196. /**
  109197. * Checks to see if a texture is used in the material.
  109198. * @param texture - Base texture to use.
  109199. * @returns - Boolean specifying if a texture is used in the material.
  109200. */
  109201. hasTexture(texture: BaseTexture): boolean;
  109202. /**
  109203. * Disposes the resources of the material.
  109204. * @param forceDisposeEffect - Forces the disposal of effects.
  109205. * @param forceDisposeTextures - Forces the disposal of all textures.
  109206. */
  109207. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109208. }
  109209. }
  109210. declare module BABYLON {
  109211. /**
  109212. * The Physically based material of BJS.
  109213. *
  109214. * This offers the main features of a standard PBR material.
  109215. * For more information, please refer to the documentation :
  109216. * https://doc.babylonjs.com/how_to/physically_based_rendering
  109217. */
  109218. export class PBRMaterial extends PBRBaseMaterial {
  109219. /**
  109220. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109221. */
  109222. static readonly PBRMATERIAL_OPAQUE: number;
  109223. /**
  109224. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109225. */
  109226. static readonly PBRMATERIAL_ALPHATEST: number;
  109227. /**
  109228. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109229. */
  109230. static readonly PBRMATERIAL_ALPHABLEND: number;
  109231. /**
  109232. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109233. * They are also discarded below the alpha cutoff threshold to improve performances.
  109234. */
  109235. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  109236. /**
  109237. * Defines the default value of how much AO map is occluding the analytical lights
  109238. * (point spot...).
  109239. */
  109240. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  109241. /**
  109242. * Intensity of the direct lights e.g. the four lights available in your scene.
  109243. * This impacts both the direct diffuse and specular highlights.
  109244. */
  109245. directIntensity: number;
  109246. /**
  109247. * Intensity of the emissive part of the material.
  109248. * This helps controlling the emissive effect without modifying the emissive color.
  109249. */
  109250. emissiveIntensity: number;
  109251. /**
  109252. * Intensity of the environment e.g. how much the environment will light the object
  109253. * either through harmonics for rough material or through the refelction for shiny ones.
  109254. */
  109255. environmentIntensity: number;
  109256. /**
  109257. * This is a special control allowing the reduction of the specular highlights coming from the
  109258. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  109259. */
  109260. specularIntensity: number;
  109261. /**
  109262. * Debug Control allowing disabling the bump map on this material.
  109263. */
  109264. disableBumpMap: boolean;
  109265. /**
  109266. * AKA Diffuse Texture in standard nomenclature.
  109267. */
  109268. albedoTexture: BaseTexture;
  109269. /**
  109270. * AKA Occlusion Texture in other nomenclature.
  109271. */
  109272. ambientTexture: BaseTexture;
  109273. /**
  109274. * AKA Occlusion Texture Intensity in other nomenclature.
  109275. */
  109276. ambientTextureStrength: number;
  109277. /**
  109278. * Defines how much the AO map is occluding the analytical lights (point spot...).
  109279. * 1 means it completely occludes it
  109280. * 0 mean it has no impact
  109281. */
  109282. ambientTextureImpactOnAnalyticalLights: number;
  109283. /**
  109284. * Stores the alpha values in a texture.
  109285. */
  109286. opacityTexture: BaseTexture;
  109287. /**
  109288. * Stores the reflection values in a texture.
  109289. */
  109290. reflectionTexture: Nullable<BaseTexture>;
  109291. /**
  109292. * Stores the emissive values in a texture.
  109293. */
  109294. emissiveTexture: BaseTexture;
  109295. /**
  109296. * AKA Specular texture in other nomenclature.
  109297. */
  109298. reflectivityTexture: BaseTexture;
  109299. /**
  109300. * Used to switch from specular/glossiness to metallic/roughness workflow.
  109301. */
  109302. metallicTexture: BaseTexture;
  109303. /**
  109304. * Specifies the metallic scalar of the metallic/roughness workflow.
  109305. * Can also be used to scale the metalness values of the metallic texture.
  109306. */
  109307. metallic: Nullable<number>;
  109308. /**
  109309. * Specifies the roughness scalar of the metallic/roughness workflow.
  109310. * Can also be used to scale the roughness values of the metallic texture.
  109311. */
  109312. roughness: Nullable<number>;
  109313. /**
  109314. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  109315. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  109316. */
  109317. microSurfaceTexture: BaseTexture;
  109318. /**
  109319. * Stores surface normal data used to displace a mesh in a texture.
  109320. */
  109321. bumpTexture: BaseTexture;
  109322. /**
  109323. * Stores the pre-calculated light information of a mesh in a texture.
  109324. */
  109325. lightmapTexture: BaseTexture;
  109326. /**
  109327. * Stores the refracted light information in a texture.
  109328. */
  109329. refractionTexture: Nullable<BaseTexture>;
  109330. /**
  109331. * The color of a material in ambient lighting.
  109332. */
  109333. ambientColor: Color3;
  109334. /**
  109335. * AKA Diffuse Color in other nomenclature.
  109336. */
  109337. albedoColor: Color3;
  109338. /**
  109339. * AKA Specular Color in other nomenclature.
  109340. */
  109341. reflectivityColor: Color3;
  109342. /**
  109343. * The color reflected from the material.
  109344. */
  109345. reflectionColor: Color3;
  109346. /**
  109347. * The color emitted from the material.
  109348. */
  109349. emissiveColor: Color3;
  109350. /**
  109351. * AKA Glossiness in other nomenclature.
  109352. */
  109353. microSurface: number;
  109354. /**
  109355. * source material index of refraction (IOR)' / 'destination material IOR.
  109356. */
  109357. indexOfRefraction: number;
  109358. /**
  109359. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109360. */
  109361. invertRefractionY: boolean;
  109362. /**
  109363. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109364. * Materials half opaque for instance using refraction could benefit from this control.
  109365. */
  109366. linkRefractionWithTransparency: boolean;
  109367. /**
  109368. * If true, the light map contains occlusion information instead of lighting info.
  109369. */
  109370. useLightmapAsShadowmap: boolean;
  109371. /**
  109372. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  109373. */
  109374. useAlphaFromAlbedoTexture: boolean;
  109375. /**
  109376. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109377. */
  109378. forceAlphaTest: boolean;
  109379. /**
  109380. * Defines the alpha limits in alpha test mode.
  109381. */
  109382. alphaCutOff: number;
  109383. /**
  109384. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109385. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109386. */
  109387. useSpecularOverAlpha: boolean;
  109388. /**
  109389. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  109390. */
  109391. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  109392. /**
  109393. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  109394. */
  109395. useRoughnessFromMetallicTextureAlpha: boolean;
  109396. /**
  109397. * Specifies if the metallic texture contains the roughness information in its green channel.
  109398. */
  109399. useRoughnessFromMetallicTextureGreen: boolean;
  109400. /**
  109401. * Specifies if the metallic texture contains the metallness information in its blue channel.
  109402. */
  109403. useMetallnessFromMetallicTextureBlue: boolean;
  109404. /**
  109405. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  109406. */
  109407. useAmbientOcclusionFromMetallicTextureRed: boolean;
  109408. /**
  109409. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  109410. */
  109411. useAmbientInGrayScale: boolean;
  109412. /**
  109413. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  109414. * The material will try to infer what glossiness each pixel should be.
  109415. */
  109416. useAutoMicroSurfaceFromReflectivityMap: boolean;
  109417. /**
  109418. * BJS is using an harcoded light falloff based on a manually sets up range.
  109419. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109420. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109421. */
  109422. /**
  109423. * BJS is using an harcoded light falloff based on a manually sets up range.
  109424. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109425. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109426. */
  109427. usePhysicalLightFalloff: boolean;
  109428. /**
  109429. * In order to support the falloff compatibility with gltf, a special mode has been added
  109430. * to reproduce the gltf light falloff.
  109431. */
  109432. /**
  109433. * In order to support the falloff compatibility with gltf, a special mode has been added
  109434. * to reproduce the gltf light falloff.
  109435. */
  109436. useGLTFLightFalloff: boolean;
  109437. /**
  109438. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109439. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109440. */
  109441. useRadianceOverAlpha: boolean;
  109442. /**
  109443. * Allows using an object space normal map (instead of tangent space).
  109444. */
  109445. useObjectSpaceNormalMap: boolean;
  109446. /**
  109447. * Allows using the bump map in parallax mode.
  109448. */
  109449. useParallax: boolean;
  109450. /**
  109451. * Allows using the bump map in parallax occlusion mode.
  109452. */
  109453. useParallaxOcclusion: boolean;
  109454. /**
  109455. * Controls the scale bias of the parallax mode.
  109456. */
  109457. parallaxScaleBias: number;
  109458. /**
  109459. * If sets to true, disables all the lights affecting the material.
  109460. */
  109461. disableLighting: boolean;
  109462. /**
  109463. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  109464. */
  109465. forceIrradianceInFragment: boolean;
  109466. /**
  109467. * Number of Simultaneous lights allowed on the material.
  109468. */
  109469. maxSimultaneousLights: number;
  109470. /**
  109471. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109472. */
  109473. invertNormalMapX: boolean;
  109474. /**
  109475. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109476. */
  109477. invertNormalMapY: boolean;
  109478. /**
  109479. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109480. */
  109481. twoSidedLighting: boolean;
  109482. /**
  109483. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109484. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  109485. */
  109486. useAlphaFresnel: boolean;
  109487. /**
  109488. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109489. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  109490. */
  109491. useLinearAlphaFresnel: boolean;
  109492. /**
  109493. * Let user defines the brdf lookup texture used for IBL.
  109494. * A default 8bit version is embedded but you could point at :
  109495. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  109496. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109497. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  109498. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109499. */
  109500. environmentBRDFTexture: Nullable<BaseTexture>;
  109501. /**
  109502. * Force normal to face away from face.
  109503. */
  109504. forceNormalForward: boolean;
  109505. /**
  109506. * Enables specular anti aliasing in the PBR shader.
  109507. * It will both interacts on the Geometry for analytical and IBL lighting.
  109508. * It also prefilter the roughness map based on the bump values.
  109509. */
  109510. enableSpecularAntiAliasing: boolean;
  109511. /**
  109512. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  109513. * makes the reflect vector face the model (under horizon).
  109514. */
  109515. useHorizonOcclusion: boolean;
  109516. /**
  109517. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  109518. * too much the area relying on ambient texture to define their ambient occlusion.
  109519. */
  109520. useRadianceOcclusion: boolean;
  109521. /**
  109522. * If set to true, no lighting calculations will be applied.
  109523. */
  109524. unlit: boolean;
  109525. /**
  109526. * Gets the image processing configuration used either in this material.
  109527. */
  109528. /**
  109529. * Sets the Default image processing configuration used either in the this material.
  109530. *
  109531. * If sets to null, the scene one is in use.
  109532. */
  109533. imageProcessingConfiguration: ImageProcessingConfiguration;
  109534. /**
  109535. * Gets wether the color curves effect is enabled.
  109536. */
  109537. /**
  109538. * Sets wether the color curves effect is enabled.
  109539. */
  109540. cameraColorCurvesEnabled: boolean;
  109541. /**
  109542. * Gets wether the color grading effect is enabled.
  109543. */
  109544. /**
  109545. * Gets wether the color grading effect is enabled.
  109546. */
  109547. cameraColorGradingEnabled: boolean;
  109548. /**
  109549. * Gets wether tonemapping is enabled or not.
  109550. */
  109551. /**
  109552. * Sets wether tonemapping is enabled or not
  109553. */
  109554. cameraToneMappingEnabled: boolean;
  109555. /**
  109556. * The camera exposure used on this material.
  109557. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109558. * This corresponds to a photographic exposure.
  109559. */
  109560. /**
  109561. * The camera exposure used on this material.
  109562. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109563. * This corresponds to a photographic exposure.
  109564. */
  109565. cameraExposure: number;
  109566. /**
  109567. * Gets The camera contrast used on this material.
  109568. */
  109569. /**
  109570. * Sets The camera contrast used on this material.
  109571. */
  109572. cameraContrast: number;
  109573. /**
  109574. * Gets the Color Grading 2D Lookup Texture.
  109575. */
  109576. /**
  109577. * Sets the Color Grading 2D Lookup Texture.
  109578. */
  109579. cameraColorGradingTexture: Nullable<BaseTexture>;
  109580. /**
  109581. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109582. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109583. * 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;
  109584. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109585. */
  109586. /**
  109587. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109588. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109589. * 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;
  109590. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109591. */
  109592. cameraColorCurves: Nullable<ColorCurves>;
  109593. /**
  109594. * Instantiates a new PBRMaterial instance.
  109595. *
  109596. * @param name The material name
  109597. * @param scene The scene the material will be use in.
  109598. */
  109599. constructor(name: string, scene: Scene);
  109600. /**
  109601. * Returns the name of this material class.
  109602. */
  109603. getClassName(): string;
  109604. /**
  109605. * Makes a duplicate of the current material.
  109606. * @param name - name to use for the new material.
  109607. */
  109608. clone(name: string): PBRMaterial;
  109609. /**
  109610. * Serializes this PBR Material.
  109611. * @returns - An object with the serialized material.
  109612. */
  109613. serialize(): any;
  109614. /**
  109615. * Parses a PBR Material from a serialized object.
  109616. * @param source - Serialized object.
  109617. * @param scene - BJS scene instance.
  109618. * @param rootUrl - url for the scene object
  109619. * @returns - PBRMaterial
  109620. */
  109621. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  109622. }
  109623. }
  109624. declare module BABYLON {
  109625. /**
  109626. * Direct draw surface info
  109627. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  109628. */
  109629. export interface DDSInfo {
  109630. /**
  109631. * Width of the texture
  109632. */
  109633. width: number;
  109634. /**
  109635. * Width of the texture
  109636. */
  109637. height: number;
  109638. /**
  109639. * Number of Mipmaps for the texture
  109640. * @see https://en.wikipedia.org/wiki/Mipmap
  109641. */
  109642. mipmapCount: number;
  109643. /**
  109644. * If the textures format is a known fourCC format
  109645. * @see https://www.fourcc.org/
  109646. */
  109647. isFourCC: boolean;
  109648. /**
  109649. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  109650. */
  109651. isRGB: boolean;
  109652. /**
  109653. * If the texture is a lumincance format
  109654. */
  109655. isLuminance: boolean;
  109656. /**
  109657. * If this is a cube texture
  109658. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  109659. */
  109660. isCube: boolean;
  109661. /**
  109662. * If the texture is a compressed format eg. FOURCC_DXT1
  109663. */
  109664. isCompressed: boolean;
  109665. /**
  109666. * The dxgiFormat of the texture
  109667. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  109668. */
  109669. dxgiFormat: number;
  109670. /**
  109671. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  109672. */
  109673. textureType: number;
  109674. /**
  109675. * Sphericle polynomial created for the dds texture
  109676. */
  109677. sphericalPolynomial?: SphericalPolynomial;
  109678. }
  109679. /**
  109680. * Class used to provide DDS decompression tools
  109681. */
  109682. export class DDSTools {
  109683. /**
  109684. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  109685. */
  109686. static StoreLODInAlphaChannel: boolean;
  109687. /**
  109688. * Gets DDS information from an array buffer
  109689. * @param arrayBuffer defines the array buffer to read data from
  109690. * @returns the DDS information
  109691. */
  109692. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  109693. private static _FloatView;
  109694. private static _Int32View;
  109695. private static _ToHalfFloat;
  109696. private static _FromHalfFloat;
  109697. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  109698. private static _GetHalfFloatRGBAArrayBuffer;
  109699. private static _GetFloatRGBAArrayBuffer;
  109700. private static _GetFloatAsUIntRGBAArrayBuffer;
  109701. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  109702. private static _GetRGBAArrayBuffer;
  109703. private static _ExtractLongWordOrder;
  109704. private static _GetRGBArrayBuffer;
  109705. private static _GetLuminanceArrayBuffer;
  109706. /**
  109707. * Uploads DDS Levels to a Babylon Texture
  109708. * @hidden
  109709. */
  109710. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  109711. }
  109712. interface Engine {
  109713. /**
  109714. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  109715. * @param rootUrl defines the url where the file to load is located
  109716. * @param scene defines the current scene
  109717. * @param lodScale defines scale to apply to the mip map selection
  109718. * @param lodOffset defines offset to apply to the mip map selection
  109719. * @param onLoad defines an optional callback raised when the texture is loaded
  109720. * @param onError defines an optional callback raised if there is an issue to load the texture
  109721. * @param format defines the format of the data
  109722. * @param forcedExtension defines the extension to use to pick the right loader
  109723. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  109724. * @returns the cube texture as an InternalTexture
  109725. */
  109726. 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;
  109727. }
  109728. }
  109729. declare module BABYLON {
  109730. /**
  109731. * Implementation of the DDS Texture Loader.
  109732. * @hidden
  109733. */
  109734. export class _DDSTextureLoader implements IInternalTextureLoader {
  109735. /**
  109736. * Defines wether the loader supports cascade loading the different faces.
  109737. */
  109738. readonly supportCascades: boolean;
  109739. /**
  109740. * This returns if the loader support the current file information.
  109741. * @param extension defines the file extension of the file being loaded
  109742. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109743. * @param fallback defines the fallback internal texture if any
  109744. * @param isBase64 defines whether the texture is encoded as a base64
  109745. * @param isBuffer defines whether the texture data are stored as a buffer
  109746. * @returns true if the loader can load the specified file
  109747. */
  109748. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109749. /**
  109750. * Transform the url before loading if required.
  109751. * @param rootUrl the url of the texture
  109752. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109753. * @returns the transformed texture
  109754. */
  109755. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109756. /**
  109757. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109758. * @param rootUrl the url of the texture
  109759. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109760. * @returns the fallback texture
  109761. */
  109762. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109763. /**
  109764. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109765. * @param data contains the texture data
  109766. * @param texture defines the BabylonJS internal texture
  109767. * @param createPolynomials will be true if polynomials have been requested
  109768. * @param onLoad defines the callback to trigger once the texture is ready
  109769. * @param onError defines the callback to trigger in case of error
  109770. */
  109771. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109772. /**
  109773. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109774. * @param data contains the texture data
  109775. * @param texture defines the BabylonJS internal texture
  109776. * @param callback defines the method to call once ready to upload
  109777. */
  109778. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109779. }
  109780. }
  109781. declare module BABYLON {
  109782. /** @hidden */
  109783. export var rgbdEncodePixelShader: {
  109784. name: string;
  109785. shader: string;
  109786. };
  109787. }
  109788. declare module BABYLON {
  109789. /**
  109790. * Raw texture data and descriptor sufficient for WebGL texture upload
  109791. */
  109792. export interface EnvironmentTextureInfo {
  109793. /**
  109794. * Version of the environment map
  109795. */
  109796. version: number;
  109797. /**
  109798. * Width of image
  109799. */
  109800. width: number;
  109801. /**
  109802. * Irradiance information stored in the file.
  109803. */
  109804. irradiance: any;
  109805. /**
  109806. * Specular information stored in the file.
  109807. */
  109808. specular: any;
  109809. }
  109810. /**
  109811. * Sets of helpers addressing the serialization and deserialization of environment texture
  109812. * stored in a BabylonJS env file.
  109813. * Those files are usually stored as .env files.
  109814. */
  109815. export class EnvironmentTextureTools {
  109816. /**
  109817. * Magic number identifying the env file.
  109818. */
  109819. private static _MagicBytes;
  109820. /**
  109821. * Gets the environment info from an env file.
  109822. * @param data The array buffer containing the .env bytes.
  109823. * @returns the environment file info (the json header) if successfully parsed.
  109824. */
  109825. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109826. /**
  109827. * Creates an environment texture from a loaded cube texture.
  109828. * @param texture defines the cube texture to convert in env file
  109829. * @return a promise containing the environment data if succesfull.
  109830. */
  109831. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109832. /**
  109833. * Creates a JSON representation of the spherical data.
  109834. * @param texture defines the texture containing the polynomials
  109835. * @return the JSON representation of the spherical info
  109836. */
  109837. private static _CreateEnvTextureIrradiance;
  109838. /**
  109839. * Uploads the texture info contained in the env file to the GPU.
  109840. * @param texture defines the internal texture to upload to
  109841. * @param arrayBuffer defines the buffer cotaining the data to load
  109842. * @param info defines the texture info retrieved through the GetEnvInfo method
  109843. * @returns a promise
  109844. */
  109845. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109846. /**
  109847. * Uploads the levels of image data to the GPU.
  109848. * @param texture defines the internal texture to upload to
  109849. * @param imageData defines the array buffer views of image data [mipmap][face]
  109850. * @returns a promise
  109851. */
  109852. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109853. /**
  109854. * Uploads spherical polynomials information to the texture.
  109855. * @param texture defines the texture we are trying to upload the information to
  109856. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109857. */
  109858. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109859. /** @hidden */
  109860. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109861. }
  109862. }
  109863. declare module BABYLON {
  109864. /**
  109865. * Implementation of the ENV Texture Loader.
  109866. * @hidden
  109867. */
  109868. export class _ENVTextureLoader implements IInternalTextureLoader {
  109869. /**
  109870. * Defines wether the loader supports cascade loading the different faces.
  109871. */
  109872. readonly supportCascades: boolean;
  109873. /**
  109874. * This returns if the loader support the current file information.
  109875. * @param extension defines the file extension of the file being loaded
  109876. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109877. * @param fallback defines the fallback internal texture if any
  109878. * @param isBase64 defines whether the texture is encoded as a base64
  109879. * @param isBuffer defines whether the texture data are stored as a buffer
  109880. * @returns true if the loader can load the specified file
  109881. */
  109882. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109883. /**
  109884. * Transform the url before loading if required.
  109885. * @param rootUrl the url of the texture
  109886. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109887. * @returns the transformed texture
  109888. */
  109889. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109890. /**
  109891. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109892. * @param rootUrl the url of the texture
  109893. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109894. * @returns the fallback texture
  109895. */
  109896. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109897. /**
  109898. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109899. * @param data contains the texture data
  109900. * @param texture defines the BabylonJS internal texture
  109901. * @param createPolynomials will be true if polynomials have been requested
  109902. * @param onLoad defines the callback to trigger once the texture is ready
  109903. * @param onError defines the callback to trigger in case of error
  109904. */
  109905. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109906. /**
  109907. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109908. * @param data contains the texture data
  109909. * @param texture defines the BabylonJS internal texture
  109910. * @param callback defines the method to call once ready to upload
  109911. */
  109912. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109913. }
  109914. }
  109915. declare module BABYLON {
  109916. /**
  109917. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109918. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109919. */
  109920. export class KhronosTextureContainer {
  109921. /** contents of the KTX container file */
  109922. arrayBuffer: any;
  109923. private static HEADER_LEN;
  109924. private static COMPRESSED_2D;
  109925. private static COMPRESSED_3D;
  109926. private static TEX_2D;
  109927. private static TEX_3D;
  109928. /**
  109929. * Gets the openGL type
  109930. */
  109931. glType: number;
  109932. /**
  109933. * Gets the openGL type size
  109934. */
  109935. glTypeSize: number;
  109936. /**
  109937. * Gets the openGL format
  109938. */
  109939. glFormat: number;
  109940. /**
  109941. * Gets the openGL internal format
  109942. */
  109943. glInternalFormat: number;
  109944. /**
  109945. * Gets the base internal format
  109946. */
  109947. glBaseInternalFormat: number;
  109948. /**
  109949. * Gets image width in pixel
  109950. */
  109951. pixelWidth: number;
  109952. /**
  109953. * Gets image height in pixel
  109954. */
  109955. pixelHeight: number;
  109956. /**
  109957. * Gets image depth in pixels
  109958. */
  109959. pixelDepth: number;
  109960. /**
  109961. * Gets the number of array elements
  109962. */
  109963. numberOfArrayElements: number;
  109964. /**
  109965. * Gets the number of faces
  109966. */
  109967. numberOfFaces: number;
  109968. /**
  109969. * Gets the number of mipmap levels
  109970. */
  109971. numberOfMipmapLevels: number;
  109972. /**
  109973. * Gets the bytes of key value data
  109974. */
  109975. bytesOfKeyValueData: number;
  109976. /**
  109977. * Gets the load type
  109978. */
  109979. loadType: number;
  109980. /**
  109981. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109982. */
  109983. isInvalid: boolean;
  109984. /**
  109985. * Creates a new KhronosTextureContainer
  109986. * @param arrayBuffer contents of the KTX container file
  109987. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109988. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109989. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109990. */
  109991. constructor(
  109992. /** contents of the KTX container file */
  109993. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109994. /**
  109995. * Uploads KTX content to a Babylon Texture.
  109996. * It is assumed that the texture has already been created & is currently bound
  109997. * @hidden
  109998. */
  109999. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  110000. private _upload2DCompressedLevels;
  110001. }
  110002. }
  110003. declare module BABYLON {
  110004. /**
  110005. * Implementation of the KTX Texture Loader.
  110006. * @hidden
  110007. */
  110008. export class _KTXTextureLoader implements IInternalTextureLoader {
  110009. /**
  110010. * Defines wether the loader supports cascade loading the different faces.
  110011. */
  110012. readonly supportCascades: boolean;
  110013. /**
  110014. * This returns if the loader support the current file information.
  110015. * @param extension defines the file extension of the file being loaded
  110016. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110017. * @param fallback defines the fallback internal texture if any
  110018. * @param isBase64 defines whether the texture is encoded as a base64
  110019. * @param isBuffer defines whether the texture data are stored as a buffer
  110020. * @returns true if the loader can load the specified file
  110021. */
  110022. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  110023. /**
  110024. * Transform the url before loading if required.
  110025. * @param rootUrl the url of the texture
  110026. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110027. * @returns the transformed texture
  110028. */
  110029. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  110030. /**
  110031. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  110032. * @param rootUrl the url of the texture
  110033. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110034. * @returns the fallback texture
  110035. */
  110036. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  110037. /**
  110038. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  110039. * @param data contains the texture data
  110040. * @param texture defines the BabylonJS internal texture
  110041. * @param createPolynomials will be true if polynomials have been requested
  110042. * @param onLoad defines the callback to trigger once the texture is ready
  110043. * @param onError defines the callback to trigger in case of error
  110044. */
  110045. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  110046. /**
  110047. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  110048. * @param data contains the texture data
  110049. * @param texture defines the BabylonJS internal texture
  110050. * @param callback defines the method to call once ready to upload
  110051. */
  110052. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  110053. }
  110054. }
  110055. declare module BABYLON {
  110056. /** @hidden */
  110057. export var _forceSceneHelpersToBundle: boolean;
  110058. interface Scene {
  110059. /**
  110060. * Creates a default light for the scene.
  110061. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  110062. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  110063. */
  110064. createDefaultLight(replace?: boolean): void;
  110065. /**
  110066. * Creates a default camera for the scene.
  110067. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  110068. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  110069. * @param replace has default false, when true replaces the active camera in the scene
  110070. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  110071. */
  110072. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  110073. /**
  110074. * Creates a default camera and a default light.
  110075. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  110076. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  110077. * @param replace has the default false, when true replaces the active camera/light in the scene
  110078. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  110079. */
  110080. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  110081. /**
  110082. * Creates a new sky box
  110083. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  110084. * @param environmentTexture defines the texture to use as environment texture
  110085. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  110086. * @param scale defines the overall scale of the skybox
  110087. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  110088. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  110089. * @returns a new mesh holding the sky box
  110090. */
  110091. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  110092. /**
  110093. * Creates a new environment
  110094. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  110095. * @param options defines the options you can use to configure the environment
  110096. * @returns the new EnvironmentHelper
  110097. */
  110098. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  110099. /**
  110100. * Creates a new VREXperienceHelper
  110101. * @see http://doc.babylonjs.com/how_to/webvr_helper
  110102. * @param webVROptions defines the options used to create the new VREXperienceHelper
  110103. * @returns a new VREXperienceHelper
  110104. */
  110105. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  110106. /**
  110107. * Creates a new XREXperienceHelper
  110108. * @see http://doc.babylonjs.com/how_to/webxr
  110109. * @returns a promise for a new XREXperienceHelper
  110110. */
  110111. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  110112. }
  110113. }
  110114. declare module BABYLON {
  110115. /**
  110116. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  110117. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  110118. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  110119. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  110120. */
  110121. export class VideoDome extends TransformNode {
  110122. /**
  110123. * Define the video source as a Monoscopic panoramic 360 video.
  110124. */
  110125. static readonly MODE_MONOSCOPIC: number;
  110126. /**
  110127. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  110128. */
  110129. static readonly MODE_TOPBOTTOM: number;
  110130. /**
  110131. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  110132. */
  110133. static readonly MODE_SIDEBYSIDE: number;
  110134. private _useDirectMapping;
  110135. /**
  110136. * The video texture being displayed on the sphere
  110137. */
  110138. protected _videoTexture: VideoTexture;
  110139. /**
  110140. * Gets the video texture being displayed on the sphere
  110141. */
  110142. readonly videoTexture: VideoTexture;
  110143. /**
  110144. * The skybox material
  110145. */
  110146. protected _material: BackgroundMaterial;
  110147. /**
  110148. * The surface used for the skybox
  110149. */
  110150. protected _mesh: Mesh;
  110151. /**
  110152. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  110153. * Also see the options.resolution property.
  110154. */
  110155. fovMultiplier: number;
  110156. private _videoMode;
  110157. /**
  110158. * Gets or set the current video mode for the video. It can be:
  110159. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  110160. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  110161. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  110162. */
  110163. videoMode: number;
  110164. /**
  110165. * Oberserver used in Stereoscopic VR Mode.
  110166. */
  110167. private _onBeforeCameraRenderObserver;
  110168. /**
  110169. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  110170. * @param name Element's name, child elements will append suffixes for their own names.
  110171. * @param urlsOrVideo defines the url(s) or the video element to use
  110172. * @param options An object containing optional or exposed sub element properties
  110173. */
  110174. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  110175. resolution?: number;
  110176. clickToPlay?: boolean;
  110177. autoPlay?: boolean;
  110178. loop?: boolean;
  110179. size?: number;
  110180. poster?: string;
  110181. faceForward?: boolean;
  110182. useDirectMapping?: boolean;
  110183. }, scene: Scene);
  110184. private _changeVideoMode;
  110185. /**
  110186. * Releases resources associated with this node.
  110187. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110188. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110189. */
  110190. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110191. }
  110192. }
  110193. declare module BABYLON {
  110194. /**
  110195. * This class can be used to get instrumentation data from a Babylon engine
  110196. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110197. */
  110198. export class EngineInstrumentation implements IDisposable {
  110199. /**
  110200. * Define the instrumented engine.
  110201. */
  110202. engine: Engine;
  110203. private _captureGPUFrameTime;
  110204. private _gpuFrameTimeToken;
  110205. private _gpuFrameTime;
  110206. private _captureShaderCompilationTime;
  110207. private _shaderCompilationTime;
  110208. private _onBeginFrameObserver;
  110209. private _onEndFrameObserver;
  110210. private _onBeforeShaderCompilationObserver;
  110211. private _onAfterShaderCompilationObserver;
  110212. /**
  110213. * Gets the perf counter used for GPU frame time
  110214. */
  110215. readonly gpuFrameTimeCounter: PerfCounter;
  110216. /**
  110217. * Gets the GPU frame time capture status
  110218. */
  110219. /**
  110220. * Enable or disable the GPU frame time capture
  110221. */
  110222. captureGPUFrameTime: boolean;
  110223. /**
  110224. * Gets the perf counter used for shader compilation time
  110225. */
  110226. readonly shaderCompilationTimeCounter: PerfCounter;
  110227. /**
  110228. * Gets the shader compilation time capture status
  110229. */
  110230. /**
  110231. * Enable or disable the shader compilation time capture
  110232. */
  110233. captureShaderCompilationTime: boolean;
  110234. /**
  110235. * Instantiates a new engine instrumentation.
  110236. * This class can be used to get instrumentation data from a Babylon engine
  110237. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110238. * @param engine Defines the engine to instrument
  110239. */
  110240. constructor(
  110241. /**
  110242. * Define the instrumented engine.
  110243. */
  110244. engine: Engine);
  110245. /**
  110246. * Dispose and release associated resources.
  110247. */
  110248. dispose(): void;
  110249. }
  110250. }
  110251. declare module BABYLON {
  110252. /**
  110253. * This class can be used to get instrumentation data from a Babylon engine
  110254. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110255. */
  110256. export class SceneInstrumentation implements IDisposable {
  110257. /**
  110258. * Defines the scene to instrument
  110259. */
  110260. scene: Scene;
  110261. private _captureActiveMeshesEvaluationTime;
  110262. private _activeMeshesEvaluationTime;
  110263. private _captureRenderTargetsRenderTime;
  110264. private _renderTargetsRenderTime;
  110265. private _captureFrameTime;
  110266. private _frameTime;
  110267. private _captureRenderTime;
  110268. private _renderTime;
  110269. private _captureInterFrameTime;
  110270. private _interFrameTime;
  110271. private _captureParticlesRenderTime;
  110272. private _particlesRenderTime;
  110273. private _captureSpritesRenderTime;
  110274. private _spritesRenderTime;
  110275. private _capturePhysicsTime;
  110276. private _physicsTime;
  110277. private _captureAnimationsTime;
  110278. private _animationsTime;
  110279. private _captureCameraRenderTime;
  110280. private _cameraRenderTime;
  110281. private _onBeforeActiveMeshesEvaluationObserver;
  110282. private _onAfterActiveMeshesEvaluationObserver;
  110283. private _onBeforeRenderTargetsRenderObserver;
  110284. private _onAfterRenderTargetsRenderObserver;
  110285. private _onAfterRenderObserver;
  110286. private _onBeforeDrawPhaseObserver;
  110287. private _onAfterDrawPhaseObserver;
  110288. private _onBeforeAnimationsObserver;
  110289. private _onBeforeParticlesRenderingObserver;
  110290. private _onAfterParticlesRenderingObserver;
  110291. private _onBeforeSpritesRenderingObserver;
  110292. private _onAfterSpritesRenderingObserver;
  110293. private _onBeforePhysicsObserver;
  110294. private _onAfterPhysicsObserver;
  110295. private _onAfterAnimationsObserver;
  110296. private _onBeforeCameraRenderObserver;
  110297. private _onAfterCameraRenderObserver;
  110298. /**
  110299. * Gets the perf counter used for active meshes evaluation time
  110300. */
  110301. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  110302. /**
  110303. * Gets the active meshes evaluation time capture status
  110304. */
  110305. /**
  110306. * Enable or disable the active meshes evaluation time capture
  110307. */
  110308. captureActiveMeshesEvaluationTime: boolean;
  110309. /**
  110310. * Gets the perf counter used for render targets render time
  110311. */
  110312. readonly renderTargetsRenderTimeCounter: PerfCounter;
  110313. /**
  110314. * Gets the render targets render time capture status
  110315. */
  110316. /**
  110317. * Enable or disable the render targets render time capture
  110318. */
  110319. captureRenderTargetsRenderTime: boolean;
  110320. /**
  110321. * Gets the perf counter used for particles render time
  110322. */
  110323. readonly particlesRenderTimeCounter: PerfCounter;
  110324. /**
  110325. * Gets the particles render time capture status
  110326. */
  110327. /**
  110328. * Enable or disable the particles render time capture
  110329. */
  110330. captureParticlesRenderTime: boolean;
  110331. /**
  110332. * Gets the perf counter used for sprites render time
  110333. */
  110334. readonly spritesRenderTimeCounter: PerfCounter;
  110335. /**
  110336. * Gets the sprites render time capture status
  110337. */
  110338. /**
  110339. * Enable or disable the sprites render time capture
  110340. */
  110341. captureSpritesRenderTime: boolean;
  110342. /**
  110343. * Gets the perf counter used for physics time
  110344. */
  110345. readonly physicsTimeCounter: PerfCounter;
  110346. /**
  110347. * Gets the physics time capture status
  110348. */
  110349. /**
  110350. * Enable or disable the physics time capture
  110351. */
  110352. capturePhysicsTime: boolean;
  110353. /**
  110354. * Gets the perf counter used for animations time
  110355. */
  110356. readonly animationsTimeCounter: PerfCounter;
  110357. /**
  110358. * Gets the animations time capture status
  110359. */
  110360. /**
  110361. * Enable or disable the animations time capture
  110362. */
  110363. captureAnimationsTime: boolean;
  110364. /**
  110365. * Gets the perf counter used for frame time capture
  110366. */
  110367. readonly frameTimeCounter: PerfCounter;
  110368. /**
  110369. * Gets the frame time capture status
  110370. */
  110371. /**
  110372. * Enable or disable the frame time capture
  110373. */
  110374. captureFrameTime: boolean;
  110375. /**
  110376. * Gets the perf counter used for inter-frames time capture
  110377. */
  110378. readonly interFrameTimeCounter: PerfCounter;
  110379. /**
  110380. * Gets the inter-frames time capture status
  110381. */
  110382. /**
  110383. * Enable or disable the inter-frames time capture
  110384. */
  110385. captureInterFrameTime: boolean;
  110386. /**
  110387. * Gets the perf counter used for render time capture
  110388. */
  110389. readonly renderTimeCounter: PerfCounter;
  110390. /**
  110391. * Gets the render time capture status
  110392. */
  110393. /**
  110394. * Enable or disable the render time capture
  110395. */
  110396. captureRenderTime: boolean;
  110397. /**
  110398. * Gets the perf counter used for camera render time capture
  110399. */
  110400. readonly cameraRenderTimeCounter: PerfCounter;
  110401. /**
  110402. * Gets the camera render time capture status
  110403. */
  110404. /**
  110405. * Enable or disable the camera render time capture
  110406. */
  110407. captureCameraRenderTime: boolean;
  110408. /**
  110409. * Gets the perf counter used for draw calls
  110410. */
  110411. readonly drawCallsCounter: PerfCounter;
  110412. /**
  110413. * Instantiates a new scene instrumentation.
  110414. * This class can be used to get instrumentation data from a Babylon engine
  110415. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110416. * @param scene Defines the scene to instrument
  110417. */
  110418. constructor(
  110419. /**
  110420. * Defines the scene to instrument
  110421. */
  110422. scene: Scene);
  110423. /**
  110424. * Dispose and release associated resources.
  110425. */
  110426. dispose(): void;
  110427. }
  110428. }
  110429. declare module BABYLON {
  110430. /** @hidden */
  110431. export var glowMapGenerationPixelShader: {
  110432. name: string;
  110433. shader: string;
  110434. };
  110435. }
  110436. declare module BABYLON {
  110437. /** @hidden */
  110438. export var glowMapGenerationVertexShader: {
  110439. name: string;
  110440. shader: string;
  110441. };
  110442. }
  110443. declare module BABYLON {
  110444. /**
  110445. * Effect layer options. This helps customizing the behaviour
  110446. * of the effect layer.
  110447. */
  110448. export interface IEffectLayerOptions {
  110449. /**
  110450. * Multiplication factor apply to the canvas size to compute the render target size
  110451. * used to generated the objects (the smaller the faster).
  110452. */
  110453. mainTextureRatio: number;
  110454. /**
  110455. * Enforces a fixed size texture to ensure effect stability across devices.
  110456. */
  110457. mainTextureFixedSize?: number;
  110458. /**
  110459. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  110460. */
  110461. alphaBlendingMode: number;
  110462. /**
  110463. * The camera attached to the layer.
  110464. */
  110465. camera: Nullable<Camera>;
  110466. /**
  110467. * The rendering group to draw the layer in.
  110468. */
  110469. renderingGroupId: number;
  110470. }
  110471. /**
  110472. * The effect layer Helps adding post process effect blended with the main pass.
  110473. *
  110474. * This can be for instance use to generate glow or higlight effects on the scene.
  110475. *
  110476. * The effect layer class can not be used directly and is intented to inherited from to be
  110477. * customized per effects.
  110478. */
  110479. export abstract class EffectLayer {
  110480. private _vertexBuffers;
  110481. private _indexBuffer;
  110482. private _cachedDefines;
  110483. private _effectLayerMapGenerationEffect;
  110484. private _effectLayerOptions;
  110485. private _mergeEffect;
  110486. protected _scene: Scene;
  110487. protected _engine: Engine;
  110488. protected _maxSize: number;
  110489. protected _mainTextureDesiredSize: ISize;
  110490. protected _mainTexture: RenderTargetTexture;
  110491. protected _shouldRender: boolean;
  110492. protected _postProcesses: PostProcess[];
  110493. protected _textures: BaseTexture[];
  110494. protected _emissiveTextureAndColor: {
  110495. texture: Nullable<BaseTexture>;
  110496. color: Color4;
  110497. };
  110498. /**
  110499. * The name of the layer
  110500. */
  110501. name: string;
  110502. /**
  110503. * The clear color of the texture used to generate the glow map.
  110504. */
  110505. neutralColor: Color4;
  110506. /**
  110507. * Specifies wether the highlight layer is enabled or not.
  110508. */
  110509. isEnabled: boolean;
  110510. /**
  110511. * Gets the camera attached to the layer.
  110512. */
  110513. readonly camera: Nullable<Camera>;
  110514. /**
  110515. * Gets the rendering group id the layer should render in.
  110516. */
  110517. renderingGroupId: number;
  110518. /**
  110519. * An event triggered when the effect layer has been disposed.
  110520. */
  110521. onDisposeObservable: Observable<EffectLayer>;
  110522. /**
  110523. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  110524. */
  110525. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  110526. /**
  110527. * An event triggered when the generated texture is being merged in the scene.
  110528. */
  110529. onBeforeComposeObservable: Observable<EffectLayer>;
  110530. /**
  110531. * An event triggered when the generated texture has been merged in the scene.
  110532. */
  110533. onAfterComposeObservable: Observable<EffectLayer>;
  110534. /**
  110535. * An event triggered when the efffect layer changes its size.
  110536. */
  110537. onSizeChangedObservable: Observable<EffectLayer>;
  110538. /** @hidden */
  110539. static _SceneComponentInitialization: (scene: Scene) => void;
  110540. /**
  110541. * Instantiates a new effect Layer and references it in the scene.
  110542. * @param name The name of the layer
  110543. * @param scene The scene to use the layer in
  110544. */
  110545. constructor(
  110546. /** The Friendly of the effect in the scene */
  110547. name: string, scene: Scene);
  110548. /**
  110549. * Get the effect name of the layer.
  110550. * @return The effect name
  110551. */
  110552. abstract getEffectName(): string;
  110553. /**
  110554. * Checks for the readiness of the element composing the layer.
  110555. * @param subMesh the mesh to check for
  110556. * @param useInstances specify wether or not to use instances to render the mesh
  110557. * @return true if ready otherwise, false
  110558. */
  110559. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110560. /**
  110561. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110562. * @returns true if the effect requires stencil during the main canvas render pass.
  110563. */
  110564. abstract needStencil(): boolean;
  110565. /**
  110566. * Create the merge effect. This is the shader use to blit the information back
  110567. * to the main canvas at the end of the scene rendering.
  110568. * @returns The effect containing the shader used to merge the effect on the main canvas
  110569. */
  110570. protected abstract _createMergeEffect(): Effect;
  110571. /**
  110572. * Creates the render target textures and post processes used in the effect layer.
  110573. */
  110574. protected abstract _createTextureAndPostProcesses(): void;
  110575. /**
  110576. * Implementation specific of rendering the generating effect on the main canvas.
  110577. * @param effect The effect used to render through
  110578. */
  110579. protected abstract _internalRender(effect: Effect): void;
  110580. /**
  110581. * Sets the required values for both the emissive texture and and the main color.
  110582. */
  110583. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110584. /**
  110585. * Free any resources and references associated to a mesh.
  110586. * Internal use
  110587. * @param mesh The mesh to free.
  110588. */
  110589. abstract _disposeMesh(mesh: Mesh): void;
  110590. /**
  110591. * Serializes this layer (Glow or Highlight for example)
  110592. * @returns a serialized layer object
  110593. */
  110594. abstract serialize?(): any;
  110595. /**
  110596. * Initializes the effect layer with the required options.
  110597. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  110598. */
  110599. protected _init(options: Partial<IEffectLayerOptions>): void;
  110600. /**
  110601. * Generates the index buffer of the full screen quad blending to the main canvas.
  110602. */
  110603. private _generateIndexBuffer;
  110604. /**
  110605. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  110606. */
  110607. private _generateVertexBuffer;
  110608. /**
  110609. * Sets the main texture desired size which is the closest power of two
  110610. * of the engine canvas size.
  110611. */
  110612. private _setMainTextureSize;
  110613. /**
  110614. * Creates the main texture for the effect layer.
  110615. */
  110616. protected _createMainTexture(): void;
  110617. /**
  110618. * Adds specific effects defines.
  110619. * @param defines The defines to add specifics to.
  110620. */
  110621. protected _addCustomEffectDefines(defines: string[]): void;
  110622. /**
  110623. * Checks for the readiness of the element composing the layer.
  110624. * @param subMesh the mesh to check for
  110625. * @param useInstances specify wether or not to use instances to render the mesh
  110626. * @param emissiveTexture the associated emissive texture used to generate the glow
  110627. * @return true if ready otherwise, false
  110628. */
  110629. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  110630. /**
  110631. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  110632. */
  110633. render(): void;
  110634. /**
  110635. * Determine if a given mesh will be used in the current effect.
  110636. * @param mesh mesh to test
  110637. * @returns true if the mesh will be used
  110638. */
  110639. hasMesh(mesh: AbstractMesh): boolean;
  110640. /**
  110641. * Returns true if the layer contains information to display, otherwise false.
  110642. * @returns true if the glow layer should be rendered
  110643. */
  110644. shouldRender(): boolean;
  110645. /**
  110646. * Returns true if the mesh should render, otherwise false.
  110647. * @param mesh The mesh to render
  110648. * @returns true if it should render otherwise false
  110649. */
  110650. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  110651. /**
  110652. * Returns true if the mesh can be rendered, otherwise false.
  110653. * @param mesh The mesh to render
  110654. * @param material The material used on the mesh
  110655. * @returns true if it can be rendered otherwise false
  110656. */
  110657. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110658. /**
  110659. * Returns true if the mesh should render, otherwise false.
  110660. * @param mesh The mesh to render
  110661. * @returns true if it should render otherwise false
  110662. */
  110663. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  110664. /**
  110665. * Renders the submesh passed in parameter to the generation map.
  110666. */
  110667. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  110668. /**
  110669. * Rebuild the required buffers.
  110670. * @hidden Internal use only.
  110671. */
  110672. _rebuild(): void;
  110673. /**
  110674. * Dispose only the render target textures and post process.
  110675. */
  110676. private _disposeTextureAndPostProcesses;
  110677. /**
  110678. * Dispose the highlight layer and free resources.
  110679. */
  110680. dispose(): void;
  110681. /**
  110682. * Gets the class name of the effect layer
  110683. * @returns the string with the class name of the effect layer
  110684. */
  110685. getClassName(): string;
  110686. /**
  110687. * Creates an effect layer from parsed effect layer data
  110688. * @param parsedEffectLayer defines effect layer data
  110689. * @param scene defines the current scene
  110690. * @param rootUrl defines the root URL containing the effect layer information
  110691. * @returns a parsed effect Layer
  110692. */
  110693. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  110694. }
  110695. }
  110696. declare module BABYLON {
  110697. interface AbstractScene {
  110698. /**
  110699. * The list of effect layers (highlights/glow) added to the scene
  110700. * @see http://doc.babylonjs.com/how_to/highlight_layer
  110701. * @see http://doc.babylonjs.com/how_to/glow_layer
  110702. */
  110703. effectLayers: Array<EffectLayer>;
  110704. /**
  110705. * Removes the given effect layer from this scene.
  110706. * @param toRemove defines the effect layer to remove
  110707. * @returns the index of the removed effect layer
  110708. */
  110709. removeEffectLayer(toRemove: EffectLayer): number;
  110710. /**
  110711. * Adds the given effect layer to this scene
  110712. * @param newEffectLayer defines the effect layer to add
  110713. */
  110714. addEffectLayer(newEffectLayer: EffectLayer): void;
  110715. }
  110716. /**
  110717. * Defines the layer scene component responsible to manage any effect layers
  110718. * in a given scene.
  110719. */
  110720. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  110721. /**
  110722. * The component name helpfull to identify the component in the list of scene components.
  110723. */
  110724. readonly name: string;
  110725. /**
  110726. * The scene the component belongs to.
  110727. */
  110728. scene: Scene;
  110729. private _engine;
  110730. private _renderEffects;
  110731. private _needStencil;
  110732. private _previousStencilState;
  110733. /**
  110734. * Creates a new instance of the component for the given scene
  110735. * @param scene Defines the scene to register the component in
  110736. */
  110737. constructor(scene: Scene);
  110738. /**
  110739. * Registers the component in a given scene
  110740. */
  110741. register(): void;
  110742. /**
  110743. * Rebuilds the elements related to this component in case of
  110744. * context lost for instance.
  110745. */
  110746. rebuild(): void;
  110747. /**
  110748. * Serializes the component data to the specified json object
  110749. * @param serializationObject The object to serialize to
  110750. */
  110751. serialize(serializationObject: any): void;
  110752. /**
  110753. * Adds all the elements from the container to the scene
  110754. * @param container the container holding the elements
  110755. */
  110756. addFromContainer(container: AbstractScene): void;
  110757. /**
  110758. * Removes all the elements in the container from the scene
  110759. * @param container contains the elements to remove
  110760. * @param dispose if the removed element should be disposed (default: false)
  110761. */
  110762. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110763. /**
  110764. * Disposes the component and the associated ressources.
  110765. */
  110766. dispose(): void;
  110767. private _isReadyForMesh;
  110768. private _renderMainTexture;
  110769. private _setStencil;
  110770. private _setStencilBack;
  110771. private _draw;
  110772. private _drawCamera;
  110773. private _drawRenderingGroup;
  110774. }
  110775. }
  110776. declare module BABYLON {
  110777. /** @hidden */
  110778. export var glowMapMergePixelShader: {
  110779. name: string;
  110780. shader: string;
  110781. };
  110782. }
  110783. declare module BABYLON {
  110784. /** @hidden */
  110785. export var glowMapMergeVertexShader: {
  110786. name: string;
  110787. shader: string;
  110788. };
  110789. }
  110790. declare module BABYLON {
  110791. interface AbstractScene {
  110792. /**
  110793. * Return a the first highlight layer of the scene with a given name.
  110794. * @param name The name of the highlight layer to look for.
  110795. * @return The highlight layer if found otherwise null.
  110796. */
  110797. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  110798. }
  110799. /**
  110800. * Glow layer options. This helps customizing the behaviour
  110801. * of the glow layer.
  110802. */
  110803. export interface IGlowLayerOptions {
  110804. /**
  110805. * Multiplication factor apply to the canvas size to compute the render target size
  110806. * used to generated the glowing objects (the smaller the faster).
  110807. */
  110808. mainTextureRatio: number;
  110809. /**
  110810. * Enforces a fixed size texture to ensure resize independant blur.
  110811. */
  110812. mainTextureFixedSize?: number;
  110813. /**
  110814. * How big is the kernel of the blur texture.
  110815. */
  110816. blurKernelSize: number;
  110817. /**
  110818. * The camera attached to the layer.
  110819. */
  110820. camera: Nullable<Camera>;
  110821. /**
  110822. * Enable MSAA by chosing the number of samples.
  110823. */
  110824. mainTextureSamples?: number;
  110825. /**
  110826. * The rendering group to draw the layer in.
  110827. */
  110828. renderingGroupId: number;
  110829. }
  110830. /**
  110831. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  110832. *
  110833. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110834. * glowy meshes to your scene.
  110835. *
  110836. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  110837. */
  110838. export class GlowLayer extends EffectLayer {
  110839. /**
  110840. * Effect Name of the layer.
  110841. */
  110842. static readonly EffectName: string;
  110843. /**
  110844. * The default blur kernel size used for the glow.
  110845. */
  110846. static DefaultBlurKernelSize: number;
  110847. /**
  110848. * The default texture size ratio used for the glow.
  110849. */
  110850. static DefaultTextureRatio: number;
  110851. /**
  110852. * Sets the kernel size of the blur.
  110853. */
  110854. /**
  110855. * Gets the kernel size of the blur.
  110856. */
  110857. blurKernelSize: number;
  110858. /**
  110859. * Sets the glow intensity.
  110860. */
  110861. /**
  110862. * Gets the glow intensity.
  110863. */
  110864. intensity: number;
  110865. private _options;
  110866. private _intensity;
  110867. private _horizontalBlurPostprocess1;
  110868. private _verticalBlurPostprocess1;
  110869. private _horizontalBlurPostprocess2;
  110870. private _verticalBlurPostprocess2;
  110871. private _blurTexture1;
  110872. private _blurTexture2;
  110873. private _postProcesses1;
  110874. private _postProcesses2;
  110875. private _includedOnlyMeshes;
  110876. private _excludedMeshes;
  110877. /**
  110878. * Callback used to let the user override the color selection on a per mesh basis
  110879. */
  110880. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  110881. /**
  110882. * Callback used to let the user override the texture selection on a per mesh basis
  110883. */
  110884. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  110885. /**
  110886. * Instantiates a new glow Layer and references it to the scene.
  110887. * @param name The name of the layer
  110888. * @param scene The scene to use the layer in
  110889. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  110890. */
  110891. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  110892. /**
  110893. * Get the effect name of the layer.
  110894. * @return The effect name
  110895. */
  110896. getEffectName(): string;
  110897. /**
  110898. * Create the merge effect. This is the shader use to blit the information back
  110899. * to the main canvas at the end of the scene rendering.
  110900. */
  110901. protected _createMergeEffect(): Effect;
  110902. /**
  110903. * Creates the render target textures and post processes used in the glow layer.
  110904. */
  110905. protected _createTextureAndPostProcesses(): void;
  110906. /**
  110907. * Checks for the readiness of the element composing the layer.
  110908. * @param subMesh the mesh to check for
  110909. * @param useInstances specify wether or not to use instances to render the mesh
  110910. * @param emissiveTexture the associated emissive texture used to generate the glow
  110911. * @return true if ready otherwise, false
  110912. */
  110913. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110914. /**
  110915. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110916. */
  110917. needStencil(): boolean;
  110918. /**
  110919. * Returns true if the mesh can be rendered, otherwise false.
  110920. * @param mesh The mesh to render
  110921. * @param material The material used on the mesh
  110922. * @returns true if it can be rendered otherwise false
  110923. */
  110924. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110925. /**
  110926. * Implementation specific of rendering the generating effect on the main canvas.
  110927. * @param effect The effect used to render through
  110928. */
  110929. protected _internalRender(effect: Effect): void;
  110930. /**
  110931. * Sets the required values for both the emissive texture and and the main color.
  110932. */
  110933. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110934. /**
  110935. * Returns true if the mesh should render, otherwise false.
  110936. * @param mesh The mesh to render
  110937. * @returns true if it should render otherwise false
  110938. */
  110939. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110940. /**
  110941. * Adds specific effects defines.
  110942. * @param defines The defines to add specifics to.
  110943. */
  110944. protected _addCustomEffectDefines(defines: string[]): void;
  110945. /**
  110946. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110947. * @param mesh The mesh to exclude from the glow layer
  110948. */
  110949. addExcludedMesh(mesh: Mesh): void;
  110950. /**
  110951. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110952. * @param mesh The mesh to remove
  110953. */
  110954. removeExcludedMesh(mesh: Mesh): void;
  110955. /**
  110956. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110957. * @param mesh The mesh to include in the glow layer
  110958. */
  110959. addIncludedOnlyMesh(mesh: Mesh): void;
  110960. /**
  110961. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110962. * @param mesh The mesh to remove
  110963. */
  110964. removeIncludedOnlyMesh(mesh: Mesh): void;
  110965. /**
  110966. * Determine if a given mesh will be used in the glow layer
  110967. * @param mesh The mesh to test
  110968. * @returns true if the mesh will be highlighted by the current glow layer
  110969. */
  110970. hasMesh(mesh: AbstractMesh): boolean;
  110971. /**
  110972. * Free any resources and references associated to a mesh.
  110973. * Internal use
  110974. * @param mesh The mesh to free.
  110975. * @hidden
  110976. */
  110977. _disposeMesh(mesh: Mesh): void;
  110978. /**
  110979. * Gets the class name of the effect layer
  110980. * @returns the string with the class name of the effect layer
  110981. */
  110982. getClassName(): string;
  110983. /**
  110984. * Serializes this glow layer
  110985. * @returns a serialized glow layer object
  110986. */
  110987. serialize(): any;
  110988. /**
  110989. * Creates a Glow Layer from parsed glow layer data
  110990. * @param parsedGlowLayer defines glow layer data
  110991. * @param scene defines the current scene
  110992. * @param rootUrl defines the root URL containing the glow layer information
  110993. * @returns a parsed Glow Layer
  110994. */
  110995. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110996. }
  110997. }
  110998. declare module BABYLON {
  110999. /** @hidden */
  111000. export var glowBlurPostProcessPixelShader: {
  111001. name: string;
  111002. shader: string;
  111003. };
  111004. }
  111005. declare module BABYLON {
  111006. interface AbstractScene {
  111007. /**
  111008. * Return a the first highlight layer of the scene with a given name.
  111009. * @param name The name of the highlight layer to look for.
  111010. * @return The highlight layer if found otherwise null.
  111011. */
  111012. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  111013. }
  111014. /**
  111015. * Highlight layer options. This helps customizing the behaviour
  111016. * of the highlight layer.
  111017. */
  111018. export interface IHighlightLayerOptions {
  111019. /**
  111020. * Multiplication factor apply to the canvas size to compute the render target size
  111021. * used to generated the glowing objects (the smaller the faster).
  111022. */
  111023. mainTextureRatio: number;
  111024. /**
  111025. * Enforces a fixed size texture to ensure resize independant blur.
  111026. */
  111027. mainTextureFixedSize?: number;
  111028. /**
  111029. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  111030. * of the picture to blur (the smaller the faster).
  111031. */
  111032. blurTextureSizeRatio: number;
  111033. /**
  111034. * How big in texel of the blur texture is the vertical blur.
  111035. */
  111036. blurVerticalSize: number;
  111037. /**
  111038. * How big in texel of the blur texture is the horizontal blur.
  111039. */
  111040. blurHorizontalSize: number;
  111041. /**
  111042. * Alpha blending mode used to apply the blur. Default is combine.
  111043. */
  111044. alphaBlendingMode: number;
  111045. /**
  111046. * The camera attached to the layer.
  111047. */
  111048. camera: Nullable<Camera>;
  111049. /**
  111050. * Should we display highlight as a solid stroke?
  111051. */
  111052. isStroke?: boolean;
  111053. /**
  111054. * The rendering group to draw the layer in.
  111055. */
  111056. renderingGroupId: number;
  111057. }
  111058. /**
  111059. * The highlight layer Helps adding a glow effect around a mesh.
  111060. *
  111061. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  111062. * glowy meshes to your scene.
  111063. *
  111064. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  111065. */
  111066. export class HighlightLayer extends EffectLayer {
  111067. name: string;
  111068. /**
  111069. * Effect Name of the highlight layer.
  111070. */
  111071. static readonly EffectName: string;
  111072. /**
  111073. * The neutral color used during the preparation of the glow effect.
  111074. * This is black by default as the blend operation is a blend operation.
  111075. */
  111076. static NeutralColor: Color4;
  111077. /**
  111078. * Stencil value used for glowing meshes.
  111079. */
  111080. static GlowingMeshStencilReference: number;
  111081. /**
  111082. * Stencil value used for the other meshes in the scene.
  111083. */
  111084. static NormalMeshStencilReference: number;
  111085. /**
  111086. * Specifies whether or not the inner glow is ACTIVE in the layer.
  111087. */
  111088. innerGlow: boolean;
  111089. /**
  111090. * Specifies whether or not the outer glow is ACTIVE in the layer.
  111091. */
  111092. outerGlow: boolean;
  111093. /**
  111094. * Specifies the horizontal size of the blur.
  111095. */
  111096. /**
  111097. * Gets the horizontal size of the blur.
  111098. */
  111099. blurHorizontalSize: number;
  111100. /**
  111101. * Specifies the vertical size of the blur.
  111102. */
  111103. /**
  111104. * Gets the vertical size of the blur.
  111105. */
  111106. blurVerticalSize: number;
  111107. /**
  111108. * An event triggered when the highlight layer is being blurred.
  111109. */
  111110. onBeforeBlurObservable: Observable<HighlightLayer>;
  111111. /**
  111112. * An event triggered when the highlight layer has been blurred.
  111113. */
  111114. onAfterBlurObservable: Observable<HighlightLayer>;
  111115. private _instanceGlowingMeshStencilReference;
  111116. private _options;
  111117. private _downSamplePostprocess;
  111118. private _horizontalBlurPostprocess;
  111119. private _verticalBlurPostprocess;
  111120. private _blurTexture;
  111121. private _meshes;
  111122. private _excludedMeshes;
  111123. /**
  111124. * Instantiates a new highlight Layer and references it to the scene..
  111125. * @param name The name of the layer
  111126. * @param scene The scene to use the layer in
  111127. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  111128. */
  111129. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  111130. /**
  111131. * Get the effect name of the layer.
  111132. * @return The effect name
  111133. */
  111134. getEffectName(): string;
  111135. /**
  111136. * Create the merge effect. This is the shader use to blit the information back
  111137. * to the main canvas at the end of the scene rendering.
  111138. */
  111139. protected _createMergeEffect(): Effect;
  111140. /**
  111141. * Creates the render target textures and post processes used in the highlight layer.
  111142. */
  111143. protected _createTextureAndPostProcesses(): void;
  111144. /**
  111145. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  111146. */
  111147. needStencil(): boolean;
  111148. /**
  111149. * Checks for the readiness of the element composing the layer.
  111150. * @param subMesh the mesh to check for
  111151. * @param useInstances specify wether or not to use instances to render the mesh
  111152. * @param emissiveTexture the associated emissive texture used to generate the glow
  111153. * @return true if ready otherwise, false
  111154. */
  111155. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111156. /**
  111157. * Implementation specific of rendering the generating effect on the main canvas.
  111158. * @param effect The effect used to render through
  111159. */
  111160. protected _internalRender(effect: Effect): void;
  111161. /**
  111162. * Returns true if the layer contains information to display, otherwise false.
  111163. */
  111164. shouldRender(): boolean;
  111165. /**
  111166. * Returns true if the mesh should render, otherwise false.
  111167. * @param mesh The mesh to render
  111168. * @returns true if it should render otherwise false
  111169. */
  111170. protected _shouldRenderMesh(mesh: Mesh): boolean;
  111171. /**
  111172. * Sets the required values for both the emissive texture and and the main color.
  111173. */
  111174. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  111175. /**
  111176. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  111177. * @param mesh The mesh to exclude from the highlight layer
  111178. */
  111179. addExcludedMesh(mesh: Mesh): void;
  111180. /**
  111181. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  111182. * @param mesh The mesh to highlight
  111183. */
  111184. removeExcludedMesh(mesh: Mesh): void;
  111185. /**
  111186. * Determine if a given mesh will be highlighted by the current HighlightLayer
  111187. * @param mesh mesh to test
  111188. * @returns true if the mesh will be highlighted by the current HighlightLayer
  111189. */
  111190. hasMesh(mesh: AbstractMesh): boolean;
  111191. /**
  111192. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  111193. * @param mesh The mesh to highlight
  111194. * @param color The color of the highlight
  111195. * @param glowEmissiveOnly Extract the glow from the emissive texture
  111196. */
  111197. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  111198. /**
  111199. * Remove a mesh from the highlight layer in order to make it stop glowing.
  111200. * @param mesh The mesh to highlight
  111201. */
  111202. removeMesh(mesh: Mesh): void;
  111203. /**
  111204. * Force the stencil to the normal expected value for none glowing parts
  111205. */
  111206. private _defaultStencilReference;
  111207. /**
  111208. * Free any resources and references associated to a mesh.
  111209. * Internal use
  111210. * @param mesh The mesh to free.
  111211. * @hidden
  111212. */
  111213. _disposeMesh(mesh: Mesh): void;
  111214. /**
  111215. * Dispose the highlight layer and free resources.
  111216. */
  111217. dispose(): void;
  111218. /**
  111219. * Gets the class name of the effect layer
  111220. * @returns the string with the class name of the effect layer
  111221. */
  111222. getClassName(): string;
  111223. /**
  111224. * Serializes this Highlight layer
  111225. * @returns a serialized Highlight layer object
  111226. */
  111227. serialize(): any;
  111228. /**
  111229. * Creates a Highlight layer from parsed Highlight layer data
  111230. * @param parsedHightlightLayer defines the Highlight layer data
  111231. * @param scene defines the current scene
  111232. * @param rootUrl defines the root URL containing the Highlight layer information
  111233. * @returns a parsed Highlight layer
  111234. */
  111235. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  111236. }
  111237. }
  111238. declare module BABYLON {
  111239. interface AbstractScene {
  111240. /**
  111241. * The list of layers (background and foreground) of the scene
  111242. */
  111243. layers: Array<Layer>;
  111244. }
  111245. /**
  111246. * Defines the layer scene component responsible to manage any layers
  111247. * in a given scene.
  111248. */
  111249. export class LayerSceneComponent implements ISceneComponent {
  111250. /**
  111251. * The component name helpfull to identify the component in the list of scene components.
  111252. */
  111253. readonly name: string;
  111254. /**
  111255. * The scene the component belongs to.
  111256. */
  111257. scene: Scene;
  111258. private _engine;
  111259. /**
  111260. * Creates a new instance of the component for the given scene
  111261. * @param scene Defines the scene to register the component in
  111262. */
  111263. constructor(scene: Scene);
  111264. /**
  111265. * Registers the component in a given scene
  111266. */
  111267. register(): void;
  111268. /**
  111269. * Rebuilds the elements related to this component in case of
  111270. * context lost for instance.
  111271. */
  111272. rebuild(): void;
  111273. /**
  111274. * Disposes the component and the associated ressources.
  111275. */
  111276. dispose(): void;
  111277. private _draw;
  111278. private _drawCameraPredicate;
  111279. private _drawCameraBackground;
  111280. private _drawCameraForeground;
  111281. private _drawRenderTargetPredicate;
  111282. private _drawRenderTargetBackground;
  111283. private _drawRenderTargetForeground;
  111284. /**
  111285. * Adds all the elements from the container to the scene
  111286. * @param container the container holding the elements
  111287. */
  111288. addFromContainer(container: AbstractScene): void;
  111289. /**
  111290. * Removes all the elements in the container from the scene
  111291. * @param container contains the elements to remove
  111292. * @param dispose if the removed element should be disposed (default: false)
  111293. */
  111294. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111295. }
  111296. }
  111297. declare module BABYLON {
  111298. /** @hidden */
  111299. export var layerPixelShader: {
  111300. name: string;
  111301. shader: string;
  111302. };
  111303. }
  111304. declare module BABYLON {
  111305. /** @hidden */
  111306. export var layerVertexShader: {
  111307. name: string;
  111308. shader: string;
  111309. };
  111310. }
  111311. declare module BABYLON {
  111312. /**
  111313. * This represents a full screen 2d layer.
  111314. * This can be useful to display a picture in the background of your scene for instance.
  111315. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111316. */
  111317. export class Layer {
  111318. /**
  111319. * Define the name of the layer.
  111320. */
  111321. name: string;
  111322. /**
  111323. * Define the texture the layer should display.
  111324. */
  111325. texture: Nullable<Texture>;
  111326. /**
  111327. * Is the layer in background or foreground.
  111328. */
  111329. isBackground: boolean;
  111330. /**
  111331. * Define the color of the layer (instead of texture).
  111332. */
  111333. color: Color4;
  111334. /**
  111335. * Define the scale of the layer in order to zoom in out of the texture.
  111336. */
  111337. scale: Vector2;
  111338. /**
  111339. * Define an offset for the layer in order to shift the texture.
  111340. */
  111341. offset: Vector2;
  111342. /**
  111343. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  111344. */
  111345. alphaBlendingMode: number;
  111346. /**
  111347. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  111348. * Alpha test will not mix with the background color in case of transparency.
  111349. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  111350. */
  111351. alphaTest: boolean;
  111352. /**
  111353. * Define a mask to restrict the layer to only some of the scene cameras.
  111354. */
  111355. layerMask: number;
  111356. /**
  111357. * Define the list of render target the layer is visible into.
  111358. */
  111359. renderTargetTextures: RenderTargetTexture[];
  111360. /**
  111361. * Define if the layer is only used in renderTarget or if it also
  111362. * renders in the main frame buffer of the canvas.
  111363. */
  111364. renderOnlyInRenderTargetTextures: boolean;
  111365. private _scene;
  111366. private _vertexBuffers;
  111367. private _indexBuffer;
  111368. private _effect;
  111369. private _alphaTestEffect;
  111370. /**
  111371. * An event triggered when the layer is disposed.
  111372. */
  111373. onDisposeObservable: Observable<Layer>;
  111374. private _onDisposeObserver;
  111375. /**
  111376. * Back compatibility with callback before the onDisposeObservable existed.
  111377. * The set callback will be triggered when the layer has been disposed.
  111378. */
  111379. onDispose: () => void;
  111380. /**
  111381. * An event triggered before rendering the scene
  111382. */
  111383. onBeforeRenderObservable: Observable<Layer>;
  111384. private _onBeforeRenderObserver;
  111385. /**
  111386. * Back compatibility with callback before the onBeforeRenderObservable existed.
  111387. * The set callback will be triggered just before rendering the layer.
  111388. */
  111389. onBeforeRender: () => void;
  111390. /**
  111391. * An event triggered after rendering the scene
  111392. */
  111393. onAfterRenderObservable: Observable<Layer>;
  111394. private _onAfterRenderObserver;
  111395. /**
  111396. * Back compatibility with callback before the onAfterRenderObservable existed.
  111397. * The set callback will be triggered just after rendering the layer.
  111398. */
  111399. onAfterRender: () => void;
  111400. /**
  111401. * Instantiates a new layer.
  111402. * This represents a full screen 2d layer.
  111403. * This can be useful to display a picture in the background of your scene for instance.
  111404. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111405. * @param name Define the name of the layer in the scene
  111406. * @param imgUrl Define the url of the texture to display in the layer
  111407. * @param scene Define the scene the layer belongs to
  111408. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  111409. * @param color Defines a color for the layer
  111410. */
  111411. constructor(
  111412. /**
  111413. * Define the name of the layer.
  111414. */
  111415. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  111416. private _createIndexBuffer;
  111417. /** @hidden */
  111418. _rebuild(): void;
  111419. /**
  111420. * Renders the layer in the scene.
  111421. */
  111422. render(): void;
  111423. /**
  111424. * Disposes and releases the associated ressources.
  111425. */
  111426. dispose(): void;
  111427. }
  111428. }
  111429. declare module BABYLON {
  111430. /** @hidden */
  111431. export var lensFlarePixelShader: {
  111432. name: string;
  111433. shader: string;
  111434. };
  111435. }
  111436. declare module BABYLON {
  111437. /** @hidden */
  111438. export var lensFlareVertexShader: {
  111439. name: string;
  111440. shader: string;
  111441. };
  111442. }
  111443. declare module BABYLON {
  111444. /**
  111445. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111446. * It is usually composed of several `lensFlare`.
  111447. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111448. */
  111449. export class LensFlareSystem {
  111450. /**
  111451. * Define the name of the lens flare system
  111452. */
  111453. name: string;
  111454. /**
  111455. * List of lens flares used in this system.
  111456. */
  111457. lensFlares: LensFlare[];
  111458. /**
  111459. * Define a limit from the border the lens flare can be visible.
  111460. */
  111461. borderLimit: number;
  111462. /**
  111463. * Define a viewport border we do not want to see the lens flare in.
  111464. */
  111465. viewportBorder: number;
  111466. /**
  111467. * Define a predicate which could limit the list of meshes able to occlude the effect.
  111468. */
  111469. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  111470. /**
  111471. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  111472. */
  111473. layerMask: number;
  111474. /**
  111475. * Define the id of the lens flare system in the scene.
  111476. * (equal to name by default)
  111477. */
  111478. id: string;
  111479. private _scene;
  111480. private _emitter;
  111481. private _vertexBuffers;
  111482. private _indexBuffer;
  111483. private _effect;
  111484. private _positionX;
  111485. private _positionY;
  111486. private _isEnabled;
  111487. /** @hidden */
  111488. static _SceneComponentInitialization: (scene: Scene) => void;
  111489. /**
  111490. * Instantiates a lens flare system.
  111491. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111492. * It is usually composed of several `lensFlare`.
  111493. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111494. * @param name Define the name of the lens flare system in the scene
  111495. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  111496. * @param scene Define the scene the lens flare system belongs to
  111497. */
  111498. constructor(
  111499. /**
  111500. * Define the name of the lens flare system
  111501. */
  111502. name: string, emitter: any, scene: Scene);
  111503. /**
  111504. * Define if the lens flare system is enabled.
  111505. */
  111506. isEnabled: boolean;
  111507. /**
  111508. * Get the scene the effects belongs to.
  111509. * @returns the scene holding the lens flare system
  111510. */
  111511. getScene(): Scene;
  111512. /**
  111513. * Get the emitter of the lens flare system.
  111514. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111515. * @returns the emitter of the lens flare system
  111516. */
  111517. getEmitter(): any;
  111518. /**
  111519. * Set the emitter of the lens flare system.
  111520. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111521. * @param newEmitter Define the new emitter of the system
  111522. */
  111523. setEmitter(newEmitter: any): void;
  111524. /**
  111525. * Get the lens flare system emitter position.
  111526. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  111527. * @returns the position
  111528. */
  111529. getEmitterPosition(): Vector3;
  111530. /**
  111531. * @hidden
  111532. */
  111533. computeEffectivePosition(globalViewport: Viewport): boolean;
  111534. /** @hidden */
  111535. _isVisible(): boolean;
  111536. /**
  111537. * @hidden
  111538. */
  111539. render(): boolean;
  111540. /**
  111541. * Dispose and release the lens flare with its associated resources.
  111542. */
  111543. dispose(): void;
  111544. /**
  111545. * Parse a lens flare system from a JSON repressentation
  111546. * @param parsedLensFlareSystem Define the JSON to parse
  111547. * @param scene Define the scene the parsed system should be instantiated in
  111548. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  111549. * @returns the parsed system
  111550. */
  111551. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  111552. /**
  111553. * Serialize the current Lens Flare System into a JSON representation.
  111554. * @returns the serialized JSON
  111555. */
  111556. serialize(): any;
  111557. }
  111558. }
  111559. declare module BABYLON {
  111560. /**
  111561. * This represents one of the lens effect in a `lensFlareSystem`.
  111562. * It controls one of the indiviual texture used in the effect.
  111563. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111564. */
  111565. export class LensFlare {
  111566. /**
  111567. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111568. */
  111569. size: number;
  111570. /**
  111571. * 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.
  111572. */
  111573. position: number;
  111574. /**
  111575. * Define the lens color.
  111576. */
  111577. color: Color3;
  111578. /**
  111579. * Define the lens texture.
  111580. */
  111581. texture: Nullable<Texture>;
  111582. /**
  111583. * Define the alpha mode to render this particular lens.
  111584. */
  111585. alphaMode: number;
  111586. private _system;
  111587. /**
  111588. * Creates a new Lens Flare.
  111589. * This represents one of the lens effect in a `lensFlareSystem`.
  111590. * It controls one of the indiviual texture used in the effect.
  111591. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111592. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  111593. * @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.
  111594. * @param color Define the lens color
  111595. * @param imgUrl Define the lens texture url
  111596. * @param system Define the `lensFlareSystem` this flare is part of
  111597. * @returns The newly created Lens Flare
  111598. */
  111599. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  111600. /**
  111601. * Instantiates a new Lens Flare.
  111602. * This represents one of the lens effect in a `lensFlareSystem`.
  111603. * It controls one of the indiviual texture used in the effect.
  111604. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111605. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  111606. * @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.
  111607. * @param color Define the lens color
  111608. * @param imgUrl Define the lens texture url
  111609. * @param system Define the `lensFlareSystem` this flare is part of
  111610. */
  111611. constructor(
  111612. /**
  111613. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111614. */
  111615. size: number,
  111616. /**
  111617. * 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.
  111618. */
  111619. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  111620. /**
  111621. * Dispose and release the lens flare with its associated resources.
  111622. */
  111623. dispose(): void;
  111624. }
  111625. }
  111626. declare module BABYLON {
  111627. interface AbstractScene {
  111628. /**
  111629. * The list of lens flare system added to the scene
  111630. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111631. */
  111632. lensFlareSystems: Array<LensFlareSystem>;
  111633. /**
  111634. * Removes the given lens flare system from this scene.
  111635. * @param toRemove The lens flare system to remove
  111636. * @returns The index of the removed lens flare system
  111637. */
  111638. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  111639. /**
  111640. * Adds the given lens flare system to this scene
  111641. * @param newLensFlareSystem The lens flare system to add
  111642. */
  111643. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  111644. /**
  111645. * Gets a lens flare system using its name
  111646. * @param name defines the name to look for
  111647. * @returns the lens flare system or null if not found
  111648. */
  111649. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  111650. /**
  111651. * Gets a lens flare system using its id
  111652. * @param id defines the id to look for
  111653. * @returns the lens flare system or null if not found
  111654. */
  111655. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  111656. }
  111657. /**
  111658. * Defines the lens flare scene component responsible to manage any lens flares
  111659. * in a given scene.
  111660. */
  111661. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  111662. /**
  111663. * The component name helpfull to identify the component in the list of scene components.
  111664. */
  111665. readonly name: string;
  111666. /**
  111667. * The scene the component belongs to.
  111668. */
  111669. scene: Scene;
  111670. /**
  111671. * Creates a new instance of the component for the given scene
  111672. * @param scene Defines the scene to register the component in
  111673. */
  111674. constructor(scene: Scene);
  111675. /**
  111676. * Registers the component in a given scene
  111677. */
  111678. register(): void;
  111679. /**
  111680. * Rebuilds the elements related to this component in case of
  111681. * context lost for instance.
  111682. */
  111683. rebuild(): void;
  111684. /**
  111685. * Adds all the elements from the container to the scene
  111686. * @param container the container holding the elements
  111687. */
  111688. addFromContainer(container: AbstractScene): void;
  111689. /**
  111690. * Removes all the elements in the container from the scene
  111691. * @param container contains the elements to remove
  111692. * @param dispose if the removed element should be disposed (default: false)
  111693. */
  111694. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111695. /**
  111696. * Serializes the component data to the specified json object
  111697. * @param serializationObject The object to serialize to
  111698. */
  111699. serialize(serializationObject: any): void;
  111700. /**
  111701. * Disposes the component and the associated ressources.
  111702. */
  111703. dispose(): void;
  111704. private _draw;
  111705. }
  111706. }
  111707. declare module BABYLON {
  111708. /**
  111709. * Defines the shadow generator component responsible to manage any shadow generators
  111710. * in a given scene.
  111711. */
  111712. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  111713. /**
  111714. * The component name helpfull to identify the component in the list of scene components.
  111715. */
  111716. readonly name: string;
  111717. /**
  111718. * The scene the component belongs to.
  111719. */
  111720. scene: Scene;
  111721. /**
  111722. * Creates a new instance of the component for the given scene
  111723. * @param scene Defines the scene to register the component in
  111724. */
  111725. constructor(scene: Scene);
  111726. /**
  111727. * Registers the component in a given scene
  111728. */
  111729. register(): void;
  111730. /**
  111731. * Rebuilds the elements related to this component in case of
  111732. * context lost for instance.
  111733. */
  111734. rebuild(): void;
  111735. /**
  111736. * Serializes the component data to the specified json object
  111737. * @param serializationObject The object to serialize to
  111738. */
  111739. serialize(serializationObject: any): void;
  111740. /**
  111741. * Adds all the elements from the container to the scene
  111742. * @param container the container holding the elements
  111743. */
  111744. addFromContainer(container: AbstractScene): void;
  111745. /**
  111746. * Removes all the elements in the container from the scene
  111747. * @param container contains the elements to remove
  111748. * @param dispose if the removed element should be disposed (default: false)
  111749. */
  111750. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111751. /**
  111752. * Rebuilds the elements related to this component in case of
  111753. * context lost for instance.
  111754. */
  111755. dispose(): void;
  111756. private _gatherRenderTargets;
  111757. }
  111758. }
  111759. declare module BABYLON {
  111760. /**
  111761. * A point light is a light defined by an unique point in world space.
  111762. * The light is emitted in every direction from this point.
  111763. * A good example of a point light is a standard light bulb.
  111764. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111765. */
  111766. export class PointLight extends ShadowLight {
  111767. private _shadowAngle;
  111768. /**
  111769. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111770. * This specifies what angle the shadow will use to be created.
  111771. *
  111772. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111773. */
  111774. /**
  111775. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111776. * This specifies what angle the shadow will use to be created.
  111777. *
  111778. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111779. */
  111780. shadowAngle: number;
  111781. /**
  111782. * Gets the direction if it has been set.
  111783. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111784. */
  111785. /**
  111786. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111787. */
  111788. direction: Vector3;
  111789. /**
  111790. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  111791. * A PointLight emits the light in every direction.
  111792. * It can cast shadows.
  111793. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  111794. * ```javascript
  111795. * var pointLight = new PointLight("pl", camera.position, scene);
  111796. * ```
  111797. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111798. * @param name The light friendly name
  111799. * @param position The position of the point light in the scene
  111800. * @param scene The scene the lights belongs to
  111801. */
  111802. constructor(name: string, position: Vector3, scene: Scene);
  111803. /**
  111804. * Returns the string "PointLight"
  111805. * @returns the class name
  111806. */
  111807. getClassName(): string;
  111808. /**
  111809. * Returns the integer 0.
  111810. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111811. */
  111812. getTypeID(): number;
  111813. /**
  111814. * Specifies wether or not the shadowmap should be a cube texture.
  111815. * @returns true if the shadowmap needs to be a cube texture.
  111816. */
  111817. needCube(): boolean;
  111818. /**
  111819. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  111820. * @param faceIndex The index of the face we are computed the direction to generate shadow
  111821. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  111822. */
  111823. getShadowDirection(faceIndex?: number): Vector3;
  111824. /**
  111825. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  111826. * - fov = PI / 2
  111827. * - aspect ratio : 1.0
  111828. * - z-near and far equal to the active camera minZ and maxZ.
  111829. * Returns the PointLight.
  111830. */
  111831. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111832. protected _buildUniformLayout(): void;
  111833. /**
  111834. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  111835. * @param effect The effect to update
  111836. * @param lightIndex The index of the light in the effect to update
  111837. * @returns The point light
  111838. */
  111839. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  111840. /**
  111841. * Prepares the list of defines specific to the light type.
  111842. * @param defines the list of defines
  111843. * @param lightIndex defines the index of the light for the effect
  111844. */
  111845. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111846. }
  111847. }
  111848. declare module BABYLON {
  111849. /**
  111850. * Header information of HDR texture files.
  111851. */
  111852. export interface HDRInfo {
  111853. /**
  111854. * The height of the texture in pixels.
  111855. */
  111856. height: number;
  111857. /**
  111858. * The width of the texture in pixels.
  111859. */
  111860. width: number;
  111861. /**
  111862. * The index of the beginning of the data in the binary file.
  111863. */
  111864. dataPosition: number;
  111865. }
  111866. /**
  111867. * This groups tools to convert HDR texture to native colors array.
  111868. */
  111869. export class HDRTools {
  111870. private static Ldexp;
  111871. private static Rgbe2float;
  111872. private static readStringLine;
  111873. /**
  111874. * Reads header information from an RGBE texture stored in a native array.
  111875. * More information on this format are available here:
  111876. * https://en.wikipedia.org/wiki/RGBE_image_format
  111877. *
  111878. * @param uint8array The binary file stored in native array.
  111879. * @return The header information.
  111880. */
  111881. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  111882. /**
  111883. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  111884. * This RGBE texture needs to store the information as a panorama.
  111885. *
  111886. * More information on this format are available here:
  111887. * https://en.wikipedia.org/wiki/RGBE_image_format
  111888. *
  111889. * @param buffer The binary file stored in an array buffer.
  111890. * @param size The expected size of the extracted cubemap.
  111891. * @return The Cube Map information.
  111892. */
  111893. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  111894. /**
  111895. * Returns the pixels data extracted from an RGBE texture.
  111896. * This pixels will be stored left to right up to down in the R G B order in one array.
  111897. *
  111898. * More information on this format are available here:
  111899. * https://en.wikipedia.org/wiki/RGBE_image_format
  111900. *
  111901. * @param uint8array The binary file stored in an array buffer.
  111902. * @param hdrInfo The header information of the file.
  111903. * @return The pixels data in RGB right to left up to down order.
  111904. */
  111905. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111906. private static RGBE_ReadPixels_RLE;
  111907. }
  111908. }
  111909. declare module BABYLON {
  111910. /**
  111911. * This represents a texture coming from an HDR input.
  111912. *
  111913. * The only supported format is currently panorama picture stored in RGBE format.
  111914. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111915. */
  111916. export class HDRCubeTexture extends BaseTexture {
  111917. private static _facesMapping;
  111918. private _generateHarmonics;
  111919. private _noMipmap;
  111920. private _textureMatrix;
  111921. private _size;
  111922. private _onLoad;
  111923. private _onError;
  111924. /**
  111925. * The texture URL.
  111926. */
  111927. url: string;
  111928. /**
  111929. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111930. */
  111931. coordinatesMode: number;
  111932. protected _isBlocking: boolean;
  111933. /**
  111934. * Sets wether or not the texture is blocking during loading.
  111935. */
  111936. /**
  111937. * Gets wether or not the texture is blocking during loading.
  111938. */
  111939. isBlocking: boolean;
  111940. protected _rotationY: number;
  111941. /**
  111942. * Sets texture matrix rotation angle around Y axis in radians.
  111943. */
  111944. /**
  111945. * Gets texture matrix rotation angle around Y axis radians.
  111946. */
  111947. rotationY: number;
  111948. /**
  111949. * Gets or sets the center of the bounding box associated with the cube texture
  111950. * It must define where the camera used to render the texture was set
  111951. */
  111952. boundingBoxPosition: Vector3;
  111953. private _boundingBoxSize;
  111954. /**
  111955. * Gets or sets the size of the bounding box associated with the cube texture
  111956. * When defined, the cubemap will switch to local mode
  111957. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111958. * @example https://www.babylonjs-playground.com/#RNASML
  111959. */
  111960. boundingBoxSize: Vector3;
  111961. /**
  111962. * Instantiates an HDRTexture from the following parameters.
  111963. *
  111964. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111965. * @param scene The scene the texture will be used in
  111966. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111967. * @param noMipmap Forces to not generate the mipmap if true
  111968. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111969. * @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)
  111970. * @param reserved Reserved flag for internal use.
  111971. */
  111972. 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>);
  111973. /**
  111974. * Get the current class name of the texture useful for serialization or dynamic coding.
  111975. * @returns "HDRCubeTexture"
  111976. */
  111977. getClassName(): string;
  111978. /**
  111979. * Occurs when the file is raw .hdr file.
  111980. */
  111981. private loadTexture;
  111982. clone(): HDRCubeTexture;
  111983. delayLoad(): void;
  111984. /**
  111985. * Get the texture reflection matrix used to rotate/transform the reflection.
  111986. * @returns the reflection matrix
  111987. */
  111988. getReflectionTextureMatrix(): Matrix;
  111989. /**
  111990. * Set the texture reflection matrix used to rotate/transform the reflection.
  111991. * @param value Define the reflection matrix to set
  111992. */
  111993. setReflectionTextureMatrix(value: Matrix): void;
  111994. /**
  111995. * Parses a JSON representation of an HDR Texture in order to create the texture
  111996. * @param parsedTexture Define the JSON representation
  111997. * @param scene Define the scene the texture should be created in
  111998. * @param rootUrl Define the root url in case we need to load relative dependencies
  111999. * @returns the newly created texture after parsing
  112000. */
  112001. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  112002. serialize(): any;
  112003. }
  112004. }
  112005. declare module BABYLON {
  112006. /**
  112007. * Class used to control physics engine
  112008. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  112009. */
  112010. export class PhysicsEngine implements IPhysicsEngine {
  112011. private _physicsPlugin;
  112012. /**
  112013. * Global value used to control the smallest number supported by the simulation
  112014. */
  112015. static Epsilon: number;
  112016. private _impostors;
  112017. private _joints;
  112018. /**
  112019. * Gets the gravity vector used by the simulation
  112020. */
  112021. gravity: Vector3;
  112022. /**
  112023. * Factory used to create the default physics plugin.
  112024. * @returns The default physics plugin
  112025. */
  112026. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  112027. /**
  112028. * Creates a new Physics Engine
  112029. * @param gravity defines the gravity vector used by the simulation
  112030. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  112031. */
  112032. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  112033. /**
  112034. * Sets the gravity vector used by the simulation
  112035. * @param gravity defines the gravity vector to use
  112036. */
  112037. setGravity(gravity: Vector3): void;
  112038. /**
  112039. * Set the time step of the physics engine.
  112040. * Default is 1/60.
  112041. * To slow it down, enter 1/600 for example.
  112042. * To speed it up, 1/30
  112043. * @param newTimeStep defines the new timestep to apply to this world.
  112044. */
  112045. setTimeStep(newTimeStep?: number): void;
  112046. /**
  112047. * Get the time step of the physics engine.
  112048. * @returns the current time step
  112049. */
  112050. getTimeStep(): number;
  112051. /**
  112052. * Release all resources
  112053. */
  112054. dispose(): void;
  112055. /**
  112056. * Gets the name of the current physics plugin
  112057. * @returns the name of the plugin
  112058. */
  112059. getPhysicsPluginName(): string;
  112060. /**
  112061. * Adding a new impostor for the impostor tracking.
  112062. * This will be done by the impostor itself.
  112063. * @param impostor the impostor to add
  112064. */
  112065. addImpostor(impostor: PhysicsImpostor): void;
  112066. /**
  112067. * Remove an impostor from the engine.
  112068. * This impostor and its mesh will not longer be updated by the physics engine.
  112069. * @param impostor the impostor to remove
  112070. */
  112071. removeImpostor(impostor: PhysicsImpostor): void;
  112072. /**
  112073. * Add a joint to the physics engine
  112074. * @param mainImpostor defines the main impostor to which the joint is added.
  112075. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112076. * @param joint defines the joint that will connect both impostors.
  112077. */
  112078. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112079. /**
  112080. * Removes a joint from the simulation
  112081. * @param mainImpostor defines the impostor used with the joint
  112082. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112083. * @param joint defines the joint to remove
  112084. */
  112085. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112086. /**
  112087. * Called by the scene. No need to call it.
  112088. * @param delta defines the timespam between frames
  112089. */
  112090. _step(delta: number): void;
  112091. /**
  112092. * Gets the current plugin used to run the simulation
  112093. * @returns current plugin
  112094. */
  112095. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112096. /**
  112097. * Gets the list of physic impostors
  112098. * @returns an array of PhysicsImpostor
  112099. */
  112100. getImpostors(): Array<PhysicsImpostor>;
  112101. /**
  112102. * Gets the impostor for a physics enabled object
  112103. * @param object defines the object impersonated by the impostor
  112104. * @returns the PhysicsImpostor or null if not found
  112105. */
  112106. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112107. /**
  112108. * Gets the impostor for a physics body object
  112109. * @param body defines physics body used by the impostor
  112110. * @returns the PhysicsImpostor or null if not found
  112111. */
  112112. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112113. /**
  112114. * Does a raycast in the physics world
  112115. * @param from when should the ray start?
  112116. * @param to when should the ray end?
  112117. * @returns PhysicsRaycastResult
  112118. */
  112119. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112120. }
  112121. }
  112122. declare module BABYLON {
  112123. /** @hidden */
  112124. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  112125. private _useDeltaForWorldStep;
  112126. world: any;
  112127. name: string;
  112128. private _physicsMaterials;
  112129. private _fixedTimeStep;
  112130. private _cannonRaycastResult;
  112131. private _raycastResult;
  112132. private _physicsBodysToRemoveAfterStep;
  112133. BJSCANNON: any;
  112134. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  112135. setGravity(gravity: Vector3): void;
  112136. setTimeStep(timeStep: number): void;
  112137. getTimeStep(): number;
  112138. executeStep(delta: number): void;
  112139. private _removeMarkedPhysicsBodiesFromWorld;
  112140. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112141. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112142. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112143. private _processChildMeshes;
  112144. removePhysicsBody(impostor: PhysicsImpostor): void;
  112145. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112146. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112147. private _addMaterial;
  112148. private _checkWithEpsilon;
  112149. private _createShape;
  112150. private _createHeightmap;
  112151. private _minus90X;
  112152. private _plus90X;
  112153. private _tmpPosition;
  112154. private _tmpDeltaPosition;
  112155. private _tmpUnityRotation;
  112156. private _updatePhysicsBodyTransformation;
  112157. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112158. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112159. isSupported(): boolean;
  112160. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112161. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112162. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112163. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112164. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112165. getBodyMass(impostor: PhysicsImpostor): number;
  112166. getBodyFriction(impostor: PhysicsImpostor): number;
  112167. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112168. getBodyRestitution(impostor: PhysicsImpostor): number;
  112169. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112170. sleepBody(impostor: PhysicsImpostor): void;
  112171. wakeUpBody(impostor: PhysicsImpostor): void;
  112172. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  112173. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112174. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112175. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112176. getRadius(impostor: PhysicsImpostor): number;
  112177. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112178. dispose(): void;
  112179. private _extendNamespace;
  112180. /**
  112181. * Does a raycast in the physics world
  112182. * @param from when should the ray start?
  112183. * @param to when should the ray end?
  112184. * @returns PhysicsRaycastResult
  112185. */
  112186. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112187. }
  112188. }
  112189. declare module BABYLON {
  112190. /** @hidden */
  112191. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  112192. world: any;
  112193. name: string;
  112194. BJSOIMO: any;
  112195. private _raycastResult;
  112196. constructor(iterations?: number, oimoInjection?: any);
  112197. setGravity(gravity: Vector3): void;
  112198. setTimeStep(timeStep: number): void;
  112199. getTimeStep(): number;
  112200. private _tmpImpostorsArray;
  112201. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112202. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112203. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112204. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112205. private _tmpPositionVector;
  112206. removePhysicsBody(impostor: PhysicsImpostor): void;
  112207. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112208. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112209. isSupported(): boolean;
  112210. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112211. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112212. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112213. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112214. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112215. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112216. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112217. getBodyMass(impostor: PhysicsImpostor): number;
  112218. getBodyFriction(impostor: PhysicsImpostor): number;
  112219. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112220. getBodyRestitution(impostor: PhysicsImpostor): number;
  112221. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112222. sleepBody(impostor: PhysicsImpostor): void;
  112223. wakeUpBody(impostor: PhysicsImpostor): void;
  112224. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112225. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  112226. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112227. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112228. getRadius(impostor: PhysicsImpostor): number;
  112229. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112230. dispose(): void;
  112231. /**
  112232. * Does a raycast in the physics world
  112233. * @param from when should the ray start?
  112234. * @param to when should the ray end?
  112235. * @returns PhysicsRaycastResult
  112236. */
  112237. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112238. }
  112239. }
  112240. declare module BABYLON {
  112241. /**
  112242. * Class containing static functions to help procedurally build meshes
  112243. */
  112244. export class RibbonBuilder {
  112245. /**
  112246. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  112247. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  112248. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  112249. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  112250. * * 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
  112251. * * 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
  112252. * * 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
  112253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112255. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112256. * * 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
  112257. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  112258. * * 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
  112259. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  112260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112261. * @param name defines the name of the mesh
  112262. * @param options defines the options used to create the mesh
  112263. * @param scene defines the hosting scene
  112264. * @returns the ribbon mesh
  112265. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  112266. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112267. */
  112268. static CreateRibbon(name: string, options: {
  112269. pathArray: Vector3[][];
  112270. closeArray?: boolean;
  112271. closePath?: boolean;
  112272. offset?: number;
  112273. updatable?: boolean;
  112274. sideOrientation?: number;
  112275. frontUVs?: Vector4;
  112276. backUVs?: Vector4;
  112277. instance?: Mesh;
  112278. invertUV?: boolean;
  112279. uvs?: Vector2[];
  112280. colors?: Color4[];
  112281. }, scene?: Nullable<Scene>): Mesh;
  112282. }
  112283. }
  112284. declare module BABYLON {
  112285. /**
  112286. * Class containing static functions to help procedurally build meshes
  112287. */
  112288. export class ShapeBuilder {
  112289. /**
  112290. * 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.
  112291. * * 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.
  112292. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112293. * * 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.
  112294. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  112295. * * 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
  112296. * * 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
  112297. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  112298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112300. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  112301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112302. * @param name defines the name of the mesh
  112303. * @param options defines the options used to create the mesh
  112304. * @param scene defines the hosting scene
  112305. * @returns the extruded shape mesh
  112306. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112307. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112308. */
  112309. static ExtrudeShape(name: string, options: {
  112310. shape: Vector3[];
  112311. path: Vector3[];
  112312. scale?: number;
  112313. rotation?: number;
  112314. cap?: number;
  112315. updatable?: boolean;
  112316. sideOrientation?: number;
  112317. frontUVs?: Vector4;
  112318. backUVs?: Vector4;
  112319. instance?: Mesh;
  112320. invertUV?: boolean;
  112321. }, scene?: Nullable<Scene>): Mesh;
  112322. /**
  112323. * Creates an custom extruded shape mesh.
  112324. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  112325. * * 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.
  112326. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112327. * * 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
  112328. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  112329. * * 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
  112330. * * It must returns a float value that will be the scale value applied to the shape on each path point
  112331. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  112332. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  112333. * * 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
  112334. * * 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
  112335. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  112336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112337. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112338. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112340. * @param name defines the name of the mesh
  112341. * @param options defines the options used to create the mesh
  112342. * @param scene defines the hosting scene
  112343. * @returns the custom extruded shape mesh
  112344. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  112345. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112347. */
  112348. static ExtrudeShapeCustom(name: string, options: {
  112349. shape: Vector3[];
  112350. path: Vector3[];
  112351. scaleFunction?: any;
  112352. rotationFunction?: any;
  112353. ribbonCloseArray?: boolean;
  112354. ribbonClosePath?: boolean;
  112355. cap?: number;
  112356. updatable?: boolean;
  112357. sideOrientation?: number;
  112358. frontUVs?: Vector4;
  112359. backUVs?: Vector4;
  112360. instance?: Mesh;
  112361. invertUV?: boolean;
  112362. }, scene?: Nullable<Scene>): Mesh;
  112363. private static _ExtrudeShapeGeneric;
  112364. }
  112365. }
  112366. declare module BABYLON {
  112367. /**
  112368. * AmmoJS Physics plugin
  112369. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112370. * @see https://github.com/kripken/ammo.js/
  112371. */
  112372. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  112373. private _useDeltaForWorldStep;
  112374. /**
  112375. * Reference to the Ammo library
  112376. */
  112377. bjsAMMO: any;
  112378. /**
  112379. * Created ammoJS world which physics bodies are added to
  112380. */
  112381. world: any;
  112382. /**
  112383. * Name of the plugin
  112384. */
  112385. name: string;
  112386. private _timeStep;
  112387. private _fixedTimeStep;
  112388. private _maxSteps;
  112389. private _tmpQuaternion;
  112390. private _tmpAmmoTransform;
  112391. private _tmpAmmoQuaternion;
  112392. private _tmpAmmoConcreteContactResultCallback;
  112393. private _collisionConfiguration;
  112394. private _dispatcher;
  112395. private _overlappingPairCache;
  112396. private _solver;
  112397. private _softBodySolver;
  112398. private _tmpAmmoVectorA;
  112399. private _tmpAmmoVectorB;
  112400. private _tmpAmmoVectorC;
  112401. private _tmpAmmoVectorD;
  112402. private _tmpContactCallbackResult;
  112403. private _tmpAmmoVectorRCA;
  112404. private _tmpAmmoVectorRCB;
  112405. private _raycastResult;
  112406. private static readonly DISABLE_COLLISION_FLAG;
  112407. private static readonly KINEMATIC_FLAG;
  112408. private static readonly DISABLE_DEACTIVATION_FLAG;
  112409. /**
  112410. * Initializes the ammoJS plugin
  112411. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  112412. * @param ammoInjection can be used to inject your own ammo reference
  112413. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  112414. */
  112415. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  112416. /**
  112417. * Sets the gravity of the physics world (m/(s^2))
  112418. * @param gravity Gravity to set
  112419. */
  112420. setGravity(gravity: Vector3): void;
  112421. /**
  112422. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  112423. * @param timeStep timestep to use in seconds
  112424. */
  112425. setTimeStep(timeStep: number): void;
  112426. /**
  112427. * 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)
  112428. * @param fixedTimeStep fixedTimeStep to use in seconds
  112429. */
  112430. setFixedTimeStep(fixedTimeStep: number): void;
  112431. /**
  112432. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  112433. * @param maxSteps the maximum number of steps by the physics engine per frame
  112434. */
  112435. setMaxSteps(maxSteps: number): void;
  112436. /**
  112437. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  112438. * @returns the current timestep in seconds
  112439. */
  112440. getTimeStep(): number;
  112441. private _isImpostorInContact;
  112442. private _isImpostorPairInContact;
  112443. private _stepSimulation;
  112444. /**
  112445. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  112446. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  112447. * After the step the babylon meshes are set to the position of the physics imposters
  112448. * @param delta amount of time to step forward
  112449. * @param impostors array of imposters to update before/after the step
  112450. */
  112451. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112452. /**
  112453. * Update babylon mesh to match physics world object
  112454. * @param impostor imposter to match
  112455. */
  112456. private _afterSoftStep;
  112457. /**
  112458. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112459. * @param impostor imposter to match
  112460. */
  112461. private _ropeStep;
  112462. /**
  112463. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112464. * @param impostor imposter to match
  112465. */
  112466. private _softbodyOrClothStep;
  112467. private _tmpVector;
  112468. private _tmpMatrix;
  112469. /**
  112470. * Applies an impulse on the imposter
  112471. * @param impostor imposter to apply impulse to
  112472. * @param force amount of force to be applied to the imposter
  112473. * @param contactPoint the location to apply the impulse on the imposter
  112474. */
  112475. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112476. /**
  112477. * Applies a force on the imposter
  112478. * @param impostor imposter to apply force
  112479. * @param force amount of force to be applied to the imposter
  112480. * @param contactPoint the location to apply the force on the imposter
  112481. */
  112482. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112483. /**
  112484. * Creates a physics body using the plugin
  112485. * @param impostor the imposter to create the physics body on
  112486. */
  112487. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112488. /**
  112489. * Removes the physics body from the imposter and disposes of the body's memory
  112490. * @param impostor imposter to remove the physics body from
  112491. */
  112492. removePhysicsBody(impostor: PhysicsImpostor): void;
  112493. /**
  112494. * Generates a joint
  112495. * @param impostorJoint the imposter joint to create the joint with
  112496. */
  112497. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112498. /**
  112499. * Removes a joint
  112500. * @param impostorJoint the imposter joint to remove the joint from
  112501. */
  112502. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112503. private _addMeshVerts;
  112504. /**
  112505. * Initialise the soft body vertices to match its object's (mesh) vertices
  112506. * Softbody vertices (nodes) are in world space and to match this
  112507. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  112508. * @param impostor to create the softbody for
  112509. */
  112510. private _softVertexData;
  112511. /**
  112512. * Create an impostor's soft body
  112513. * @param impostor to create the softbody for
  112514. */
  112515. private _createSoftbody;
  112516. /**
  112517. * Create cloth for an impostor
  112518. * @param impostor to create the softbody for
  112519. */
  112520. private _createCloth;
  112521. /**
  112522. * Create rope for an impostor
  112523. * @param impostor to create the softbody for
  112524. */
  112525. private _createRope;
  112526. private _addHullVerts;
  112527. private _createShape;
  112528. /**
  112529. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  112530. * @param impostor imposter containing the physics body and babylon object
  112531. */
  112532. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112533. /**
  112534. * Sets the babylon object's position/rotation from the physics body's position/rotation
  112535. * @param impostor imposter containing the physics body and babylon object
  112536. * @param newPosition new position
  112537. * @param newRotation new rotation
  112538. */
  112539. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112540. /**
  112541. * If this plugin is supported
  112542. * @returns true if its supported
  112543. */
  112544. isSupported(): boolean;
  112545. /**
  112546. * Sets the linear velocity of the physics body
  112547. * @param impostor imposter to set the velocity on
  112548. * @param velocity velocity to set
  112549. */
  112550. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112551. /**
  112552. * Sets the angular velocity of the physics body
  112553. * @param impostor imposter to set the velocity on
  112554. * @param velocity velocity to set
  112555. */
  112556. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112557. /**
  112558. * gets the linear velocity
  112559. * @param impostor imposter to get linear velocity from
  112560. * @returns linear velocity
  112561. */
  112562. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112563. /**
  112564. * gets the angular velocity
  112565. * @param impostor imposter to get angular velocity from
  112566. * @returns angular velocity
  112567. */
  112568. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112569. /**
  112570. * Sets the mass of physics body
  112571. * @param impostor imposter to set the mass on
  112572. * @param mass mass to set
  112573. */
  112574. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112575. /**
  112576. * Gets the mass of the physics body
  112577. * @param impostor imposter to get the mass from
  112578. * @returns mass
  112579. */
  112580. getBodyMass(impostor: PhysicsImpostor): number;
  112581. /**
  112582. * Gets friction of the impostor
  112583. * @param impostor impostor to get friction from
  112584. * @returns friction value
  112585. */
  112586. getBodyFriction(impostor: PhysicsImpostor): number;
  112587. /**
  112588. * Sets friction of the impostor
  112589. * @param impostor impostor to set friction on
  112590. * @param friction friction value
  112591. */
  112592. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112593. /**
  112594. * Gets restitution of the impostor
  112595. * @param impostor impostor to get restitution from
  112596. * @returns restitution value
  112597. */
  112598. getBodyRestitution(impostor: PhysicsImpostor): number;
  112599. /**
  112600. * Sets resitution of the impostor
  112601. * @param impostor impostor to set resitution on
  112602. * @param restitution resitution value
  112603. */
  112604. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112605. /**
  112606. * Gets pressure inside the impostor
  112607. * @param impostor impostor to get pressure from
  112608. * @returns pressure value
  112609. */
  112610. getBodyPressure(impostor: PhysicsImpostor): number;
  112611. /**
  112612. * Sets pressure inside a soft body impostor
  112613. * Cloth and rope must remain 0 pressure
  112614. * @param impostor impostor to set pressure on
  112615. * @param pressure pressure value
  112616. */
  112617. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  112618. /**
  112619. * Gets stiffness of the impostor
  112620. * @param impostor impostor to get stiffness from
  112621. * @returns pressure value
  112622. */
  112623. getBodyStiffness(impostor: PhysicsImpostor): number;
  112624. /**
  112625. * Sets stiffness of the impostor
  112626. * @param impostor impostor to set stiffness on
  112627. * @param stiffness stiffness value from 0 to 1
  112628. */
  112629. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  112630. /**
  112631. * Gets velocityIterations of the impostor
  112632. * @param impostor impostor to get velocity iterations from
  112633. * @returns velocityIterations value
  112634. */
  112635. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  112636. /**
  112637. * Sets velocityIterations of the impostor
  112638. * @param impostor impostor to set velocity iterations on
  112639. * @param velocityIterations velocityIterations value
  112640. */
  112641. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  112642. /**
  112643. * Gets positionIterations of the impostor
  112644. * @param impostor impostor to get position iterations from
  112645. * @returns positionIterations value
  112646. */
  112647. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  112648. /**
  112649. * Sets positionIterations of the impostor
  112650. * @param impostor impostor to set position on
  112651. * @param positionIterations positionIterations value
  112652. */
  112653. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  112654. /**
  112655. * Append an anchor to a cloth object
  112656. * @param impostor is the cloth impostor to add anchor to
  112657. * @param otherImpostor is the rigid impostor to anchor to
  112658. * @param width ratio across width from 0 to 1
  112659. * @param height ratio up height from 0 to 1
  112660. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112661. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112662. */
  112663. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112664. /**
  112665. * Append an hook to a rope object
  112666. * @param impostor is the rope impostor to add hook to
  112667. * @param otherImpostor is the rigid impostor to hook to
  112668. * @param length ratio along the rope from 0 to 1
  112669. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  112670. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112671. */
  112672. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112673. /**
  112674. * Sleeps the physics body and stops it from being active
  112675. * @param impostor impostor to sleep
  112676. */
  112677. sleepBody(impostor: PhysicsImpostor): void;
  112678. /**
  112679. * Activates the physics body
  112680. * @param impostor impostor to activate
  112681. */
  112682. wakeUpBody(impostor: PhysicsImpostor): void;
  112683. /**
  112684. * Updates the distance parameters of the joint
  112685. * @param joint joint to update
  112686. * @param maxDistance maximum distance of the joint
  112687. * @param minDistance minimum distance of the joint
  112688. */
  112689. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112690. /**
  112691. * Sets a motor on the joint
  112692. * @param joint joint to set motor on
  112693. * @param speed speed of the motor
  112694. * @param maxForce maximum force of the motor
  112695. * @param motorIndex index of the motor
  112696. */
  112697. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112698. /**
  112699. * Sets the motors limit
  112700. * @param joint joint to set limit on
  112701. * @param upperLimit upper limit
  112702. * @param lowerLimit lower limit
  112703. */
  112704. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112705. /**
  112706. * Syncs the position and rotation of a mesh with the impostor
  112707. * @param mesh mesh to sync
  112708. * @param impostor impostor to update the mesh with
  112709. */
  112710. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112711. /**
  112712. * Gets the radius of the impostor
  112713. * @param impostor impostor to get radius from
  112714. * @returns the radius
  112715. */
  112716. getRadius(impostor: PhysicsImpostor): number;
  112717. /**
  112718. * Gets the box size of the impostor
  112719. * @param impostor impostor to get box size from
  112720. * @param result the resulting box size
  112721. */
  112722. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112723. /**
  112724. * Disposes of the impostor
  112725. */
  112726. dispose(): void;
  112727. /**
  112728. * Does a raycast in the physics world
  112729. * @param from when should the ray start?
  112730. * @param to when should the ray end?
  112731. * @returns PhysicsRaycastResult
  112732. */
  112733. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112734. }
  112735. }
  112736. declare module BABYLON {
  112737. interface AbstractScene {
  112738. /**
  112739. * The list of reflection probes added to the scene
  112740. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112741. */
  112742. reflectionProbes: Array<ReflectionProbe>;
  112743. /**
  112744. * Removes the given reflection probe from this scene.
  112745. * @param toRemove The reflection probe to remove
  112746. * @returns The index of the removed reflection probe
  112747. */
  112748. removeReflectionProbe(toRemove: ReflectionProbe): number;
  112749. /**
  112750. * Adds the given reflection probe to this scene.
  112751. * @param newReflectionProbe The reflection probe to add
  112752. */
  112753. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  112754. }
  112755. /**
  112756. * Class used to generate realtime reflection / refraction cube textures
  112757. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112758. */
  112759. export class ReflectionProbe {
  112760. /** defines the name of the probe */
  112761. name: string;
  112762. private _scene;
  112763. private _renderTargetTexture;
  112764. private _projectionMatrix;
  112765. private _viewMatrix;
  112766. private _target;
  112767. private _add;
  112768. private _attachedMesh;
  112769. private _invertYAxis;
  112770. /** Gets or sets probe position (center of the cube map) */
  112771. position: Vector3;
  112772. /**
  112773. * Creates a new reflection probe
  112774. * @param name defines the name of the probe
  112775. * @param size defines the texture resolution (for each face)
  112776. * @param scene defines the hosting scene
  112777. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  112778. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  112779. */
  112780. constructor(
  112781. /** defines the name of the probe */
  112782. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  112783. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  112784. samples: number;
  112785. /** Gets or sets the refresh rate to use (on every frame by default) */
  112786. refreshRate: number;
  112787. /**
  112788. * Gets the hosting scene
  112789. * @returns a Scene
  112790. */
  112791. getScene(): Scene;
  112792. /** Gets the internal CubeTexture used to render to */
  112793. readonly cubeTexture: RenderTargetTexture;
  112794. /** Gets the list of meshes to render */
  112795. readonly renderList: Nullable<AbstractMesh[]>;
  112796. /**
  112797. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  112798. * @param mesh defines the mesh to attach to
  112799. */
  112800. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112801. /**
  112802. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  112803. * @param renderingGroupId The rendering group id corresponding to its index
  112804. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  112805. */
  112806. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  112807. /**
  112808. * Clean all associated resources
  112809. */
  112810. dispose(): void;
  112811. /**
  112812. * Converts the reflection probe information to a readable string for debug purpose.
  112813. * @param fullDetails Supports for multiple levels of logging within scene loading
  112814. * @returns the human readable reflection probe info
  112815. */
  112816. toString(fullDetails?: boolean): string;
  112817. /**
  112818. * Get the class name of the relfection probe.
  112819. * @returns "ReflectionProbe"
  112820. */
  112821. getClassName(): string;
  112822. /**
  112823. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  112824. * @returns The JSON representation of the texture
  112825. */
  112826. serialize(): any;
  112827. /**
  112828. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  112829. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  112830. * @param scene Define the scene the parsed reflection probe should be instantiated in
  112831. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  112832. * @returns The parsed reflection probe if successful
  112833. */
  112834. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  112835. }
  112836. }
  112837. declare module BABYLON {
  112838. /** @hidden */
  112839. export var _BabylonLoaderRegistered: boolean;
  112840. }
  112841. declare module BABYLON {
  112842. /**
  112843. * The Physically based simple base material of BJS.
  112844. *
  112845. * This enables better naming and convention enforcements on top of the pbrMaterial.
  112846. * It is used as the base class for both the specGloss and metalRough conventions.
  112847. */
  112848. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  112849. /**
  112850. * Number of Simultaneous lights allowed on the material.
  112851. */
  112852. maxSimultaneousLights: number;
  112853. /**
  112854. * If sets to true, disables all the lights affecting the material.
  112855. */
  112856. disableLighting: boolean;
  112857. /**
  112858. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  112859. */
  112860. environmentTexture: BaseTexture;
  112861. /**
  112862. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112863. */
  112864. invertNormalMapX: boolean;
  112865. /**
  112866. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112867. */
  112868. invertNormalMapY: boolean;
  112869. /**
  112870. * Normal map used in the model.
  112871. */
  112872. normalTexture: BaseTexture;
  112873. /**
  112874. * Emissivie color used to self-illuminate the model.
  112875. */
  112876. emissiveColor: Color3;
  112877. /**
  112878. * Emissivie texture used to self-illuminate the model.
  112879. */
  112880. emissiveTexture: BaseTexture;
  112881. /**
  112882. * Occlusion Channel Strenght.
  112883. */
  112884. occlusionStrength: number;
  112885. /**
  112886. * Occlusion Texture of the material (adding extra occlusion effects).
  112887. */
  112888. occlusionTexture: BaseTexture;
  112889. /**
  112890. * Defines the alpha limits in alpha test mode.
  112891. */
  112892. alphaCutOff: number;
  112893. /**
  112894. * Gets the current double sided mode.
  112895. */
  112896. /**
  112897. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112898. */
  112899. doubleSided: boolean;
  112900. /**
  112901. * Stores the pre-calculated light information of a mesh in a texture.
  112902. */
  112903. lightmapTexture: BaseTexture;
  112904. /**
  112905. * If true, the light map contains occlusion information instead of lighting info.
  112906. */
  112907. useLightmapAsShadowmap: boolean;
  112908. /**
  112909. * Instantiates a new PBRMaterial instance.
  112910. *
  112911. * @param name The material name
  112912. * @param scene The scene the material will be use in.
  112913. */
  112914. constructor(name: string, scene: Scene);
  112915. getClassName(): string;
  112916. }
  112917. }
  112918. declare module BABYLON {
  112919. /**
  112920. * The PBR material of BJS following the metal roughness convention.
  112921. *
  112922. * This fits to the PBR convention in the GLTF definition:
  112923. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112924. */
  112925. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112926. /**
  112927. * The base color has two different interpretations depending on the value of metalness.
  112928. * When the material is a metal, the base color is the specific measured reflectance value
  112929. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112930. * of the material.
  112931. */
  112932. baseColor: Color3;
  112933. /**
  112934. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112935. * well as opacity information in the alpha channel.
  112936. */
  112937. baseTexture: BaseTexture;
  112938. /**
  112939. * Specifies the metallic scalar value of the material.
  112940. * Can also be used to scale the metalness values of the metallic texture.
  112941. */
  112942. metallic: number;
  112943. /**
  112944. * Specifies the roughness scalar value of the material.
  112945. * Can also be used to scale the roughness values of the metallic texture.
  112946. */
  112947. roughness: number;
  112948. /**
  112949. * Texture containing both the metallic value in the B channel and the
  112950. * roughness value in the G channel to keep better precision.
  112951. */
  112952. metallicRoughnessTexture: BaseTexture;
  112953. /**
  112954. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112955. *
  112956. * @param name The material name
  112957. * @param scene The scene the material will be use in.
  112958. */
  112959. constructor(name: string, scene: Scene);
  112960. /**
  112961. * Return the currrent class name of the material.
  112962. */
  112963. getClassName(): string;
  112964. /**
  112965. * Makes a duplicate of the current material.
  112966. * @param name - name to use for the new material.
  112967. */
  112968. clone(name: string): PBRMetallicRoughnessMaterial;
  112969. /**
  112970. * Serialize the material to a parsable JSON object.
  112971. */
  112972. serialize(): any;
  112973. /**
  112974. * Parses a JSON object correponding to the serialize function.
  112975. */
  112976. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112977. }
  112978. }
  112979. declare module BABYLON {
  112980. /**
  112981. * The PBR material of BJS following the specular glossiness convention.
  112982. *
  112983. * This fits to the PBR convention in the GLTF definition:
  112984. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112985. */
  112986. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112987. /**
  112988. * Specifies the diffuse color of the material.
  112989. */
  112990. diffuseColor: Color3;
  112991. /**
  112992. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112993. * channel.
  112994. */
  112995. diffuseTexture: BaseTexture;
  112996. /**
  112997. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112998. */
  112999. specularColor: Color3;
  113000. /**
  113001. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  113002. */
  113003. glossiness: number;
  113004. /**
  113005. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  113006. */
  113007. specularGlossinessTexture: BaseTexture;
  113008. /**
  113009. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  113010. *
  113011. * @param name The material name
  113012. * @param scene The scene the material will be use in.
  113013. */
  113014. constructor(name: string, scene: Scene);
  113015. /**
  113016. * Return the currrent class name of the material.
  113017. */
  113018. getClassName(): string;
  113019. /**
  113020. * Makes a duplicate of the current material.
  113021. * @param name - name to use for the new material.
  113022. */
  113023. clone(name: string): PBRSpecularGlossinessMaterial;
  113024. /**
  113025. * Serialize the material to a parsable JSON object.
  113026. */
  113027. serialize(): any;
  113028. /**
  113029. * Parses a JSON object correponding to the serialize function.
  113030. */
  113031. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  113032. }
  113033. }
  113034. declare module BABYLON {
  113035. /**
  113036. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  113037. * It can help converting any input color in a desired output one. This can then be used to create effects
  113038. * from sepia, black and white to sixties or futuristic rendering...
  113039. *
  113040. * The only supported format is currently 3dl.
  113041. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  113042. */
  113043. export class ColorGradingTexture extends BaseTexture {
  113044. /**
  113045. * The current texture matrix. (will always be identity in color grading texture)
  113046. */
  113047. private _textureMatrix;
  113048. /**
  113049. * The texture URL.
  113050. */
  113051. url: string;
  113052. /**
  113053. * Empty line regex stored for GC.
  113054. */
  113055. private static _noneEmptyLineRegex;
  113056. private _engine;
  113057. /**
  113058. * Instantiates a ColorGradingTexture from the following parameters.
  113059. *
  113060. * @param url The location of the color gradind data (currently only supporting 3dl)
  113061. * @param scene The scene the texture will be used in
  113062. */
  113063. constructor(url: string, scene: Scene);
  113064. /**
  113065. * Returns the texture matrix used in most of the material.
  113066. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  113067. */
  113068. getTextureMatrix(): Matrix;
  113069. /**
  113070. * Occurs when the file being loaded is a .3dl LUT file.
  113071. */
  113072. private load3dlTexture;
  113073. /**
  113074. * Starts the loading process of the texture.
  113075. */
  113076. private loadTexture;
  113077. /**
  113078. * Clones the color gradind texture.
  113079. */
  113080. clone(): ColorGradingTexture;
  113081. /**
  113082. * Called during delayed load for textures.
  113083. */
  113084. delayLoad(): void;
  113085. /**
  113086. * Parses a color grading texture serialized by Babylon.
  113087. * @param parsedTexture The texture information being parsedTexture
  113088. * @param scene The scene to load the texture in
  113089. * @param rootUrl The root url of the data assets to load
  113090. * @return A color gradind texture
  113091. */
  113092. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  113093. /**
  113094. * Serializes the LUT texture to json format.
  113095. */
  113096. serialize(): any;
  113097. }
  113098. }
  113099. declare module BABYLON {
  113100. /**
  113101. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  113102. */
  113103. export class EquiRectangularCubeTexture extends BaseTexture {
  113104. /** The six faces of the cube. */
  113105. private static _FacesMapping;
  113106. private _noMipmap;
  113107. private _onLoad;
  113108. private _onError;
  113109. /** The size of the cubemap. */
  113110. private _size;
  113111. /** The buffer of the image. */
  113112. private _buffer;
  113113. /** The width of the input image. */
  113114. private _width;
  113115. /** The height of the input image. */
  113116. private _height;
  113117. /** The URL to the image. */
  113118. url: string;
  113119. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  113120. coordinatesMode: number;
  113121. /**
  113122. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  113123. * @param url The location of the image
  113124. * @param scene The scene the texture will be used in
  113125. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  113126. * @param noMipmap Forces to not generate the mipmap if true
  113127. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  113128. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  113129. * @param onLoad — defines a callback called when texture is loaded
  113130. * @param onError — defines a callback called if there is an error
  113131. */
  113132. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  113133. /**
  113134. * Load the image data, by putting the image on a canvas and extracting its buffer.
  113135. */
  113136. private loadImage;
  113137. /**
  113138. * Convert the image buffer into a cubemap and create a CubeTexture.
  113139. */
  113140. private loadTexture;
  113141. /**
  113142. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  113143. * @param buffer The ArrayBuffer that should be converted.
  113144. * @returns The buffer as Float32Array.
  113145. */
  113146. private getFloat32ArrayFromArrayBuffer;
  113147. /**
  113148. * Get the current class name of the texture useful for serialization or dynamic coding.
  113149. * @returns "EquiRectangularCubeTexture"
  113150. */
  113151. getClassName(): string;
  113152. /**
  113153. * Create a clone of the current EquiRectangularCubeTexture and return it.
  113154. * @returns A clone of the current EquiRectangularCubeTexture.
  113155. */
  113156. clone(): EquiRectangularCubeTexture;
  113157. }
  113158. }
  113159. declare module BABYLON {
  113160. /**
  113161. * Based on jsTGALoader - Javascript loader for TGA file
  113162. * By Vincent Thibault
  113163. * @see http://blog.robrowser.com/javascript-tga-loader.html
  113164. */
  113165. export class TGATools {
  113166. private static _TYPE_INDEXED;
  113167. private static _TYPE_RGB;
  113168. private static _TYPE_GREY;
  113169. private static _TYPE_RLE_INDEXED;
  113170. private static _TYPE_RLE_RGB;
  113171. private static _TYPE_RLE_GREY;
  113172. private static _ORIGIN_MASK;
  113173. private static _ORIGIN_SHIFT;
  113174. private static _ORIGIN_BL;
  113175. private static _ORIGIN_BR;
  113176. private static _ORIGIN_UL;
  113177. private static _ORIGIN_UR;
  113178. /**
  113179. * Gets the header of a TGA file
  113180. * @param data defines the TGA data
  113181. * @returns the header
  113182. */
  113183. static GetTGAHeader(data: Uint8Array): any;
  113184. /**
  113185. * Uploads TGA content to a Babylon Texture
  113186. * @hidden
  113187. */
  113188. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  113189. /** @hidden */
  113190. 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;
  113191. /** @hidden */
  113192. 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;
  113193. /** @hidden */
  113194. 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;
  113195. /** @hidden */
  113196. 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;
  113197. /** @hidden */
  113198. 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;
  113199. /** @hidden */
  113200. 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;
  113201. }
  113202. }
  113203. declare module BABYLON {
  113204. /**
  113205. * Implementation of the TGA Texture Loader.
  113206. * @hidden
  113207. */
  113208. export class _TGATextureLoader implements IInternalTextureLoader {
  113209. /**
  113210. * Defines wether the loader supports cascade loading the different faces.
  113211. */
  113212. readonly supportCascades: boolean;
  113213. /**
  113214. * This returns if the loader support the current file information.
  113215. * @param extension defines the file extension of the file being loaded
  113216. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113217. * @param fallback defines the fallback internal texture if any
  113218. * @param isBase64 defines whether the texture is encoded as a base64
  113219. * @param isBuffer defines whether the texture data are stored as a buffer
  113220. * @returns true if the loader can load the specified file
  113221. */
  113222. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113223. /**
  113224. * Transform the url before loading if required.
  113225. * @param rootUrl the url of the texture
  113226. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113227. * @returns the transformed texture
  113228. */
  113229. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113230. /**
  113231. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113232. * @param rootUrl the url of the texture
  113233. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113234. * @returns the fallback texture
  113235. */
  113236. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113237. /**
  113238. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113239. * @param data contains the texture data
  113240. * @param texture defines the BabylonJS internal texture
  113241. * @param createPolynomials will be true if polynomials have been requested
  113242. * @param onLoad defines the callback to trigger once the texture is ready
  113243. * @param onError defines the callback to trigger in case of error
  113244. */
  113245. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113246. /**
  113247. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113248. * @param data contains the texture data
  113249. * @param texture defines the BabylonJS internal texture
  113250. * @param callback defines the method to call once ready to upload
  113251. */
  113252. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113253. }
  113254. }
  113255. declare module BABYLON {
  113256. /**
  113257. * Info about the .basis files
  113258. */
  113259. class BasisFileInfo {
  113260. /**
  113261. * If the file has alpha
  113262. */
  113263. hasAlpha: boolean;
  113264. /**
  113265. * Info about each image of the basis file
  113266. */
  113267. images: Array<{
  113268. levels: Array<{
  113269. width: number;
  113270. height: number;
  113271. transcodedPixels: ArrayBufferView;
  113272. }>;
  113273. }>;
  113274. }
  113275. /**
  113276. * Result of transcoding a basis file
  113277. */
  113278. class TranscodeResult {
  113279. /**
  113280. * Info about the .basis file
  113281. */
  113282. fileInfo: BasisFileInfo;
  113283. /**
  113284. * Format to use when loading the file
  113285. */
  113286. format: number;
  113287. }
  113288. /**
  113289. * Configuration options for the Basis transcoder
  113290. */
  113291. export class BasisTranscodeConfiguration {
  113292. /**
  113293. * Supported compression formats used to determine the supported output format of the transcoder
  113294. */
  113295. supportedCompressionFormats?: {
  113296. /**
  113297. * etc1 compression format
  113298. */
  113299. etc1?: boolean;
  113300. /**
  113301. * s3tc compression format
  113302. */
  113303. s3tc?: boolean;
  113304. /**
  113305. * pvrtc compression format
  113306. */
  113307. pvrtc?: boolean;
  113308. /**
  113309. * etc2 compression format
  113310. */
  113311. etc2?: boolean;
  113312. };
  113313. /**
  113314. * If mipmap levels should be loaded for transcoded images (Default: true)
  113315. */
  113316. loadMipmapLevels?: boolean;
  113317. /**
  113318. * Index of a single image to load (Default: all images)
  113319. */
  113320. loadSingleImage?: number;
  113321. }
  113322. /**
  113323. * Used to load .Basis files
  113324. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  113325. */
  113326. export class BasisTools {
  113327. private static _IgnoreSupportedFormats;
  113328. /**
  113329. * URL to use when loading the basis transcoder
  113330. */
  113331. static JSModuleURL: string;
  113332. /**
  113333. * URL to use when loading the wasm module for the transcoder
  113334. */
  113335. static WasmModuleURL: string;
  113336. /**
  113337. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  113338. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  113339. * @returns internal format corresponding to the Basis format
  113340. */
  113341. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  113342. private static _WorkerPromise;
  113343. private static _Worker;
  113344. private static _actionId;
  113345. private static _CreateWorkerAsync;
  113346. /**
  113347. * Transcodes a loaded image file to compressed pixel data
  113348. * @param imageData image data to transcode
  113349. * @param config configuration options for the transcoding
  113350. * @returns a promise resulting in the transcoded image
  113351. */
  113352. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  113353. /**
  113354. * Loads a texture from the transcode result
  113355. * @param texture texture load to
  113356. * @param transcodeResult the result of transcoding the basis file to load from
  113357. */
  113358. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  113359. }
  113360. }
  113361. declare module BABYLON {
  113362. /**
  113363. * Loader for .basis file format
  113364. */
  113365. export class _BasisTextureLoader implements IInternalTextureLoader {
  113366. /**
  113367. * Defines whether the loader supports cascade loading the different faces.
  113368. */
  113369. readonly supportCascades: boolean;
  113370. /**
  113371. * This returns if the loader support the current file information.
  113372. * @param extension defines the file extension of the file being loaded
  113373. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113374. * @param fallback defines the fallback internal texture if any
  113375. * @param isBase64 defines whether the texture is encoded as a base64
  113376. * @param isBuffer defines whether the texture data are stored as a buffer
  113377. * @returns true if the loader can load the specified file
  113378. */
  113379. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113380. /**
  113381. * Transform the url before loading if required.
  113382. * @param rootUrl the url of the texture
  113383. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113384. * @returns the transformed texture
  113385. */
  113386. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113387. /**
  113388. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113389. * @param rootUrl the url of the texture
  113390. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113391. * @returns the fallback texture
  113392. */
  113393. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113394. /**
  113395. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  113396. * @param data contains the texture data
  113397. * @param texture defines the BabylonJS internal texture
  113398. * @param createPolynomials will be true if polynomials have been requested
  113399. * @param onLoad defines the callback to trigger once the texture is ready
  113400. * @param onError defines the callback to trigger in case of error
  113401. */
  113402. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113403. /**
  113404. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113405. * @param data contains the texture data
  113406. * @param texture defines the BabylonJS internal texture
  113407. * @param callback defines the method to call once ready to upload
  113408. */
  113409. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113410. }
  113411. }
  113412. declare module BABYLON {
  113413. /**
  113414. * 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.
  113415. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113416. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113417. */
  113418. export class CustomProceduralTexture extends ProceduralTexture {
  113419. private _animate;
  113420. private _time;
  113421. private _config;
  113422. private _texturePath;
  113423. /**
  113424. * Instantiates a new Custom Procedural Texture.
  113425. * 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.
  113426. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113427. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113428. * @param name Define the name of the texture
  113429. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  113430. * @param size Define the size of the texture to create
  113431. * @param scene Define the scene the texture belongs to
  113432. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  113433. * @param generateMipMaps Define if the texture should creates mip maps or not
  113434. */
  113435. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113436. private _loadJson;
  113437. /**
  113438. * Is the texture ready to be used ? (rendered at least once)
  113439. * @returns true if ready, otherwise, false.
  113440. */
  113441. isReady(): boolean;
  113442. /**
  113443. * Render the texture to its associated render target.
  113444. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  113445. */
  113446. render(useCameraPostProcess?: boolean): void;
  113447. /**
  113448. * Update the list of dependant textures samplers in the shader.
  113449. */
  113450. updateTextures(): void;
  113451. /**
  113452. * Update the uniform values of the procedural texture in the shader.
  113453. */
  113454. updateShaderUniforms(): void;
  113455. /**
  113456. * Define if the texture animates or not.
  113457. */
  113458. animate: boolean;
  113459. }
  113460. }
  113461. declare module BABYLON {
  113462. /** @hidden */
  113463. export var noisePixelShader: {
  113464. name: string;
  113465. shader: string;
  113466. };
  113467. }
  113468. declare module BABYLON {
  113469. /**
  113470. * Class used to generate noise procedural textures
  113471. */
  113472. export class NoiseProceduralTexture extends ProceduralTexture {
  113473. private _time;
  113474. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  113475. brightness: number;
  113476. /** Defines the number of octaves to process */
  113477. octaves: number;
  113478. /** Defines the level of persistence (0.8 by default) */
  113479. persistence: number;
  113480. /** Gets or sets animation speed factor (default is 1) */
  113481. animationSpeedFactor: number;
  113482. /**
  113483. * Creates a new NoiseProceduralTexture
  113484. * @param name defines the name fo the texture
  113485. * @param size defines the size of the texture (default is 256)
  113486. * @param scene defines the hosting scene
  113487. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  113488. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  113489. */
  113490. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113491. private _updateShaderUniforms;
  113492. protected _getDefines(): string;
  113493. /** Generate the current state of the procedural texture */
  113494. render(useCameraPostProcess?: boolean): void;
  113495. /**
  113496. * Serializes this noise procedural texture
  113497. * @returns a serialized noise procedural texture object
  113498. */
  113499. serialize(): any;
  113500. /**
  113501. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  113502. * @param parsedTexture defines parsed texture data
  113503. * @param scene defines the current scene
  113504. * @param rootUrl defines the root URL containing noise procedural texture information
  113505. * @returns a parsed NoiseProceduralTexture
  113506. */
  113507. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  113508. }
  113509. }
  113510. declare module BABYLON {
  113511. /**
  113512. * Raw cube texture where the raw buffers are passed in
  113513. */
  113514. export class RawCubeTexture extends CubeTexture {
  113515. /**
  113516. * Creates a cube texture where the raw buffers are passed in.
  113517. * @param scene defines the scene the texture is attached to
  113518. * @param data defines the array of data to use to create each face
  113519. * @param size defines the size of the textures
  113520. * @param format defines the format of the data
  113521. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  113522. * @param generateMipMaps defines if the engine should generate the mip levels
  113523. * @param invertY defines if data must be stored with Y axis inverted
  113524. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  113525. * @param compression defines the compression used (null by default)
  113526. */
  113527. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  113528. /**
  113529. * Updates the raw cube texture.
  113530. * @param data defines the data to store
  113531. * @param format defines the data format
  113532. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113533. * @param invertY defines if data must be stored with Y axis inverted
  113534. * @param compression defines the compression used (null by default)
  113535. * @param level defines which level of the texture to update
  113536. */
  113537. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  113538. /**
  113539. * Updates a raw cube texture with RGBD encoded data.
  113540. * @param data defines the array of data [mipmap][face] to use to create each face
  113541. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  113542. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113543. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113544. * @returns a promsie that resolves when the operation is complete
  113545. */
  113546. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  113547. /**
  113548. * Clones the raw cube texture.
  113549. * @return a new cube texture
  113550. */
  113551. clone(): CubeTexture;
  113552. /** @hidden */
  113553. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113554. }
  113555. }
  113556. declare module BABYLON {
  113557. /**
  113558. * Class used to store 3D textures containing user data
  113559. */
  113560. export class RawTexture3D extends Texture {
  113561. /** Gets or sets the texture format to use */
  113562. format: number;
  113563. private _engine;
  113564. /**
  113565. * Create a new RawTexture3D
  113566. * @param data defines the data of the texture
  113567. * @param width defines the width of the texture
  113568. * @param height defines the height of the texture
  113569. * @param depth defines the depth of the texture
  113570. * @param format defines the texture format to use
  113571. * @param scene defines the hosting scene
  113572. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  113573. * @param invertY defines if texture must be stored with Y axis inverted
  113574. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  113575. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  113576. */
  113577. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  113578. /** Gets or sets the texture format to use */
  113579. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  113580. /**
  113581. * Update the texture with new data
  113582. * @param data defines the data to store in the texture
  113583. */
  113584. update(data: ArrayBufferView): void;
  113585. }
  113586. }
  113587. declare module BABYLON {
  113588. /**
  113589. * Creates a refraction texture used by refraction channel of the standard material.
  113590. * It is like a mirror but to see through a material.
  113591. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113592. */
  113593. export class RefractionTexture extends RenderTargetTexture {
  113594. /**
  113595. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  113596. * 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.
  113597. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113598. */
  113599. refractionPlane: Plane;
  113600. /**
  113601. * Define how deep under the surface we should see.
  113602. */
  113603. depth: number;
  113604. /**
  113605. * Creates a refraction texture used by refraction channel of the standard material.
  113606. * It is like a mirror but to see through a material.
  113607. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113608. * @param name Define the texture name
  113609. * @param size Define the size of the underlying texture
  113610. * @param scene Define the scene the refraction belongs to
  113611. * @param generateMipMaps Define if we need to generate mips level for the refraction
  113612. */
  113613. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  113614. /**
  113615. * Clone the refraction texture.
  113616. * @returns the cloned texture
  113617. */
  113618. clone(): RefractionTexture;
  113619. /**
  113620. * Serialize the texture to a JSON representation you could use in Parse later on
  113621. * @returns the serialized JSON representation
  113622. */
  113623. serialize(): any;
  113624. }
  113625. }
  113626. declare module BABYLON {
  113627. /**
  113628. * Defines the options related to the creation of an HtmlElementTexture
  113629. */
  113630. export interface IHtmlElementTextureOptions {
  113631. /**
  113632. * Defines wether mip maps should be created or not.
  113633. */
  113634. generateMipMaps?: boolean;
  113635. /**
  113636. * Defines the sampling mode of the texture.
  113637. */
  113638. samplingMode?: number;
  113639. /**
  113640. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  113641. */
  113642. engine: Nullable<Engine>;
  113643. /**
  113644. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  113645. */
  113646. scene: Nullable<Scene>;
  113647. }
  113648. /**
  113649. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  113650. * To be as efficient as possible depending on your constraints nothing aside the first upload
  113651. * is automatically managed.
  113652. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  113653. * in your application.
  113654. *
  113655. * As the update is not automatic, you need to call them manually.
  113656. */
  113657. export class HtmlElementTexture extends BaseTexture {
  113658. /**
  113659. * The texture URL.
  113660. */
  113661. element: HTMLVideoElement | HTMLCanvasElement;
  113662. private static readonly DefaultOptions;
  113663. private _textureMatrix;
  113664. private _engine;
  113665. private _isVideo;
  113666. private _generateMipMaps;
  113667. private _samplingMode;
  113668. /**
  113669. * Instantiates a HtmlElementTexture from the following parameters.
  113670. *
  113671. * @param name Defines the name of the texture
  113672. * @param element Defines the video or canvas the texture is filled with
  113673. * @param options Defines the other none mandatory texture creation options
  113674. */
  113675. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  113676. private _createInternalTexture;
  113677. /**
  113678. * Returns the texture matrix used in most of the material.
  113679. */
  113680. getTextureMatrix(): Matrix;
  113681. /**
  113682. * Updates the content of the texture.
  113683. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  113684. */
  113685. update(invertY?: Nullable<boolean>): void;
  113686. }
  113687. }
  113688. declare module BABYLON {
  113689. /**
  113690. * Enum used to define the target of a block
  113691. */
  113692. export enum NodeMaterialBlockTargets {
  113693. /** Vertex shader */
  113694. Vertex = 1,
  113695. /** Fragment shader */
  113696. Fragment = 2,
  113697. /** Vertex and Fragment */
  113698. VertexAndFragment = 3
  113699. }
  113700. }
  113701. declare module BABYLON {
  113702. /**
  113703. * Defines the kind of connection point for node based material
  113704. */
  113705. export enum NodeMaterialBlockConnectionPointTypes {
  113706. /** Float */
  113707. Float = 1,
  113708. /** Int */
  113709. Int = 2,
  113710. /** Vector2 */
  113711. Vector2 = 4,
  113712. /** Vector3 */
  113713. Vector3 = 8,
  113714. /** Vector4 */
  113715. Vector4 = 16,
  113716. /** Color3 */
  113717. Color3 = 32,
  113718. /** Color4 */
  113719. Color4 = 64,
  113720. /** Matrix */
  113721. Matrix = 128,
  113722. /** Texture */
  113723. Texture = 256,
  113724. /** Texture3D */
  113725. Texture3D = 512,
  113726. /** Vector3 or Color3 */
  113727. Vector3OrColor3 = 40,
  113728. /** Vector3 or Vector4 */
  113729. Vector3OrVector4 = 24,
  113730. /** Vector4 or Color4 */
  113731. Vector4OrColor4 = 80,
  113732. /** Color3 or Color4 */
  113733. Color3OrColor4 = 96,
  113734. /** Vector3 or Color3 */
  113735. Vector3OrColor3OrVector4OrColor4 = 120,
  113736. /** Detect type based on connection */
  113737. AutoDetect = 1024,
  113738. /** Output type that will be defined by input type */
  113739. BasedOnInput = 2048,
  113740. /** Light */
  113741. Light = 4096
  113742. }
  113743. }
  113744. declare module BABYLON {
  113745. /**
  113746. * Enum used to define well known values e.g. values automatically provided by the system
  113747. */
  113748. export enum NodeMaterialWellKnownValues {
  113749. /** World */
  113750. World = 1,
  113751. /** View */
  113752. View = 2,
  113753. /** Projection */
  113754. Projection = 3,
  113755. /** ViewProjection */
  113756. ViewProjection = 4,
  113757. /** WorldView */
  113758. WorldView = 5,
  113759. /** WorldViewProjection */
  113760. WorldViewProjection = 6,
  113761. /** CameraPosition */
  113762. CameraPosition = 7,
  113763. /** Will be filled by the block itself */
  113764. Automatic = 8
  113765. }
  113766. }
  113767. declare module BABYLON {
  113768. /**
  113769. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  113770. */
  113771. export enum NodeMaterialBlockConnectionPointMode {
  113772. /** Value is an uniform */
  113773. Uniform = 0,
  113774. /** Value is a mesh attribute */
  113775. Attribute = 1,
  113776. /** Value is a varying between vertex and fragment shaders */
  113777. Varying = 2,
  113778. /** Mode is undefined */
  113779. Undefined = 3
  113780. }
  113781. }
  113782. declare module BABYLON {
  113783. /**
  113784. * Class used to store shared data between 2 NodeMaterialBuildState
  113785. */
  113786. export class NodeMaterialBuildStateSharedData {
  113787. /**
  113788. * Gets the list of emitted varyings
  113789. */
  113790. varyings: string[];
  113791. /**
  113792. * Gets the varying declaration string
  113793. */
  113794. varyingDeclaration: string;
  113795. /**
  113796. * Uniform connection points
  113797. */
  113798. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  113799. /**
  113800. * Bindable blocks (Blocks that need to set data to the effect)
  113801. */
  113802. bindableBlocks: NodeMaterialBlock[];
  113803. /**
  113804. * List of blocks that can provide a compilation fallback
  113805. */
  113806. blocksWithFallbacks: NodeMaterialBlock[];
  113807. /**
  113808. * List of blocks that can provide a define update
  113809. */
  113810. blocksWithDefines: NodeMaterialBlock[];
  113811. /**
  113812. * List of blocks that can provide a repeatable content
  113813. */
  113814. repeatableContentBlocks: NodeMaterialBlock[];
  113815. /**
  113816. * List of blocks that can provide a dynamic list of uniforms
  113817. */
  113818. dynamicUniformBlocks: NodeMaterialBlock[];
  113819. /**
  113820. * List of blocks that can block the isReady function for the material
  113821. */
  113822. blockingBlocks: NodeMaterialBlock[];
  113823. /**
  113824. * Build Id used to avoid multiple recompilations
  113825. */
  113826. buildId: number;
  113827. /** List of emitted variables */
  113828. variableNames: {
  113829. [key: string]: number;
  113830. };
  113831. /** List of emitted defines */
  113832. defineNames: {
  113833. [key: string]: number;
  113834. };
  113835. /** Should emit comments? */
  113836. emitComments: boolean;
  113837. /** Emit build activity */
  113838. verbose: boolean;
  113839. /**
  113840. * Gets the compilation hints emitted at compilation time
  113841. */
  113842. hints: {
  113843. needWorldViewMatrix: boolean;
  113844. needWorldViewProjectionMatrix: boolean;
  113845. needAlphaBlending: boolean;
  113846. needAlphaTesting: boolean;
  113847. };
  113848. /**
  113849. * List of compilation checks
  113850. */
  113851. checks: {
  113852. emitVertex: boolean;
  113853. emitFragment: boolean;
  113854. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  113855. };
  113856. /** Creates a new shared data */
  113857. constructor();
  113858. /**
  113859. * Emits console errors and exceptions if there is a failing check
  113860. */
  113861. emitErrors(): void;
  113862. }
  113863. }
  113864. declare module BABYLON {
  113865. /**
  113866. * Class used to store node based material build state
  113867. */
  113868. export class NodeMaterialBuildState {
  113869. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  113870. supportUniformBuffers: boolean;
  113871. /**
  113872. * Gets the list of emitted attributes
  113873. */
  113874. attributes: string[];
  113875. /**
  113876. * Gets the list of emitted uniforms
  113877. */
  113878. uniforms: string[];
  113879. /**
  113880. * Gets the list of emitted uniform buffers
  113881. */
  113882. uniformBuffers: string[];
  113883. /**
  113884. * Gets the list of emitted samplers
  113885. */
  113886. samplers: string[];
  113887. /**
  113888. * Gets the list of emitted functions
  113889. */
  113890. functions: {
  113891. [key: string]: string;
  113892. };
  113893. /**
  113894. * Gets the target of the compilation state
  113895. */
  113896. target: NodeMaterialBlockTargets;
  113897. /**
  113898. * Gets the list of emitted counters
  113899. */
  113900. counters: {
  113901. [key: string]: number;
  113902. };
  113903. /**
  113904. * Shared data between multiple NodeMaterialBuildState instances
  113905. */
  113906. sharedData: NodeMaterialBuildStateSharedData;
  113907. /** @hidden */
  113908. _vertexState: NodeMaterialBuildState;
  113909. private _attributeDeclaration;
  113910. private _uniformDeclaration;
  113911. private _samplerDeclaration;
  113912. private _varyingTransfer;
  113913. private _repeatableContentAnchorIndex;
  113914. /** @hidden */
  113915. _builtCompilationString: string;
  113916. /**
  113917. * Gets the emitted compilation strings
  113918. */
  113919. compilationString: string;
  113920. /**
  113921. * Finalize the compilation strings
  113922. * @param state defines the current compilation state
  113923. */
  113924. finalize(state: NodeMaterialBuildState): void;
  113925. /** @hidden */
  113926. readonly _repeatableContentAnchor: string;
  113927. /** @hidden */
  113928. _getFreeVariableName(prefix: string): string;
  113929. /** @hidden */
  113930. _getFreeDefineName(prefix: string): string;
  113931. /** @hidden */
  113932. _excludeVariableName(name: string): void;
  113933. /** @hidden */
  113934. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  113935. /** @hidden */
  113936. _emitFunction(name: string, code: string, comments: string): void;
  113937. /** @hidden */
  113938. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  113939. replaceStrings?: {
  113940. search: RegExp;
  113941. replace: string;
  113942. }[];
  113943. repeatKey?: string;
  113944. }): string;
  113945. /** @hidden */
  113946. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  113947. repeatKey?: string;
  113948. removeAttributes?: boolean;
  113949. removeUniforms?: boolean;
  113950. removeVaryings?: boolean;
  113951. removeIfDef?: boolean;
  113952. replaceStrings?: {
  113953. search: RegExp;
  113954. replace: string;
  113955. }[];
  113956. }, storeKey?: string): void;
  113957. /** @hidden */
  113958. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  113959. private _emitDefine;
  113960. /** @hidden */
  113961. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  113962. }
  113963. }
  113964. declare module BABYLON {
  113965. /**
  113966. * Root class for all node material optimizers
  113967. */
  113968. export class NodeMaterialOptimizer {
  113969. /**
  113970. * Function used to optimize a NodeMaterial graph
  113971. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  113972. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  113973. */
  113974. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  113975. }
  113976. }
  113977. declare module BABYLON {
  113978. /**
  113979. * Block used to transform a vector4 with a matrix
  113980. */
  113981. export class Vector4TransformBlock extends NodeMaterialBlock {
  113982. /**
  113983. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113984. */
  113985. complementW: number;
  113986. /**
  113987. * Creates a new Vector4TransformBlock
  113988. * @param name defines the block name
  113989. */
  113990. constructor(name: string);
  113991. /**
  113992. * Gets the current class name
  113993. * @returns the class name
  113994. */
  113995. getClassName(): string;
  113996. /**
  113997. * Gets the vector input
  113998. */
  113999. readonly vector: NodeMaterialConnectionPoint;
  114000. /**
  114001. * Gets the output component
  114002. */
  114003. readonly output: NodeMaterialConnectionPoint;
  114004. /**
  114005. * Gets the matrix transform input
  114006. */
  114007. readonly transform: NodeMaterialConnectionPoint;
  114008. protected _buildBlock(state: NodeMaterialBuildState): this;
  114009. }
  114010. }
  114011. declare module BABYLON {
  114012. /**
  114013. * Block used to output the vertex position
  114014. */
  114015. export class VertexOutputBlock extends NodeMaterialBlock {
  114016. /**
  114017. * Creates a new VertexOutputBlock
  114018. * @param name defines the block name
  114019. */
  114020. constructor(name: string);
  114021. /**
  114022. * Gets the current class name
  114023. * @returns the class name
  114024. */
  114025. getClassName(): string;
  114026. /**
  114027. * Gets the vector input component
  114028. */
  114029. readonly vector: NodeMaterialConnectionPoint;
  114030. protected _buildBlock(state: NodeMaterialBuildState): this;
  114031. }
  114032. }
  114033. declare module BABYLON {
  114034. /**
  114035. * Block used to output the final color
  114036. */
  114037. export class FragmentOutputBlock extends NodeMaterialBlock {
  114038. /**
  114039. * Gets or sets a boolean indicating if this block will output an alpha value
  114040. */
  114041. alphaBlendingEnabled: boolean;
  114042. /**
  114043. * Create a new FragmentOutputBlock
  114044. * @param name defines the block name
  114045. */
  114046. constructor(name: string);
  114047. /**
  114048. * Gets the current class name
  114049. * @returns the class name
  114050. */
  114051. getClassName(): string;
  114052. /**
  114053. * Gets the color input component
  114054. */
  114055. readonly color: NodeMaterialConnectionPoint;
  114056. protected _buildBlock(state: NodeMaterialBuildState): this;
  114057. }
  114058. }
  114059. declare module BABYLON {
  114060. /**
  114061. * Interface used to configure the node material editor
  114062. */
  114063. export interface INodeMaterialEditorOptions {
  114064. /** Define the URl to load node editor script */
  114065. editorURL?: string;
  114066. }
  114067. /** @hidden */
  114068. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  114069. /** BONES */
  114070. NUM_BONE_INFLUENCERS: number;
  114071. BonesPerMesh: number;
  114072. BONETEXTURE: boolean;
  114073. /** MORPH TARGETS */
  114074. MORPHTARGETS: boolean;
  114075. MORPHTARGETS_NORMAL: boolean;
  114076. MORPHTARGETS_TANGENT: boolean;
  114077. MORPHTARGETS_UV: boolean;
  114078. NUM_MORPH_INFLUENCERS: number;
  114079. /** IMAGE PROCESSING */
  114080. IMAGEPROCESSING: boolean;
  114081. VIGNETTE: boolean;
  114082. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114083. VIGNETTEBLENDMODEOPAQUE: boolean;
  114084. TONEMAPPING: boolean;
  114085. TONEMAPPING_ACES: boolean;
  114086. CONTRAST: boolean;
  114087. EXPOSURE: boolean;
  114088. COLORCURVES: boolean;
  114089. COLORGRADING: boolean;
  114090. COLORGRADING3D: boolean;
  114091. SAMPLER3DGREENDEPTH: boolean;
  114092. SAMPLER3DBGRMAP: boolean;
  114093. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114094. constructor();
  114095. setValue(name: string, value: boolean): void;
  114096. }
  114097. /**
  114098. * Class used to configure NodeMaterial
  114099. */
  114100. export interface INodeMaterialOptions {
  114101. /**
  114102. * Defines if blocks should emit comments
  114103. */
  114104. emitComments: boolean;
  114105. }
  114106. /**
  114107. * Class used to create a node based material built by assembling shader blocks
  114108. */
  114109. export class NodeMaterial extends PushMaterial {
  114110. private _options;
  114111. private _vertexCompilationState;
  114112. private _fragmentCompilationState;
  114113. private _sharedData;
  114114. private _buildId;
  114115. private _buildWasSuccessful;
  114116. private _cachedWorldViewMatrix;
  114117. private _cachedWorldViewProjectionMatrix;
  114118. private _textureConnectionPoints;
  114119. private _optimizers;
  114120. /** Define the URl to load node editor script */
  114121. static EditorURL: string;
  114122. private BJSNODEMATERIALEDITOR;
  114123. /** Get the inspector from bundle or global */
  114124. private _getGlobalNodeMaterialEditor;
  114125. /**
  114126. * Defines the maximum number of lights that can be used in the material
  114127. */
  114128. maxSimultaneousLights: number;
  114129. /**
  114130. * Observable raised when the material is built
  114131. */
  114132. onBuildObservable: Observable<NodeMaterial>;
  114133. /**
  114134. * Gets or sets the root nodes of the material vertex shader
  114135. */
  114136. _vertexOutputNodes: NodeMaterialBlock[];
  114137. /**
  114138. * Gets or sets the root nodes of the material fragment (pixel) shader
  114139. */
  114140. _fragmentOutputNodes: NodeMaterialBlock[];
  114141. /** Gets or sets options to control the node material overall behavior */
  114142. options: INodeMaterialOptions;
  114143. /**
  114144. * Default configuration related to image processing available in the standard Material.
  114145. */
  114146. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114147. /**
  114148. * Gets the image processing configuration used either in this material.
  114149. */
  114150. /**
  114151. * Sets the Default image processing configuration used either in the this material.
  114152. *
  114153. * If sets to null, the scene one is in use.
  114154. */
  114155. imageProcessingConfiguration: ImageProcessingConfiguration;
  114156. /**
  114157. * Create a new node based material
  114158. * @param name defines the material name
  114159. * @param scene defines the hosting scene
  114160. * @param options defines creation option
  114161. */
  114162. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  114163. /**
  114164. * Gets the current class name of the material e.g. "NodeMaterial"
  114165. * @returns the class name
  114166. */
  114167. getClassName(): string;
  114168. /**
  114169. * Keep track of the image processing observer to allow dispose and replace.
  114170. */
  114171. private _imageProcessingObserver;
  114172. /**
  114173. * Attaches a new image processing configuration to the Standard Material.
  114174. * @param configuration
  114175. */
  114176. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114177. /**
  114178. * Adds a new optimizer to the list of optimizers
  114179. * @param optimizer defines the optimizers to add
  114180. * @returns the current material
  114181. */
  114182. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  114183. /**
  114184. * Remove an optimizer from the list of optimizers
  114185. * @param optimizer defines the optimizers to remove
  114186. * @returns the current material
  114187. */
  114188. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  114189. /**
  114190. * Add a new block to the list of output nodes
  114191. * @param node defines the node to add
  114192. * @returns the current material
  114193. */
  114194. addOutputNode(node: NodeMaterialBlock): this;
  114195. /**
  114196. * Remove a block from the list of root nodes
  114197. * @param node defines the node to remove
  114198. * @returns the current material
  114199. */
  114200. removeOutputNode(node: NodeMaterialBlock): this;
  114201. private _addVertexOutputNode;
  114202. private _removeVertexOutputNode;
  114203. private _addFragmentOutputNode;
  114204. private _removeFragmentOutputNode;
  114205. /**
  114206. * Specifies if the material will require alpha blending
  114207. * @returns a boolean specifying if alpha blending is needed
  114208. */
  114209. needAlphaBlending(): boolean;
  114210. /**
  114211. * Specifies if this material should be rendered in alpha test mode
  114212. * @returns a boolean specifying if an alpha test is needed.
  114213. */
  114214. needAlphaTesting(): boolean;
  114215. private _initializeBlock;
  114216. private _resetDualBlocks;
  114217. /**
  114218. * Build the material and generates the inner effect
  114219. * @param verbose defines if the build should log activity
  114220. */
  114221. build(verbose?: boolean): void;
  114222. /**
  114223. * Runs an otpimization phase to try to improve the shader code
  114224. */
  114225. optimize(): void;
  114226. private _prepareDefinesForAttributes;
  114227. /**
  114228. * Get if the submesh is ready to be used and all its information available.
  114229. * Child classes can use it to update shaders
  114230. * @param mesh defines the mesh to check
  114231. * @param subMesh defines which submesh to check
  114232. * @param useInstances specifies that instances should be used
  114233. * @returns a boolean indicating that the submesh is ready or not
  114234. */
  114235. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114236. /**
  114237. * Binds the world matrix to the material
  114238. * @param world defines the world transformation matrix
  114239. */
  114240. bindOnlyWorldMatrix(world: Matrix): void;
  114241. /**
  114242. * Binds the submesh to this material by preparing the effect and shader to draw
  114243. * @param world defines the world transformation matrix
  114244. * @param mesh defines the mesh containing the submesh
  114245. * @param subMesh defines the submesh to bind the material to
  114246. */
  114247. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114248. /**
  114249. * Gets the active textures from the material
  114250. * @returns an array of textures
  114251. */
  114252. getActiveTextures(): BaseTexture[];
  114253. /**
  114254. * Specifies if the material uses a texture
  114255. * @param texture defines the texture to check against the material
  114256. * @returns a boolean specifying if the material uses the texture
  114257. */
  114258. hasTexture(texture: BaseTexture): boolean;
  114259. /**
  114260. * Disposes the material
  114261. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  114262. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  114263. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  114264. */
  114265. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  114266. /** Creates the node editor window. */
  114267. private _createNodeEditor;
  114268. /**
  114269. * Launch the node material editor
  114270. * @param config Define the configuration of the editor
  114271. * @return a promise fulfilled when the node editor is visible
  114272. */
  114273. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  114274. /**
  114275. * Clear the current material
  114276. */
  114277. clear(): void;
  114278. /**
  114279. * Clear the current material and set it to a default state
  114280. */
  114281. setToDefault(): void;
  114282. }
  114283. }
  114284. declare module BABYLON {
  114285. /**
  114286. * Defines a block that can be used inside a node based material
  114287. */
  114288. export class NodeMaterialBlock {
  114289. private _buildId;
  114290. private _target;
  114291. private _isFinalMerger;
  114292. /** @hidden */
  114293. _inputs: NodeMaterialConnectionPoint[];
  114294. /** @hidden */
  114295. _outputs: NodeMaterialConnectionPoint[];
  114296. /**
  114297. * Gets or sets the name of the block
  114298. */
  114299. name: string;
  114300. /**
  114301. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  114302. */
  114303. readonly isFinalMerger: boolean;
  114304. /**
  114305. * Gets or sets the build Id
  114306. */
  114307. buildId: number;
  114308. /**
  114309. * Gets or sets the target of the block
  114310. */
  114311. target: NodeMaterialBlockTargets;
  114312. /**
  114313. * Gets the list of input points
  114314. */
  114315. readonly inputs: NodeMaterialConnectionPoint[];
  114316. /** Gets the list of output points */
  114317. readonly outputs: NodeMaterialConnectionPoint[];
  114318. /**
  114319. * Find an input by its name
  114320. * @param name defines the name of the input to look for
  114321. * @returns the input or null if not found
  114322. */
  114323. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114324. /**
  114325. * Find an output by its name
  114326. * @param name defines the name of the outputto look for
  114327. * @returns the output or null if not found
  114328. */
  114329. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114330. /**
  114331. * Creates a new NodeMaterialBlock
  114332. * @param name defines the block name
  114333. * @param target defines the target of that block (Vertex by default)
  114334. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  114335. */
  114336. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  114337. /**
  114338. * Initialize the block and prepare the context for build
  114339. * @param state defines the state that will be used for the build
  114340. */
  114341. initialize(state: NodeMaterialBuildState): void;
  114342. /**
  114343. * Bind data to effect. Will only be called for blocks with isBindable === true
  114344. * @param effect defines the effect to bind data to
  114345. * @param nodeMaterial defines the hosting NodeMaterial
  114346. * @param mesh defines the mesh that will be rendered
  114347. */
  114348. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114349. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  114350. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  114351. protected _writeFloat(value: number): string;
  114352. /**
  114353. * Gets the current class name e.g. "NodeMaterialBlock"
  114354. * @returns the class name
  114355. */
  114356. getClassName(): string;
  114357. /**
  114358. * Register a new input. Must be called inside a block constructor
  114359. * @param name defines the connection point name
  114360. * @param type defines the connection point type
  114361. * @param isOptional defines a boolean indicating that this input can be omitted
  114362. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114363. * @returns the current block
  114364. */
  114365. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  114366. /**
  114367. * Register a new output. Must be called inside a block constructor
  114368. * @param name defines the connection point name
  114369. * @param type defines the connection point type
  114370. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114371. * @returns the current block
  114372. */
  114373. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  114374. /**
  114375. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  114376. * @param forOutput defines an optional connection point to check compatibility with
  114377. * @returns the first available input or null
  114378. */
  114379. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  114380. /**
  114381. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  114382. * @param forBlock defines an optional block to check compatibility with
  114383. * @returns the first available input or null
  114384. */
  114385. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  114386. /**
  114387. * Connect current block with another block
  114388. * @param other defines the block to connect with
  114389. * @param options define the various options to help pick the right connections
  114390. * @returns the current block
  114391. */
  114392. connectTo(other: NodeMaterialBlock, options?: {
  114393. input?: string;
  114394. output?: string;
  114395. outputSwizzle?: string;
  114396. }): this | undefined;
  114397. protected _buildBlock(state: NodeMaterialBuildState): void;
  114398. /**
  114399. * Add uniforms, samplers and uniform buffers at compilation time
  114400. * @param state defines the state to update
  114401. * @param nodeMaterial defines the node material requesting the update
  114402. * @param defines defines the material defines to update
  114403. */
  114404. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114405. /**
  114406. * Add potential fallbacks if shader compilation fails
  114407. * @param mesh defines the mesh to be rendered
  114408. * @param fallbacks defines the current prioritized list of fallbacks
  114409. */
  114410. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114411. /**
  114412. * Update defines for shader compilation
  114413. * @param mesh defines the mesh to be rendered
  114414. * @param nodeMaterial defines the node material requesting the update
  114415. * @param defines defines the material defines to update
  114416. * @param useInstances specifies that instances should be used
  114417. */
  114418. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114419. /**
  114420. * Lets the block try to connect some inputs automatically
  114421. */
  114422. autoConfigure(): void;
  114423. /**
  114424. * Function called when a block is declared as repeatable content generator
  114425. * @param vertexShaderState defines the current compilation state for the vertex shader
  114426. * @param fragmentShaderState defines the current compilation state for the fragment shader
  114427. * @param mesh defines the mesh to be rendered
  114428. * @param defines defines the material defines to update
  114429. */
  114430. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114431. /**
  114432. * Checks if the block is ready
  114433. * @param mesh defines the mesh to be rendered
  114434. * @param nodeMaterial defines the node material requesting the update
  114435. * @param defines defines the material defines to update
  114436. * @param useInstances specifies that instances should be used
  114437. * @returns true if the block is ready
  114438. */
  114439. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  114440. /**
  114441. * Compile the current node and generate the shader code
  114442. * @param state defines the current compilation state (uniforms, samplers, current string)
  114443. * @returns the current block
  114444. */
  114445. build(state: NodeMaterialBuildState): this | undefined;
  114446. }
  114447. }
  114448. declare module BABYLON {
  114449. /**
  114450. * Defines a connection point for a block
  114451. */
  114452. export class NodeMaterialConnectionPoint {
  114453. /** @hidden */
  114454. _ownerBlock: NodeMaterialBlock;
  114455. /** @hidden */
  114456. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114457. private _associatedVariableName;
  114458. private _endpoints;
  114459. private _storedValue;
  114460. private _valueCallback;
  114461. private _mode;
  114462. /** @hidden */
  114463. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114464. /** @hidden */
  114465. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  114466. /** @hidden */
  114467. _needToEmitVarying: boolean;
  114468. /** @hidden */
  114469. _forceUniformInVertexShaderOnly: boolean;
  114470. private _type;
  114471. /**
  114472. * Gets or sets the connection point type (default is float)
  114473. */
  114474. type: NodeMaterialBlockConnectionPointTypes;
  114475. /**
  114476. * Gets or sets the connection point name
  114477. */
  114478. name: string;
  114479. /**
  114480. * Gets or sets the swizzle to apply to this connection point when reading or writing
  114481. */
  114482. swizzle: string;
  114483. /**
  114484. * Gets or sets a boolean indicating that this connection point can be omitted
  114485. */
  114486. isOptional: boolean;
  114487. /**
  114488. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  114489. */
  114490. define: string;
  114491. /** Gets or sets the target of that connection point */
  114492. target: NodeMaterialBlockTargets;
  114493. /**
  114494. * Gets or sets the value of that point.
  114495. * Please note that this value will be ignored if valueCallback is defined
  114496. */
  114497. value: any;
  114498. /**
  114499. * Gets or sets a callback used to get the value of that point.
  114500. * Please note that setting this value will force the connection point to ignore the value property
  114501. */
  114502. valueCallback: () => any;
  114503. /**
  114504. * Gets or sets the associated variable name in the shader
  114505. */
  114506. associatedVariableName: string;
  114507. /**
  114508. * Gets a boolean indicating that this connection point not defined yet
  114509. */
  114510. readonly isUndefined: boolean;
  114511. /**
  114512. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  114513. * In this case the connection point name must be the name of the uniform to use.
  114514. * Can only be set on inputs
  114515. */
  114516. isUniform: boolean;
  114517. /**
  114518. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  114519. * In this case the connection point name must be the name of the attribute to use
  114520. * Can only be set on inputs
  114521. */
  114522. isAttribute: boolean;
  114523. /**
  114524. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  114525. * Can only be set on exit points
  114526. */
  114527. isVarying: boolean;
  114528. /** Get the other side of the connection (if any) */
  114529. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114530. /** Get the block that owns this connection point */
  114531. readonly ownerBlock: NodeMaterialBlock;
  114532. /** Get the block connected on the other side of this connection (if any) */
  114533. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  114534. /** Get the block connected on the endpoints of this connection (if any) */
  114535. readonly connectedBlocks: Array<NodeMaterialBlock>;
  114536. /**
  114537. * Creates a new connection point
  114538. * @param name defines the connection point name
  114539. * @param ownerBlock defines the block hosting this connection point
  114540. */
  114541. constructor(name: string, ownerBlock: NodeMaterialBlock);
  114542. /**
  114543. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  114544. * @returns the class name
  114545. */
  114546. getClassName(): string;
  114547. /**
  114548. * Set the source of this connection point to a vertex attribute
  114549. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  114550. * @returns the current connection point
  114551. */
  114552. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  114553. /**
  114554. * Set the source of this connection point to a well known value
  114555. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  114556. * @returns the current connection point
  114557. */
  114558. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  114559. /**
  114560. * Gets a boolean indicating that the current connection point is a well known value
  114561. */
  114562. readonly isWellKnownValue: boolean;
  114563. /**
  114564. * Gets or sets the current well known value or null if not defined as well know value
  114565. */
  114566. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114567. private _getTypeLength;
  114568. /**
  114569. * Gets an boolean indicating if the current point can be connected to another point
  114570. * @param connectionPoint defines the other connection point
  114571. * @returns true if the connection is possible
  114572. */
  114573. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  114574. /**
  114575. * Connect this point to another connection point
  114576. * @param connectionPoint defines the other connection point
  114577. * @returns the current connection point
  114578. */
  114579. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114580. /**
  114581. * Disconnect this point from one of his endpoint
  114582. * @param endpoint defines the other connection point
  114583. * @returns the current connection point
  114584. */
  114585. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114586. /**
  114587. * When connection point is an uniform, this function will send its value to the effect
  114588. * @param effect defines the effect to transmit value to
  114589. * @param world defines the world matrix
  114590. * @param worldView defines the worldxview matrix
  114591. * @param worldViewProjection defines the worldxviewxprojection matrix
  114592. */
  114593. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  114594. /**
  114595. * When connection point is an uniform, this function will send its value to the effect
  114596. * @param effect defines the effect to transmit value to
  114597. * @param scene defines the hosting scene
  114598. */
  114599. transmit(effect: Effect, scene: Scene): void;
  114600. }
  114601. }
  114602. declare module BABYLON {
  114603. /**
  114604. * Block used to add support for vertex skinning (bones)
  114605. */
  114606. export class BonesBlock extends NodeMaterialBlock {
  114607. /**
  114608. * Creates a new BonesBlock
  114609. * @param name defines the block name
  114610. */
  114611. constructor(name: string);
  114612. /**
  114613. * Initialize the block and prepare the context for build
  114614. * @param state defines the state that will be used for the build
  114615. */
  114616. initialize(state: NodeMaterialBuildState): void;
  114617. /**
  114618. * Gets the current class name
  114619. * @returns the class name
  114620. */
  114621. getClassName(): string;
  114622. /**
  114623. * Gets the matrix indices input component
  114624. */
  114625. readonly matricesIndices: NodeMaterialConnectionPoint;
  114626. /**
  114627. * Gets the matrix weights input component
  114628. */
  114629. readonly matricesWeights: NodeMaterialConnectionPoint;
  114630. /**
  114631. * Gets the extra matrix indices input component
  114632. */
  114633. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  114634. /**
  114635. * Gets the extra matrix weights input component
  114636. */
  114637. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  114638. /**
  114639. * Gets the world input component
  114640. */
  114641. readonly world: NodeMaterialConnectionPoint;
  114642. /**
  114643. * Gets the output component
  114644. */
  114645. readonly output: NodeMaterialConnectionPoint;
  114646. autoConfigure(): void;
  114647. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114648. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114649. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114650. protected _buildBlock(state: NodeMaterialBuildState): this;
  114651. }
  114652. }
  114653. declare module BABYLON {
  114654. /**
  114655. * Block used to add support for instances
  114656. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114657. */
  114658. export class InstancesBlock extends NodeMaterialBlock {
  114659. /**
  114660. * Creates a new InstancesBlock
  114661. * @param name defines the block name
  114662. */
  114663. constructor(name: string);
  114664. /**
  114665. * Gets the current class name
  114666. * @returns the class name
  114667. */
  114668. getClassName(): string;
  114669. /**
  114670. * Gets the first world row input component
  114671. */
  114672. readonly world0: NodeMaterialConnectionPoint;
  114673. /**
  114674. * Gets the second world row input component
  114675. */
  114676. readonly world1: NodeMaterialConnectionPoint;
  114677. /**
  114678. * Gets the third world row input component
  114679. */
  114680. readonly world2: NodeMaterialConnectionPoint;
  114681. /**
  114682. * Gets the forth world row input component
  114683. */
  114684. readonly world3: NodeMaterialConnectionPoint;
  114685. /**
  114686. * Gets the world input component
  114687. */
  114688. readonly world: NodeMaterialConnectionPoint;
  114689. /**
  114690. * Gets the output component
  114691. */
  114692. readonly output: NodeMaterialConnectionPoint;
  114693. autoConfigure(): void;
  114694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114695. protected _buildBlock(state: NodeMaterialBuildState): this;
  114696. }
  114697. }
  114698. declare module BABYLON {
  114699. /**
  114700. * Block used to add morph targets support to vertex shader
  114701. */
  114702. export class MorphTargetsBlock extends NodeMaterialBlock {
  114703. private _repeatableContentAnchor;
  114704. private _repeatebleContentGenerated;
  114705. /**
  114706. * Create a new MorphTargetsBlock
  114707. * @param name defines the block name
  114708. */
  114709. constructor(name: string);
  114710. /**
  114711. * Gets the current class name
  114712. * @returns the class name
  114713. */
  114714. getClassName(): string;
  114715. /**
  114716. * Gets the position input component
  114717. */
  114718. readonly position: NodeMaterialConnectionPoint;
  114719. /**
  114720. * Gets the normal input component
  114721. */
  114722. readonly normal: NodeMaterialConnectionPoint;
  114723. /**
  114724. * Gets the tangent input component
  114725. */
  114726. readonly tangent: NodeMaterialConnectionPoint;
  114727. /**
  114728. * Gets the tangent input component
  114729. */
  114730. readonly uv: NodeMaterialConnectionPoint;
  114731. /**
  114732. * Gets the position output component
  114733. */
  114734. readonly positionOutput: NodeMaterialConnectionPoint;
  114735. /**
  114736. * Gets the normal output component
  114737. */
  114738. readonly normalOutput: NodeMaterialConnectionPoint;
  114739. /**
  114740. * Gets the tangent output component
  114741. */
  114742. readonly tangentOutput: NodeMaterialConnectionPoint;
  114743. /**
  114744. * Gets the tangent output component
  114745. */
  114746. readonly uvOutput: NodeMaterialConnectionPoint;
  114747. initialize(state: NodeMaterialBuildState): void;
  114748. autoConfigure(): void;
  114749. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114750. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114751. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114752. protected _buildBlock(state: NodeMaterialBuildState): this;
  114753. }
  114754. }
  114755. declare module BABYLON {
  114756. /**
  114757. * Block used to add an alpha test in the fragment shader
  114758. */
  114759. export class AlphaTestBlock extends NodeMaterialBlock {
  114760. /**
  114761. * Gets or sets the alpha value where alpha testing happens
  114762. */
  114763. alphaCutOff: number;
  114764. /**
  114765. * Create a new AlphaTestBlock
  114766. * @param name defines the block name
  114767. */
  114768. constructor(name: string);
  114769. /**
  114770. * Gets the current class name
  114771. * @returns the class name
  114772. */
  114773. getClassName(): string;
  114774. /**
  114775. * Gets the color input component
  114776. */
  114777. readonly color: NodeMaterialConnectionPoint;
  114778. protected _buildBlock(state: NodeMaterialBuildState): this;
  114779. }
  114780. }
  114781. declare module BABYLON {
  114782. /**
  114783. * Block used to create a Color4 out of 4 inputs (one for each component)
  114784. */
  114785. export class RGBAMergerBlock extends NodeMaterialBlock {
  114786. /**
  114787. * Create a new RGBAMergerBlock
  114788. * @param name defines the block name
  114789. */
  114790. constructor(name: string);
  114791. /**
  114792. * Gets the current class name
  114793. * @returns the class name
  114794. */
  114795. getClassName(): string;
  114796. /**
  114797. * Gets the R input component
  114798. */
  114799. readonly r: NodeMaterialConnectionPoint;
  114800. /**
  114801. * Gets the G input component
  114802. */
  114803. readonly g: NodeMaterialConnectionPoint;
  114804. /**
  114805. * Gets the B input component
  114806. */
  114807. readonly b: NodeMaterialConnectionPoint;
  114808. /**
  114809. * Gets the RGB input component
  114810. */
  114811. readonly rgb: NodeMaterialConnectionPoint;
  114812. /**
  114813. * Gets the R input component
  114814. */
  114815. readonly a: NodeMaterialConnectionPoint;
  114816. /**
  114817. * Gets the output component
  114818. */
  114819. readonly output: NodeMaterialConnectionPoint;
  114820. protected _buildBlock(state: NodeMaterialBuildState): this;
  114821. }
  114822. }
  114823. declare module BABYLON {
  114824. /**
  114825. * Block used to create a Color3 out of 3 inputs (one for each component)
  114826. */
  114827. export class RGBMergerBlock extends NodeMaterialBlock {
  114828. /**
  114829. * Create a new RGBMergerBlock
  114830. * @param name defines the block name
  114831. */
  114832. constructor(name: string);
  114833. /**
  114834. * Gets the current class name
  114835. * @returns the class name
  114836. */
  114837. getClassName(): string;
  114838. /**
  114839. * Gets the R component input
  114840. */
  114841. readonly r: NodeMaterialConnectionPoint;
  114842. /**
  114843. * Gets the G component input
  114844. */
  114845. readonly g: NodeMaterialConnectionPoint;
  114846. /**
  114847. * Gets the B component input
  114848. */
  114849. readonly b: NodeMaterialConnectionPoint;
  114850. /**
  114851. * Gets the output component
  114852. */
  114853. readonly output: NodeMaterialConnectionPoint;
  114854. protected _buildBlock(state: NodeMaterialBuildState): this;
  114855. }
  114856. }
  114857. declare module BABYLON {
  114858. /**
  114859. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  114860. */
  114861. export class RGBASplitterBlock extends NodeMaterialBlock {
  114862. /**
  114863. * Create a new RGBASplitterBlock
  114864. * @param name defines the block name
  114865. */
  114866. constructor(name: string);
  114867. /**
  114868. * Gets the current class name
  114869. * @returns the class name
  114870. */
  114871. getClassName(): string;
  114872. /**
  114873. * Gets the input component
  114874. */
  114875. readonly input: NodeMaterialConnectionPoint;
  114876. protected _buildBlock(state: NodeMaterialBuildState): this;
  114877. }
  114878. }
  114879. declare module BABYLON {
  114880. /**
  114881. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  114882. */
  114883. export class RGBSplitterBlock extends NodeMaterialBlock {
  114884. /**
  114885. * Create a new RGBSplitterBlock
  114886. * @param name defines the block name
  114887. */
  114888. constructor(name: string);
  114889. /**
  114890. * Gets the current class name
  114891. * @returns the class name
  114892. */
  114893. getClassName(): string;
  114894. /**
  114895. * Gets the input component
  114896. */
  114897. readonly input: NodeMaterialConnectionPoint;
  114898. protected _buildBlock(state: NodeMaterialBuildState): this;
  114899. }
  114900. }
  114901. declare module BABYLON {
  114902. /**
  114903. * Block used to read a texture from a sampler
  114904. */
  114905. export class TextureBlock extends NodeMaterialBlock {
  114906. private _defineName;
  114907. /**
  114908. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  114909. */
  114910. autoConnectTextureMatrix: boolean;
  114911. /**
  114912. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  114913. */
  114914. autoSelectUV: boolean;
  114915. /**
  114916. * Create a new TextureBlock
  114917. * @param name defines the block name
  114918. */
  114919. constructor(name: string);
  114920. /**
  114921. * Gets the current class name
  114922. * @returns the class name
  114923. */
  114924. getClassName(): string;
  114925. /**
  114926. * Gets the uv input component
  114927. */
  114928. readonly uv: NodeMaterialConnectionPoint;
  114929. /**
  114930. * Gets the texture information input component
  114931. */
  114932. readonly textureInfo: NodeMaterialConnectionPoint;
  114933. /**
  114934. * Gets the transformed uv input component
  114935. */
  114936. readonly transformedUV: NodeMaterialConnectionPoint;
  114937. /**
  114938. * Gets the texture input component
  114939. */
  114940. readonly texture: NodeMaterialConnectionPoint;
  114941. /**
  114942. * Gets the texture transform input component
  114943. */
  114944. readonly textureTransform: NodeMaterialConnectionPoint;
  114945. /**
  114946. * Gets the output component
  114947. */
  114948. readonly output: NodeMaterialConnectionPoint;
  114949. autoConfigure(): void;
  114950. initialize(state: NodeMaterialBuildState): void;
  114951. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114952. isReady(): boolean;
  114953. private _injectVertexCode;
  114954. protected _buildBlock(state: NodeMaterialBuildState): this;
  114955. }
  114956. }
  114957. declare module BABYLON {
  114958. /**
  114959. * Block used to add image processing support to fragment shader
  114960. */
  114961. export class ImageProcessingBlock extends NodeMaterialBlock {
  114962. /**
  114963. * Create a new ImageProcessingBlock
  114964. * @param name defines the block name
  114965. */
  114966. constructor(name: string);
  114967. /**
  114968. * Gets the current class name
  114969. * @returns the class name
  114970. */
  114971. getClassName(): string;
  114972. /**
  114973. * Gets the color input component
  114974. */
  114975. readonly color: NodeMaterialConnectionPoint;
  114976. /**
  114977. * Gets the output component
  114978. */
  114979. readonly output: NodeMaterialConnectionPoint;
  114980. /**
  114981. * Initialize the block and prepare the context for build
  114982. * @param state defines the state that will be used for the build
  114983. */
  114984. initialize(state: NodeMaterialBuildState): void;
  114985. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  114986. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114987. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114988. protected _buildBlock(state: NodeMaterialBuildState): this;
  114989. }
  114990. }
  114991. declare module BABYLON {
  114992. /**
  114993. * Block used to add support for scene fog
  114994. */
  114995. export class FogBlock extends NodeMaterialBlock {
  114996. /**
  114997. * Create a new FogBlock
  114998. * @param name defines the block name
  114999. */
  115000. constructor(name: string);
  115001. /**
  115002. * Gets the current class name
  115003. * @returns the class name
  115004. */
  115005. getClassName(): string;
  115006. /**
  115007. * Gets the world position input component
  115008. */
  115009. readonly worldPosition: NodeMaterialConnectionPoint;
  115010. /**
  115011. * Gets the view input component
  115012. */
  115013. readonly view: NodeMaterialConnectionPoint;
  115014. /**
  115015. * Gets the color input component
  115016. */
  115017. readonly color: NodeMaterialConnectionPoint;
  115018. /**
  115019. * Gets the fog color input component
  115020. */
  115021. readonly fogColor: NodeMaterialConnectionPoint;
  115022. /**
  115023. * Gets the for parameter input component
  115024. */
  115025. readonly fogParameters: NodeMaterialConnectionPoint;
  115026. /**
  115027. * Gets the output component
  115028. */
  115029. readonly output: NodeMaterialConnectionPoint;
  115030. autoConfigure(): void;
  115031. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115032. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115033. protected _buildBlock(state: NodeMaterialBuildState): this;
  115034. }
  115035. }
  115036. declare module BABYLON {
  115037. /**
  115038. * Block used to add light in the fragment shader
  115039. */
  115040. export class LightBlock extends NodeMaterialBlock {
  115041. private _lightId;
  115042. /**
  115043. * Create a new LightBlock
  115044. * @param name defines the block name
  115045. */
  115046. constructor(name: string);
  115047. /**
  115048. * Gets the current class name
  115049. * @returns the class name
  115050. */
  115051. getClassName(): string;
  115052. /**
  115053. * Gets the world position input component
  115054. */
  115055. readonly worldPosition: NodeMaterialConnectionPoint;
  115056. /**
  115057. * Gets the world normal input component
  115058. */
  115059. readonly worldNormal: NodeMaterialConnectionPoint;
  115060. /**
  115061. * Gets the light input component.
  115062. * If not defined, all lights will be considered
  115063. */
  115064. readonly light: NodeMaterialConnectionPoint;
  115065. /**
  115066. * Gets the camera (or eye) position component
  115067. */
  115068. readonly cameraPosition: NodeMaterialConnectionPoint;
  115069. /**
  115070. * Gets the diffuse output component
  115071. */
  115072. readonly diffuseOutput: NodeMaterialConnectionPoint;
  115073. /**
  115074. * Gets the specular output component
  115075. */
  115076. readonly specularOutput: NodeMaterialConnectionPoint;
  115077. autoConfigure(): void;
  115078. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115079. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115080. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115081. private _injectVertexCode;
  115082. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  115083. }
  115084. }
  115085. declare module BABYLON {
  115086. /**
  115087. * Block used to multiply 2 vector4
  115088. */
  115089. export class MultiplyBlock extends NodeMaterialBlock {
  115090. /**
  115091. * Creates a new MultiplyBlock
  115092. * @param name defines the block name
  115093. */
  115094. constructor(name: string);
  115095. /**
  115096. * Gets the current class name
  115097. * @returns the class name
  115098. */
  115099. getClassName(): string;
  115100. /**
  115101. * Gets the left operand input component
  115102. */
  115103. readonly left: NodeMaterialConnectionPoint;
  115104. /**
  115105. * Gets the right operand input component
  115106. */
  115107. readonly right: NodeMaterialConnectionPoint;
  115108. /**
  115109. * Gets the output component
  115110. */
  115111. readonly output: NodeMaterialConnectionPoint;
  115112. protected _buildBlock(state: NodeMaterialBuildState): this;
  115113. }
  115114. }
  115115. declare module BABYLON {
  115116. /**
  115117. * Block used to add 2 vector4
  115118. */
  115119. export class AddBlock extends NodeMaterialBlock {
  115120. /**
  115121. * Creates a new AddBlock
  115122. * @param name defines the block name
  115123. */
  115124. constructor(name: string);
  115125. /**
  115126. * Gets the current class name
  115127. * @returns the class name
  115128. */
  115129. getClassName(): string;
  115130. /**
  115131. * Gets the left operand input component
  115132. */
  115133. readonly left: NodeMaterialConnectionPoint;
  115134. /**
  115135. * Gets the right operand input component
  115136. */
  115137. readonly right: NodeMaterialConnectionPoint;
  115138. /**
  115139. * Gets the output component
  115140. */
  115141. readonly output: NodeMaterialConnectionPoint;
  115142. protected _buildBlock(state: NodeMaterialBuildState): this;
  115143. }
  115144. }
  115145. declare module BABYLON {
  115146. /**
  115147. * Block used to clamp a float
  115148. */
  115149. export class ClampBlock extends NodeMaterialBlock {
  115150. /** Gets or sets the minimum range */
  115151. minimum: number;
  115152. /** Gets or sets the maximum range */
  115153. maximum: number;
  115154. /**
  115155. * Creates a new ClampBlock
  115156. * @param name defines the block name
  115157. */
  115158. constructor(name: string);
  115159. /**
  115160. * Gets the current class name
  115161. * @returns the class name
  115162. */
  115163. getClassName(): string;
  115164. /**
  115165. * Gets the value input component
  115166. */
  115167. readonly value: NodeMaterialConnectionPoint;
  115168. /**
  115169. * Gets the output component
  115170. */
  115171. readonly output: NodeMaterialConnectionPoint;
  115172. protected _buildBlock(state: NodeMaterialBuildState): this;
  115173. }
  115174. }
  115175. declare module BABYLON {
  115176. /**
  115177. * Block used to scale a value
  115178. */
  115179. export class ScaleBlock extends NodeMaterialBlock {
  115180. /**
  115181. * Creates a new ScaleBlock
  115182. * @param name defines the block name
  115183. */
  115184. constructor(name: string);
  115185. /**
  115186. * Gets the current class name
  115187. * @returns the class name
  115188. */
  115189. getClassName(): string;
  115190. /**
  115191. * Gets the value operand input component
  115192. */
  115193. readonly value: NodeMaterialConnectionPoint;
  115194. /**
  115195. * Gets the scale operand input component
  115196. */
  115197. readonly scale: NodeMaterialConnectionPoint;
  115198. /**
  115199. * Gets the output component
  115200. */
  115201. readonly output: NodeMaterialConnectionPoint;
  115202. protected _buildBlock(state: NodeMaterialBuildState): this;
  115203. }
  115204. }
  115205. declare module BABYLON {
  115206. /**
  115207. * Block used to transform a vector2 with a matrix
  115208. */
  115209. export class Vector2TransformBlock extends NodeMaterialBlock {
  115210. /**
  115211. * Defines the value to use to complement Vector2 to transform it to a Vector4
  115212. */
  115213. complementZ: number;
  115214. /**
  115215. * Defines the value to use to complement Vector2 to transform it to a Vector4
  115216. */
  115217. complementW: number;
  115218. /**
  115219. * Creates a new Vector2TransformBlock
  115220. * @param name defines the block name
  115221. */
  115222. constructor(name: string);
  115223. /**
  115224. * Gets the vector input
  115225. */
  115226. readonly vector: NodeMaterialConnectionPoint;
  115227. /**
  115228. * Gets the matrix transform input
  115229. */
  115230. readonly transform: NodeMaterialConnectionPoint;
  115231. /**
  115232. * Gets the output component
  115233. */
  115234. readonly output: NodeMaterialConnectionPoint;
  115235. /**
  115236. * Gets the current class name
  115237. * @returns the class name
  115238. */
  115239. getClassName(): string;
  115240. protected _buildBlock(state: NodeMaterialBuildState): this;
  115241. }
  115242. }
  115243. declare module BABYLON {
  115244. /**
  115245. * Block used to transform a vector3 with a matrix
  115246. */
  115247. export class Vector3TransformBlock extends NodeMaterialBlock {
  115248. /**
  115249. * Defines the value to use to complement Vector3 to transform it to a Vector4
  115250. */
  115251. complement: number;
  115252. /**
  115253. * Creates a new Vector3TransformBlock
  115254. * @param name defines the block name
  115255. */
  115256. constructor(name: string);
  115257. /**
  115258. * Gets the vector input
  115259. */
  115260. readonly vector: NodeMaterialConnectionPoint;
  115261. /**
  115262. * Gets the matrix transform input
  115263. */
  115264. readonly transform: NodeMaterialConnectionPoint;
  115265. /**
  115266. * Gets the output component
  115267. */
  115268. readonly output: NodeMaterialConnectionPoint;
  115269. /**
  115270. * Gets the current class name
  115271. * @returns the class name
  115272. */
  115273. getClassName(): string;
  115274. protected _buildBlock(state: NodeMaterialBuildState): this;
  115275. }
  115276. }
  115277. declare module BABYLON {
  115278. /**
  115279. * Block used to multiply two matrices
  115280. */
  115281. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  115282. /**
  115283. * Creates a new MatrixMultiplicationBlock
  115284. * @param name defines the block name
  115285. */
  115286. constructor(name: string);
  115287. /**
  115288. * Gets the left operand
  115289. */
  115290. readonly left: NodeMaterialConnectionPoint;
  115291. /**
  115292. * Gets the right operand
  115293. */
  115294. readonly right: NodeMaterialConnectionPoint;
  115295. /**
  115296. * Gets the output component
  115297. */
  115298. readonly output: NodeMaterialConnectionPoint;
  115299. /**
  115300. * Gets the current class name
  115301. * @returns the class name
  115302. */
  115303. getClassName(): string;
  115304. protected _buildBlock(state: NodeMaterialBuildState): this;
  115305. }
  115306. }
  115307. declare module BABYLON {
  115308. /**
  115309. * Helper class to push actions to a pool of workers.
  115310. */
  115311. export class WorkerPool implements IDisposable {
  115312. private _workerInfos;
  115313. private _pendingActions;
  115314. /**
  115315. * Constructor
  115316. * @param workers Array of workers to use for actions
  115317. */
  115318. constructor(workers: Array<Worker>);
  115319. /**
  115320. * Terminates all workers and clears any pending actions.
  115321. */
  115322. dispose(): void;
  115323. /**
  115324. * Pushes an action to the worker pool. If all the workers are active, the action will be
  115325. * pended until a worker has completed its action.
  115326. * @param action The action to perform. Call onComplete when the action is complete.
  115327. */
  115328. push(action: (worker: Worker, onComplete: () => void) => void): void;
  115329. private _execute;
  115330. }
  115331. }
  115332. declare module BABYLON {
  115333. /**
  115334. * Configuration for Draco compression
  115335. */
  115336. export interface IDracoCompressionConfiguration {
  115337. /**
  115338. * Configuration for the decoder.
  115339. */
  115340. decoder: {
  115341. /**
  115342. * The url to the WebAssembly module.
  115343. */
  115344. wasmUrl?: string;
  115345. /**
  115346. * The url to the WebAssembly binary.
  115347. */
  115348. wasmBinaryUrl?: string;
  115349. /**
  115350. * The url to the fallback JavaScript module.
  115351. */
  115352. fallbackUrl?: string;
  115353. };
  115354. }
  115355. /**
  115356. * Draco compression (https://google.github.io/draco/)
  115357. *
  115358. * This class wraps the Draco module.
  115359. *
  115360. * **Encoder**
  115361. *
  115362. * The encoder is not currently implemented.
  115363. *
  115364. * **Decoder**
  115365. *
  115366. * 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.
  115367. *
  115368. * To update the configuration, use the following code:
  115369. * ```javascript
  115370. * DracoCompression.Configuration = {
  115371. * decoder: {
  115372. * wasmUrl: "<url to the WebAssembly library>",
  115373. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  115374. * fallbackUrl: "<url to the fallback JavaScript library>",
  115375. * }
  115376. * };
  115377. * ```
  115378. *
  115379. * 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.
  115380. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  115381. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  115382. *
  115383. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  115384. * ```javascript
  115385. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  115386. * ```
  115387. *
  115388. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  115389. */
  115390. export class DracoCompression implements IDisposable {
  115391. private _workerPoolPromise?;
  115392. private _decoderModulePromise?;
  115393. /**
  115394. * The configuration. Defaults to the following urls:
  115395. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  115396. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  115397. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  115398. */
  115399. static Configuration: IDracoCompressionConfiguration;
  115400. /**
  115401. * Returns true if the decoder configuration is available.
  115402. */
  115403. static readonly DecoderAvailable: boolean;
  115404. /**
  115405. * Default number of workers to create when creating the draco compression object.
  115406. */
  115407. static DefaultNumWorkers: number;
  115408. private static GetDefaultNumWorkers;
  115409. private static _Default;
  115410. /**
  115411. * Default instance for the draco compression object.
  115412. */
  115413. static readonly Default: DracoCompression;
  115414. /**
  115415. * Constructor
  115416. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  115417. */
  115418. constructor(numWorkers?: number);
  115419. /**
  115420. * Stop all async operations and release resources.
  115421. */
  115422. dispose(): void;
  115423. /**
  115424. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  115425. * @returns a promise that resolves when ready
  115426. */
  115427. whenReadyAsync(): Promise<void>;
  115428. /**
  115429. * Decode Draco compressed mesh data to vertex data.
  115430. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  115431. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  115432. * @returns A promise that resolves with the decoded vertex data
  115433. */
  115434. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  115435. [kind: string]: number;
  115436. }): Promise<VertexData>;
  115437. }
  115438. }
  115439. declare module BABYLON {
  115440. /**
  115441. * Class for building Constructive Solid Geometry
  115442. */
  115443. export class CSG {
  115444. private polygons;
  115445. /**
  115446. * The world matrix
  115447. */
  115448. matrix: Matrix;
  115449. /**
  115450. * Stores the position
  115451. */
  115452. position: Vector3;
  115453. /**
  115454. * Stores the rotation
  115455. */
  115456. rotation: Vector3;
  115457. /**
  115458. * Stores the rotation quaternion
  115459. */
  115460. rotationQuaternion: Nullable<Quaternion>;
  115461. /**
  115462. * Stores the scaling vector
  115463. */
  115464. scaling: Vector3;
  115465. /**
  115466. * Convert the Mesh to CSG
  115467. * @param mesh The Mesh to convert to CSG
  115468. * @returns A new CSG from the Mesh
  115469. */
  115470. static FromMesh(mesh: Mesh): CSG;
  115471. /**
  115472. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  115473. * @param polygons Polygons used to construct a CSG solid
  115474. */
  115475. private static FromPolygons;
  115476. /**
  115477. * Clones, or makes a deep copy, of the CSG
  115478. * @returns A new CSG
  115479. */
  115480. clone(): CSG;
  115481. /**
  115482. * Unions this CSG with another CSG
  115483. * @param csg The CSG to union against this CSG
  115484. * @returns The unioned CSG
  115485. */
  115486. union(csg: CSG): CSG;
  115487. /**
  115488. * Unions this CSG with another CSG in place
  115489. * @param csg The CSG to union against this CSG
  115490. */
  115491. unionInPlace(csg: CSG): void;
  115492. /**
  115493. * Subtracts this CSG with another CSG
  115494. * @param csg The CSG to subtract against this CSG
  115495. * @returns A new CSG
  115496. */
  115497. subtract(csg: CSG): CSG;
  115498. /**
  115499. * Subtracts this CSG with another CSG in place
  115500. * @param csg The CSG to subtact against this CSG
  115501. */
  115502. subtractInPlace(csg: CSG): void;
  115503. /**
  115504. * Intersect this CSG with another CSG
  115505. * @param csg The CSG to intersect against this CSG
  115506. * @returns A new CSG
  115507. */
  115508. intersect(csg: CSG): CSG;
  115509. /**
  115510. * Intersects this CSG with another CSG in place
  115511. * @param csg The CSG to intersect against this CSG
  115512. */
  115513. intersectInPlace(csg: CSG): void;
  115514. /**
  115515. * Return a new CSG solid with solid and empty space switched. This solid is
  115516. * not modified.
  115517. * @returns A new CSG solid with solid and empty space switched
  115518. */
  115519. inverse(): CSG;
  115520. /**
  115521. * Inverses the CSG in place
  115522. */
  115523. inverseInPlace(): void;
  115524. /**
  115525. * This is used to keep meshes transformations so they can be restored
  115526. * when we build back a Babylon Mesh
  115527. * NB : All CSG operations are performed in world coordinates
  115528. * @param csg The CSG to copy the transform attributes from
  115529. * @returns This CSG
  115530. */
  115531. copyTransformAttributes(csg: CSG): CSG;
  115532. /**
  115533. * Build Raw mesh from CSG
  115534. * Coordinates here are in world space
  115535. * @param name The name of the mesh geometry
  115536. * @param scene The Scene
  115537. * @param keepSubMeshes Specifies if the submeshes should be kept
  115538. * @returns A new Mesh
  115539. */
  115540. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  115541. /**
  115542. * Build Mesh from CSG taking material and transforms into account
  115543. * @param name The name of the Mesh
  115544. * @param material The material of the Mesh
  115545. * @param scene The Scene
  115546. * @param keepSubMeshes Specifies if submeshes should be kept
  115547. * @returns The new Mesh
  115548. */
  115549. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  115550. }
  115551. }
  115552. declare module BABYLON {
  115553. /**
  115554. * Class used to create a trail following a mesh
  115555. */
  115556. export class TrailMesh extends Mesh {
  115557. private _generator;
  115558. private _autoStart;
  115559. private _running;
  115560. private _diameter;
  115561. private _length;
  115562. private _sectionPolygonPointsCount;
  115563. private _sectionVectors;
  115564. private _sectionNormalVectors;
  115565. private _beforeRenderObserver;
  115566. /**
  115567. * @constructor
  115568. * @param name The value used by scene.getMeshByName() to do a lookup.
  115569. * @param generator The mesh to generate a trail.
  115570. * @param scene The scene to add this mesh to.
  115571. * @param diameter Diameter of trailing mesh. Default is 1.
  115572. * @param length Length of trailing mesh. Default is 60.
  115573. * @param autoStart Automatically start trailing mesh. Default true.
  115574. */
  115575. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  115576. /**
  115577. * "TrailMesh"
  115578. * @returns "TrailMesh"
  115579. */
  115580. getClassName(): string;
  115581. private _createMesh;
  115582. /**
  115583. * Start trailing mesh.
  115584. */
  115585. start(): void;
  115586. /**
  115587. * Stop trailing mesh.
  115588. */
  115589. stop(): void;
  115590. /**
  115591. * Update trailing mesh geometry.
  115592. */
  115593. update(): void;
  115594. /**
  115595. * Returns a new TrailMesh object.
  115596. * @param name is a string, the name given to the new mesh
  115597. * @param newGenerator use new generator object for cloned trail mesh
  115598. * @returns a new mesh
  115599. */
  115600. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  115601. /**
  115602. * Serializes this trail mesh
  115603. * @param serializationObject object to write serialization to
  115604. */
  115605. serialize(serializationObject: any): void;
  115606. /**
  115607. * Parses a serialized trail mesh
  115608. * @param parsedMesh the serialized mesh
  115609. * @param scene the scene to create the trail mesh in
  115610. * @returns the created trail mesh
  115611. */
  115612. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  115613. }
  115614. }
  115615. declare module BABYLON {
  115616. /**
  115617. * Class containing static functions to help procedurally build meshes
  115618. */
  115619. export class TiledBoxBuilder {
  115620. /**
  115621. * Creates a box mesh
  115622. * 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)
  115623. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115627. * @param name defines the name of the mesh
  115628. * @param options defines the options used to create the mesh
  115629. * @param scene defines the hosting scene
  115630. * @returns the box mesh
  115631. */
  115632. static CreateTiledBox(name: string, options: {
  115633. pattern?: number;
  115634. width?: number;
  115635. height?: number;
  115636. depth?: number;
  115637. tileSize?: number;
  115638. tileWidth?: number;
  115639. tileHeight?: number;
  115640. alignHorizontal?: number;
  115641. alignVertical?: number;
  115642. faceUV?: Vector4[];
  115643. faceColors?: Color4[];
  115644. sideOrientation?: number;
  115645. updatable?: boolean;
  115646. }, scene?: Nullable<Scene>): Mesh;
  115647. }
  115648. }
  115649. declare module BABYLON {
  115650. /**
  115651. * Class containing static functions to help procedurally build meshes
  115652. */
  115653. export class TorusKnotBuilder {
  115654. /**
  115655. * Creates a torus knot mesh
  115656. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115657. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115658. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115659. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115663. * @param name defines the name of the mesh
  115664. * @param options defines the options used to create the mesh
  115665. * @param scene defines the hosting scene
  115666. * @returns the torus knot mesh
  115667. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115668. */
  115669. static CreateTorusKnot(name: string, options: {
  115670. radius?: number;
  115671. tube?: number;
  115672. radialSegments?: number;
  115673. tubularSegments?: number;
  115674. p?: number;
  115675. q?: number;
  115676. updatable?: boolean;
  115677. sideOrientation?: number;
  115678. frontUVs?: Vector4;
  115679. backUVs?: Vector4;
  115680. }, scene: any): Mesh;
  115681. }
  115682. }
  115683. declare module BABYLON {
  115684. /**
  115685. * Polygon
  115686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  115687. */
  115688. export class Polygon {
  115689. /**
  115690. * Creates a rectangle
  115691. * @param xmin bottom X coord
  115692. * @param ymin bottom Y coord
  115693. * @param xmax top X coord
  115694. * @param ymax top Y coord
  115695. * @returns points that make the resulting rectation
  115696. */
  115697. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  115698. /**
  115699. * Creates a circle
  115700. * @param radius radius of circle
  115701. * @param cx scale in x
  115702. * @param cy scale in y
  115703. * @param numberOfSides number of sides that make up the circle
  115704. * @returns points that make the resulting circle
  115705. */
  115706. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  115707. /**
  115708. * Creates a polygon from input string
  115709. * @param input Input polygon data
  115710. * @returns the parsed points
  115711. */
  115712. static Parse(input: string): Vector2[];
  115713. /**
  115714. * Starts building a polygon from x and y coordinates
  115715. * @param x x coordinate
  115716. * @param y y coordinate
  115717. * @returns the started path2
  115718. */
  115719. static StartingAt(x: number, y: number): Path2;
  115720. }
  115721. /**
  115722. * Builds a polygon
  115723. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  115724. */
  115725. export class PolygonMeshBuilder {
  115726. private _points;
  115727. private _outlinepoints;
  115728. private _holes;
  115729. private _name;
  115730. private _scene;
  115731. private _epoints;
  115732. private _eholes;
  115733. private _addToepoint;
  115734. /**
  115735. * Babylon reference to the earcut plugin.
  115736. */
  115737. bjsEarcut: any;
  115738. /**
  115739. * Creates a PolygonMeshBuilder
  115740. * @param name name of the builder
  115741. * @param contours Path of the polygon
  115742. * @param scene scene to add to when creating the mesh
  115743. * @param earcutInjection can be used to inject your own earcut reference
  115744. */
  115745. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  115746. /**
  115747. * Adds a whole within the polygon
  115748. * @param hole Array of points defining the hole
  115749. * @returns this
  115750. */
  115751. addHole(hole: Vector2[]): PolygonMeshBuilder;
  115752. /**
  115753. * Creates the polygon
  115754. * @param updatable If the mesh should be updatable
  115755. * @param depth The depth of the mesh created
  115756. * @returns the created mesh
  115757. */
  115758. build(updatable?: boolean, depth?: number): Mesh;
  115759. /**
  115760. * Creates the polygon
  115761. * @param depth The depth of the mesh created
  115762. * @returns the created VertexData
  115763. */
  115764. buildVertexData(depth?: number): VertexData;
  115765. /**
  115766. * Adds a side to the polygon
  115767. * @param positions points that make the polygon
  115768. * @param normals normals of the polygon
  115769. * @param uvs uvs of the polygon
  115770. * @param indices indices of the polygon
  115771. * @param bounds bounds of the polygon
  115772. * @param points points of the polygon
  115773. * @param depth depth of the polygon
  115774. * @param flip flip of the polygon
  115775. */
  115776. private addSide;
  115777. }
  115778. }
  115779. declare module BABYLON {
  115780. /**
  115781. * Class containing static functions to help procedurally build meshes
  115782. */
  115783. export class PolygonBuilder {
  115784. /**
  115785. * Creates a polygon mesh
  115786. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115787. * * 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
  115788. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  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. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115791. * * Remember you can only change the shape positions, not their number when updating a polygon
  115792. * @param name defines the name of the mesh
  115793. * @param options defines the options used to create the mesh
  115794. * @param scene defines the hosting scene
  115795. * @param earcutInjection can be used to inject your own earcut reference
  115796. * @returns the polygon mesh
  115797. */
  115798. static CreatePolygon(name: string, options: {
  115799. shape: Vector3[];
  115800. holes?: Vector3[][];
  115801. depth?: number;
  115802. faceUV?: Vector4[];
  115803. faceColors?: Color4[];
  115804. updatable?: boolean;
  115805. sideOrientation?: number;
  115806. frontUVs?: Vector4;
  115807. backUVs?: Vector4;
  115808. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115809. /**
  115810. * Creates an extruded polygon mesh, with depth in the Y direction.
  115811. * * 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)
  115812. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115813. * @param name defines the name of the mesh
  115814. * @param options defines the options used to create the mesh
  115815. * @param scene defines the hosting scene
  115816. * @param earcutInjection can be used to inject your own earcut reference
  115817. * @returns the polygon mesh
  115818. */
  115819. static ExtrudePolygon(name: string, options: {
  115820. shape: Vector3[];
  115821. holes?: Vector3[][];
  115822. depth?: number;
  115823. faceUV?: Vector4[];
  115824. faceColors?: Color4[];
  115825. updatable?: boolean;
  115826. sideOrientation?: number;
  115827. frontUVs?: Vector4;
  115828. backUVs?: Vector4;
  115829. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115830. }
  115831. }
  115832. declare module BABYLON {
  115833. /**
  115834. * Class containing static functions to help procedurally build meshes
  115835. */
  115836. export class LatheBuilder {
  115837. /**
  115838. * Creates lathe mesh.
  115839. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115840. * * 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
  115841. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115842. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115843. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115844. * * 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
  115845. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115846. * * 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
  115847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115848. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115849. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115851. * @param name defines the name of the mesh
  115852. * @param options defines the options used to create the mesh
  115853. * @param scene defines the hosting scene
  115854. * @returns the lathe mesh
  115855. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115856. */
  115857. static CreateLathe(name: string, options: {
  115858. shape: Vector3[];
  115859. radius?: number;
  115860. tessellation?: number;
  115861. clip?: number;
  115862. arc?: number;
  115863. closed?: boolean;
  115864. updatable?: boolean;
  115865. sideOrientation?: number;
  115866. frontUVs?: Vector4;
  115867. backUVs?: Vector4;
  115868. cap?: number;
  115869. invertUV?: boolean;
  115870. }, scene?: Nullable<Scene>): Mesh;
  115871. }
  115872. }
  115873. declare module BABYLON {
  115874. /**
  115875. * Class containing static functions to help procedurally build meshes
  115876. */
  115877. export class TiledPlaneBuilder {
  115878. /**
  115879. * Creates a tiled plane mesh
  115880. * * The parameter `pattern` will, depending on value, do nothing or
  115881. * * * flip (reflect about central vertical) alternate tiles across and up
  115882. * * * flip every tile on alternate rows
  115883. * * * rotate (180 degs) alternate tiles across and up
  115884. * * * rotate every tile on alternate rows
  115885. * * * flip and rotate alternate tiles across and up
  115886. * * * flip and rotate every tile on alternate rows
  115887. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  115888. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  115889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115890. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115891. * * 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)
  115892. * * 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)
  115893. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115894. * @param name defines the name of the mesh
  115895. * @param options defines the options used to create the mesh
  115896. * @param scene defines the hosting scene
  115897. * @returns the box mesh
  115898. */
  115899. static CreateTiledPlane(name: string, options: {
  115900. pattern?: number;
  115901. tileSize?: number;
  115902. tileWidth?: number;
  115903. tileHeight?: number;
  115904. size?: number;
  115905. width?: number;
  115906. height?: number;
  115907. alignHorizontal?: number;
  115908. alignVertical?: number;
  115909. sideOrientation?: number;
  115910. frontUVs?: Vector4;
  115911. backUVs?: Vector4;
  115912. updatable?: boolean;
  115913. }, scene?: Nullable<Scene>): Mesh;
  115914. }
  115915. }
  115916. declare module BABYLON {
  115917. /**
  115918. * Class containing static functions to help procedurally build meshes
  115919. */
  115920. export class TubeBuilder {
  115921. /**
  115922. * Creates a tube mesh.
  115923. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115924. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115925. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115926. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115927. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115928. * * 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)
  115929. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115930. * * 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
  115931. * * 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
  115932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115934. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115936. * @param name defines the name of the mesh
  115937. * @param options defines the options used to create the mesh
  115938. * @param scene defines the hosting scene
  115939. * @returns the tube mesh
  115940. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115941. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115942. */
  115943. static CreateTube(name: string, options: {
  115944. path: Vector3[];
  115945. radius?: number;
  115946. tessellation?: number;
  115947. radiusFunction?: {
  115948. (i: number, distance: number): number;
  115949. };
  115950. cap?: number;
  115951. arc?: number;
  115952. updatable?: boolean;
  115953. sideOrientation?: number;
  115954. frontUVs?: Vector4;
  115955. backUVs?: Vector4;
  115956. instance?: Mesh;
  115957. invertUV?: boolean;
  115958. }, scene?: Nullable<Scene>): Mesh;
  115959. }
  115960. }
  115961. declare module BABYLON {
  115962. /**
  115963. * Class containing static functions to help procedurally build meshes
  115964. */
  115965. export class IcoSphereBuilder {
  115966. /**
  115967. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115968. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115969. * * 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`)
  115970. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115971. * * 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
  115972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115975. * @param name defines the name of the mesh
  115976. * @param options defines the options used to create the mesh
  115977. * @param scene defines the hosting scene
  115978. * @returns the icosahedron mesh
  115979. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115980. */
  115981. static CreateIcoSphere(name: string, options: {
  115982. radius?: number;
  115983. radiusX?: number;
  115984. radiusY?: number;
  115985. radiusZ?: number;
  115986. flat?: boolean;
  115987. subdivisions?: number;
  115988. sideOrientation?: number;
  115989. frontUVs?: Vector4;
  115990. backUVs?: Vector4;
  115991. updatable?: boolean;
  115992. }, scene?: Nullable<Scene>): Mesh;
  115993. }
  115994. }
  115995. declare module BABYLON {
  115996. /**
  115997. * Class containing static functions to help procedurally build meshes
  115998. */
  115999. export class DecalBuilder {
  116000. /**
  116001. * Creates a decal mesh.
  116002. * 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
  116003. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  116004. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  116005. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  116006. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  116007. * @param name defines the name of the mesh
  116008. * @param sourceMesh defines the mesh where the decal must be applied
  116009. * @param options defines the options used to create the mesh
  116010. * @param scene defines the hosting scene
  116011. * @returns the decal mesh
  116012. * @see https://doc.babylonjs.com/how_to/decals
  116013. */
  116014. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  116015. position?: Vector3;
  116016. normal?: Vector3;
  116017. size?: Vector3;
  116018. angle?: number;
  116019. }): Mesh;
  116020. }
  116021. }
  116022. declare module BABYLON {
  116023. /**
  116024. * Class containing static functions to help procedurally build meshes
  116025. */
  116026. export class MeshBuilder {
  116027. /**
  116028. * Creates a box mesh
  116029. * * The parameter `size` sets the size (float) of each box side (default 1)
  116030. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  116031. * * 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)
  116032. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116036. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  116037. * @param name defines the name of the mesh
  116038. * @param options defines the options used to create the mesh
  116039. * @param scene defines the hosting scene
  116040. * @returns the box mesh
  116041. */
  116042. static CreateBox(name: string, options: {
  116043. size?: number;
  116044. width?: number;
  116045. height?: number;
  116046. depth?: number;
  116047. faceUV?: Vector4[];
  116048. faceColors?: Color4[];
  116049. sideOrientation?: number;
  116050. frontUVs?: Vector4;
  116051. backUVs?: Vector4;
  116052. updatable?: boolean;
  116053. }, scene?: Nullable<Scene>): Mesh;
  116054. /**
  116055. * Creates a tiled box mesh
  116056. * * faceTiles sets the pattern, tile size and number of tiles for a face
  116057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116058. * @param name defines the name of the mesh
  116059. * @param options defines the options used to create the mesh
  116060. * @param scene defines the hosting scene
  116061. * @returns the tiled box mesh
  116062. */
  116063. static CreateTiledBox(name: string, options: {
  116064. pattern?: number;
  116065. size?: number;
  116066. width?: number;
  116067. height?: number;
  116068. depth: number;
  116069. tileSize?: number;
  116070. tileWidth?: number;
  116071. tileHeight?: number;
  116072. faceUV?: Vector4[];
  116073. faceColors?: Color4[];
  116074. alignHorizontal?: number;
  116075. alignVertical?: number;
  116076. sideOrientation?: number;
  116077. updatable?: boolean;
  116078. }, scene?: Nullable<Scene>): Mesh;
  116079. /**
  116080. * Creates a sphere mesh
  116081. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  116082. * * 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`)
  116083. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  116084. * * 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
  116085. * * 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)
  116086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116087. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116089. * @param name defines the name of the mesh
  116090. * @param options defines the options used to create the mesh
  116091. * @param scene defines the hosting scene
  116092. * @returns the sphere mesh
  116093. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  116094. */
  116095. static CreateSphere(name: string, options: {
  116096. segments?: number;
  116097. diameter?: number;
  116098. diameterX?: number;
  116099. diameterY?: number;
  116100. diameterZ?: number;
  116101. arc?: number;
  116102. slice?: number;
  116103. sideOrientation?: number;
  116104. frontUVs?: Vector4;
  116105. backUVs?: Vector4;
  116106. updatable?: boolean;
  116107. }, scene?: Nullable<Scene>): Mesh;
  116108. /**
  116109. * Creates a plane polygonal mesh. By default, this is a disc
  116110. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  116111. * * 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
  116112. * * 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
  116113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116114. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116116. * @param name defines the name of the mesh
  116117. * @param options defines the options used to create the mesh
  116118. * @param scene defines the hosting scene
  116119. * @returns the plane polygonal mesh
  116120. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  116121. */
  116122. static CreateDisc(name: string, options: {
  116123. radius?: number;
  116124. tessellation?: number;
  116125. arc?: number;
  116126. updatable?: boolean;
  116127. sideOrientation?: number;
  116128. frontUVs?: Vector4;
  116129. backUVs?: Vector4;
  116130. }, scene?: Nullable<Scene>): Mesh;
  116131. /**
  116132. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  116133. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  116134. * * 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`)
  116135. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  116136. * * 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
  116137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116140. * @param name defines the name of the mesh
  116141. * @param options defines the options used to create the mesh
  116142. * @param scene defines the hosting scene
  116143. * @returns the icosahedron mesh
  116144. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  116145. */
  116146. static CreateIcoSphere(name: string, options: {
  116147. radius?: number;
  116148. radiusX?: number;
  116149. radiusY?: number;
  116150. radiusZ?: number;
  116151. flat?: boolean;
  116152. subdivisions?: number;
  116153. sideOrientation?: number;
  116154. frontUVs?: Vector4;
  116155. backUVs?: Vector4;
  116156. updatable?: boolean;
  116157. }, scene?: Nullable<Scene>): Mesh;
  116158. /**
  116159. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116160. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116161. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116162. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116163. * * 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
  116164. * * 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
  116165. * * 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
  116166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116167. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116168. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116169. * * 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
  116170. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116171. * * 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
  116172. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116174. * @param name defines the name of the mesh
  116175. * @param options defines the options used to create the mesh
  116176. * @param scene defines the hosting scene
  116177. * @returns the ribbon mesh
  116178. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116179. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116180. */
  116181. static CreateRibbon(name: string, options: {
  116182. pathArray: Vector3[][];
  116183. closeArray?: boolean;
  116184. closePath?: boolean;
  116185. offset?: number;
  116186. updatable?: boolean;
  116187. sideOrientation?: number;
  116188. frontUVs?: Vector4;
  116189. backUVs?: Vector4;
  116190. instance?: Mesh;
  116191. invertUV?: boolean;
  116192. uvs?: Vector2[];
  116193. colors?: Color4[];
  116194. }, scene?: Nullable<Scene>): Mesh;
  116195. /**
  116196. * Creates a cylinder or a cone mesh
  116197. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  116198. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  116199. * * 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.
  116200. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  116201. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  116202. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  116203. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  116204. * * 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).
  116205. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  116206. * * 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).
  116207. * * 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
  116208. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  116209. * * 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
  116210. * * 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.
  116211. * * If `enclose` is false, a ring surface is one element.
  116212. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  116213. * * 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
  116214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116217. * @param name defines the name of the mesh
  116218. * @param options defines the options used to create the mesh
  116219. * @param scene defines the hosting scene
  116220. * @returns the cylinder mesh
  116221. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  116222. */
  116223. static CreateCylinder(name: string, options: {
  116224. height?: number;
  116225. diameterTop?: number;
  116226. diameterBottom?: number;
  116227. diameter?: number;
  116228. tessellation?: number;
  116229. subdivisions?: number;
  116230. arc?: number;
  116231. faceColors?: Color4[];
  116232. faceUV?: Vector4[];
  116233. updatable?: boolean;
  116234. hasRings?: boolean;
  116235. enclose?: boolean;
  116236. cap?: number;
  116237. sideOrientation?: number;
  116238. frontUVs?: Vector4;
  116239. backUVs?: Vector4;
  116240. }, scene?: Nullable<Scene>): Mesh;
  116241. /**
  116242. * Creates a torus mesh
  116243. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  116244. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  116245. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  116246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116247. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116249. * @param name defines the name of the mesh
  116250. * @param options defines the options used to create the mesh
  116251. * @param scene defines the hosting scene
  116252. * @returns the torus mesh
  116253. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  116254. */
  116255. static CreateTorus(name: string, options: {
  116256. diameter?: number;
  116257. thickness?: number;
  116258. tessellation?: number;
  116259. updatable?: boolean;
  116260. sideOrientation?: number;
  116261. frontUVs?: Vector4;
  116262. backUVs?: Vector4;
  116263. }, scene?: Nullable<Scene>): Mesh;
  116264. /**
  116265. * Creates a torus knot mesh
  116266. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  116267. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  116268. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  116269. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  116270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116273. * @param name defines the name of the mesh
  116274. * @param options defines the options used to create the mesh
  116275. * @param scene defines the hosting scene
  116276. * @returns the torus knot mesh
  116277. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  116278. */
  116279. static CreateTorusKnot(name: string, options: {
  116280. radius?: number;
  116281. tube?: number;
  116282. radialSegments?: number;
  116283. tubularSegments?: number;
  116284. p?: number;
  116285. q?: number;
  116286. updatable?: boolean;
  116287. sideOrientation?: number;
  116288. frontUVs?: Vector4;
  116289. backUVs?: Vector4;
  116290. }, scene?: Nullable<Scene>): Mesh;
  116291. /**
  116292. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116293. * * 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
  116294. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116295. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116296. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116297. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116298. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116299. * * 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
  116300. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116303. * @param name defines the name of the new line system
  116304. * @param options defines the options used to create the line system
  116305. * @param scene defines the hosting scene
  116306. * @returns a new line system mesh
  116307. */
  116308. static CreateLineSystem(name: string, options: {
  116309. lines: Vector3[][];
  116310. updatable?: boolean;
  116311. instance?: Nullable<LinesMesh>;
  116312. colors?: Nullable<Color4[][]>;
  116313. useVertexAlpha?: boolean;
  116314. }, scene: Nullable<Scene>): LinesMesh;
  116315. /**
  116316. * Creates a line mesh
  116317. * 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
  116318. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116319. * * The parameter `points` is an array successive Vector3
  116320. * * 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
  116321. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116322. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116323. * * When updating an instance, remember that only point positions can change, not the number of points
  116324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116325. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116326. * @param name defines the name of the new line system
  116327. * @param options defines the options used to create the line system
  116328. * @param scene defines the hosting scene
  116329. * @returns a new line mesh
  116330. */
  116331. static CreateLines(name: string, options: {
  116332. points: Vector3[];
  116333. updatable?: boolean;
  116334. instance?: Nullable<LinesMesh>;
  116335. colors?: Color4[];
  116336. useVertexAlpha?: boolean;
  116337. }, scene?: Nullable<Scene>): LinesMesh;
  116338. /**
  116339. * Creates a dashed line mesh
  116340. * * 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
  116341. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116342. * * The parameter `points` is an array successive Vector3
  116343. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116344. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116345. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116346. * * 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
  116347. * * When updating an instance, remember that only point positions can change, not the number of points
  116348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116349. * @param name defines the name of the mesh
  116350. * @param options defines the options used to create the mesh
  116351. * @param scene defines the hosting scene
  116352. * @returns the dashed line mesh
  116353. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116354. */
  116355. static CreateDashedLines(name: string, options: {
  116356. points: Vector3[];
  116357. dashSize?: number;
  116358. gapSize?: number;
  116359. dashNb?: number;
  116360. updatable?: boolean;
  116361. instance?: LinesMesh;
  116362. }, scene?: Nullable<Scene>): LinesMesh;
  116363. /**
  116364. * 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.
  116365. * * 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.
  116366. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116367. * * 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.
  116368. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116369. * * 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
  116370. * * 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
  116371. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116374. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116376. * @param name defines the name of the mesh
  116377. * @param options defines the options used to create the mesh
  116378. * @param scene defines the hosting scene
  116379. * @returns the extruded shape mesh
  116380. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116381. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116382. */
  116383. static ExtrudeShape(name: string, options: {
  116384. shape: Vector3[];
  116385. path: Vector3[];
  116386. scale?: number;
  116387. rotation?: number;
  116388. cap?: number;
  116389. updatable?: boolean;
  116390. sideOrientation?: number;
  116391. frontUVs?: Vector4;
  116392. backUVs?: Vector4;
  116393. instance?: Mesh;
  116394. invertUV?: boolean;
  116395. }, scene?: Nullable<Scene>): Mesh;
  116396. /**
  116397. * Creates an custom extruded shape mesh.
  116398. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116399. * * 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.
  116400. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116401. * * 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
  116402. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116403. * * 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
  116404. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116405. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116406. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116407. * * 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
  116408. * * 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
  116409. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116411. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116412. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116414. * @param name defines the name of the mesh
  116415. * @param options defines the options used to create the mesh
  116416. * @param scene defines the hosting scene
  116417. * @returns the custom extruded shape mesh
  116418. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116419. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116421. */
  116422. static ExtrudeShapeCustom(name: string, options: {
  116423. shape: Vector3[];
  116424. path: Vector3[];
  116425. scaleFunction?: any;
  116426. rotationFunction?: any;
  116427. ribbonCloseArray?: boolean;
  116428. ribbonClosePath?: boolean;
  116429. cap?: number;
  116430. updatable?: boolean;
  116431. sideOrientation?: number;
  116432. frontUVs?: Vector4;
  116433. backUVs?: Vector4;
  116434. instance?: Mesh;
  116435. invertUV?: boolean;
  116436. }, scene?: Nullable<Scene>): Mesh;
  116437. /**
  116438. * Creates lathe mesh.
  116439. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  116440. * * 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
  116441. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  116442. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  116443. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  116444. * * 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
  116445. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  116446. * * 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
  116447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116449. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116451. * @param name defines the name of the mesh
  116452. * @param options defines the options used to create the mesh
  116453. * @param scene defines the hosting scene
  116454. * @returns the lathe mesh
  116455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  116456. */
  116457. static CreateLathe(name: string, options: {
  116458. shape: Vector3[];
  116459. radius?: number;
  116460. tessellation?: number;
  116461. clip?: number;
  116462. arc?: number;
  116463. closed?: boolean;
  116464. updatable?: boolean;
  116465. sideOrientation?: number;
  116466. frontUVs?: Vector4;
  116467. backUVs?: Vector4;
  116468. cap?: number;
  116469. invertUV?: boolean;
  116470. }, scene?: Nullable<Scene>): Mesh;
  116471. /**
  116472. * Creates a tiled plane mesh
  116473. * * You can set a limited pattern arrangement with the tiles
  116474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116477. * @param name defines the name of the mesh
  116478. * @param options defines the options used to create the mesh
  116479. * @param scene defines the hosting scene
  116480. * @returns the plane mesh
  116481. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116482. */
  116483. static CreateTiledPlane(name: string, options: {
  116484. pattern?: number;
  116485. tileSize?: number;
  116486. tileWidth?: number;
  116487. tileHeight?: number;
  116488. size?: number;
  116489. width?: number;
  116490. height?: number;
  116491. alignHorizontal?: number;
  116492. alignVertical?: number;
  116493. sideOrientation?: number;
  116494. frontUVs?: Vector4;
  116495. backUVs?: Vector4;
  116496. updatable?: boolean;
  116497. }, scene?: Nullable<Scene>): Mesh;
  116498. /**
  116499. * Creates a plane mesh
  116500. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  116501. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  116502. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  116503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116506. * @param name defines the name of the mesh
  116507. * @param options defines the options used to create the mesh
  116508. * @param scene defines the hosting scene
  116509. * @returns the plane mesh
  116510. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116511. */
  116512. static CreatePlane(name: string, options: {
  116513. size?: number;
  116514. width?: number;
  116515. height?: number;
  116516. sideOrientation?: number;
  116517. frontUVs?: Vector4;
  116518. backUVs?: Vector4;
  116519. updatable?: boolean;
  116520. sourcePlane?: Plane;
  116521. }, scene?: Nullable<Scene>): Mesh;
  116522. /**
  116523. * Creates a ground mesh
  116524. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116525. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116527. * @param name defines the name of the mesh
  116528. * @param options defines the options used to create the mesh
  116529. * @param scene defines the hosting scene
  116530. * @returns the ground mesh
  116531. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116532. */
  116533. static CreateGround(name: string, options: {
  116534. width?: number;
  116535. height?: number;
  116536. subdivisions?: number;
  116537. subdivisionsX?: number;
  116538. subdivisionsY?: number;
  116539. updatable?: boolean;
  116540. }, scene?: Nullable<Scene>): Mesh;
  116541. /**
  116542. * Creates a tiled ground mesh
  116543. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  116544. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  116545. * * 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
  116546. * * 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
  116547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116548. * @param name defines the name of the mesh
  116549. * @param options defines the options used to create the mesh
  116550. * @param scene defines the hosting scene
  116551. * @returns the tiled ground mesh
  116552. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  116553. */
  116554. static CreateTiledGround(name: string, options: {
  116555. xmin: number;
  116556. zmin: number;
  116557. xmax: number;
  116558. zmax: number;
  116559. subdivisions?: {
  116560. w: number;
  116561. h: number;
  116562. };
  116563. precision?: {
  116564. w: number;
  116565. h: number;
  116566. };
  116567. updatable?: boolean;
  116568. }, scene?: Nullable<Scene>): Mesh;
  116569. /**
  116570. * Creates a ground mesh from a height map
  116571. * * The parameter `url` sets the URL of the height map image resource.
  116572. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  116573. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  116574. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  116575. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  116576. * * 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.
  116577. * * 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).
  116578. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  116579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116580. * @param name defines the name of the mesh
  116581. * @param url defines the url to the height map
  116582. * @param options defines the options used to create the mesh
  116583. * @param scene defines the hosting scene
  116584. * @returns the ground mesh
  116585. * @see https://doc.babylonjs.com/babylon101/height_map
  116586. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  116587. */
  116588. static CreateGroundFromHeightMap(name: string, url: string, options: {
  116589. width?: number;
  116590. height?: number;
  116591. subdivisions?: number;
  116592. minHeight?: number;
  116593. maxHeight?: number;
  116594. colorFilter?: Color3;
  116595. alphaFilter?: number;
  116596. updatable?: boolean;
  116597. onReady?: (mesh: GroundMesh) => void;
  116598. }, scene?: Nullable<Scene>): GroundMesh;
  116599. /**
  116600. * Creates a polygon mesh
  116601. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  116602. * * 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
  116603. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  116604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  116606. * * Remember you can only change the shape positions, not their number when updating a polygon
  116607. * @param name defines the name of the mesh
  116608. * @param options defines the options used to create the mesh
  116609. * @param scene defines the hosting scene
  116610. * @param earcutInjection can be used to inject your own earcut reference
  116611. * @returns the polygon mesh
  116612. */
  116613. static CreatePolygon(name: string, options: {
  116614. shape: Vector3[];
  116615. holes?: Vector3[][];
  116616. depth?: number;
  116617. faceUV?: Vector4[];
  116618. faceColors?: Color4[];
  116619. updatable?: boolean;
  116620. sideOrientation?: number;
  116621. frontUVs?: Vector4;
  116622. backUVs?: Vector4;
  116623. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116624. /**
  116625. * Creates an extruded polygon mesh, with depth in the Y direction.
  116626. * * 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)
  116627. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116628. * @param name defines the name of the mesh
  116629. * @param options defines the options used to create the mesh
  116630. * @param scene defines the hosting scene
  116631. * @param earcutInjection can be used to inject your own earcut reference
  116632. * @returns the polygon mesh
  116633. */
  116634. static ExtrudePolygon(name: string, options: {
  116635. shape: Vector3[];
  116636. holes?: Vector3[][];
  116637. depth?: number;
  116638. faceUV?: Vector4[];
  116639. faceColors?: Color4[];
  116640. updatable?: boolean;
  116641. sideOrientation?: number;
  116642. frontUVs?: Vector4;
  116643. backUVs?: Vector4;
  116644. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116645. /**
  116646. * Creates a tube mesh.
  116647. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116648. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  116649. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  116650. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  116651. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  116652. * * 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)
  116653. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  116654. * * 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
  116655. * * 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
  116656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116658. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116660. * @param name defines the name of the mesh
  116661. * @param options defines the options used to create the mesh
  116662. * @param scene defines the hosting scene
  116663. * @returns the tube mesh
  116664. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116665. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  116666. */
  116667. static CreateTube(name: string, options: {
  116668. path: Vector3[];
  116669. radius?: number;
  116670. tessellation?: number;
  116671. radiusFunction?: {
  116672. (i: number, distance: number): number;
  116673. };
  116674. cap?: number;
  116675. arc?: number;
  116676. updatable?: boolean;
  116677. sideOrientation?: number;
  116678. frontUVs?: Vector4;
  116679. backUVs?: Vector4;
  116680. instance?: Mesh;
  116681. invertUV?: boolean;
  116682. }, scene?: Nullable<Scene>): Mesh;
  116683. /**
  116684. * Creates a polyhedron mesh
  116685. * * 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
  116686. * * The parameter `size` (positive float, default 1) sets the polygon size
  116687. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  116688. * * 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`
  116689. * * 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
  116690. * * 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)`)
  116691. * * 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
  116692. * * 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
  116693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116694. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116696. * @param name defines the name of the mesh
  116697. * @param options defines the options used to create the mesh
  116698. * @param scene defines the hosting scene
  116699. * @returns the polyhedron mesh
  116700. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  116701. */
  116702. static CreatePolyhedron(name: string, options: {
  116703. type?: number;
  116704. size?: number;
  116705. sizeX?: number;
  116706. sizeY?: number;
  116707. sizeZ?: number;
  116708. custom?: any;
  116709. faceUV?: Vector4[];
  116710. faceColors?: Color4[];
  116711. flat?: boolean;
  116712. updatable?: boolean;
  116713. sideOrientation?: number;
  116714. frontUVs?: Vector4;
  116715. backUVs?: Vector4;
  116716. }, scene?: Nullable<Scene>): Mesh;
  116717. /**
  116718. * Creates a decal mesh.
  116719. * 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
  116720. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  116721. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  116722. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  116723. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  116724. * @param name defines the name of the mesh
  116725. * @param sourceMesh defines the mesh where the decal must be applied
  116726. * @param options defines the options used to create the mesh
  116727. * @param scene defines the hosting scene
  116728. * @returns the decal mesh
  116729. * @see https://doc.babylonjs.com/how_to/decals
  116730. */
  116731. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  116732. position?: Vector3;
  116733. normal?: Vector3;
  116734. size?: Vector3;
  116735. angle?: number;
  116736. }): Mesh;
  116737. }
  116738. }
  116739. declare module BABYLON {
  116740. /**
  116741. * A simplifier interface for future simplification implementations
  116742. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116743. */
  116744. export interface ISimplifier {
  116745. /**
  116746. * Simplification of a given mesh according to the given settings.
  116747. * Since this requires computation, it is assumed that the function runs async.
  116748. * @param settings The settings of the simplification, including quality and distance
  116749. * @param successCallback A callback that will be called after the mesh was simplified.
  116750. * @param errorCallback in case of an error, this callback will be called. optional.
  116751. */
  116752. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  116753. }
  116754. /**
  116755. * Expected simplification settings.
  116756. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  116757. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116758. */
  116759. export interface ISimplificationSettings {
  116760. /**
  116761. * Gets or sets the expected quality
  116762. */
  116763. quality: number;
  116764. /**
  116765. * Gets or sets the distance when this optimized version should be used
  116766. */
  116767. distance: number;
  116768. /**
  116769. * Gets an already optimized mesh
  116770. */
  116771. optimizeMesh?: boolean;
  116772. }
  116773. /**
  116774. * Class used to specify simplification options
  116775. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116776. */
  116777. export class SimplificationSettings implements ISimplificationSettings {
  116778. /** expected quality */
  116779. quality: number;
  116780. /** distance when this optimized version should be used */
  116781. distance: number;
  116782. /** already optimized mesh */
  116783. optimizeMesh?: boolean | undefined;
  116784. /**
  116785. * Creates a SimplificationSettings
  116786. * @param quality expected quality
  116787. * @param distance distance when this optimized version should be used
  116788. * @param optimizeMesh already optimized mesh
  116789. */
  116790. constructor(
  116791. /** expected quality */
  116792. quality: number,
  116793. /** distance when this optimized version should be used */
  116794. distance: number,
  116795. /** already optimized mesh */
  116796. optimizeMesh?: boolean | undefined);
  116797. }
  116798. /**
  116799. * Interface used to define a simplification task
  116800. */
  116801. export interface ISimplificationTask {
  116802. /**
  116803. * Array of settings
  116804. */
  116805. settings: Array<ISimplificationSettings>;
  116806. /**
  116807. * Simplification type
  116808. */
  116809. simplificationType: SimplificationType;
  116810. /**
  116811. * Mesh to simplify
  116812. */
  116813. mesh: Mesh;
  116814. /**
  116815. * Callback called on success
  116816. */
  116817. successCallback?: () => void;
  116818. /**
  116819. * Defines if parallel processing can be used
  116820. */
  116821. parallelProcessing: boolean;
  116822. }
  116823. /**
  116824. * Queue used to order the simplification tasks
  116825. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116826. */
  116827. export class SimplificationQueue {
  116828. private _simplificationArray;
  116829. /**
  116830. * Gets a boolean indicating that the process is still running
  116831. */
  116832. running: boolean;
  116833. /**
  116834. * Creates a new queue
  116835. */
  116836. constructor();
  116837. /**
  116838. * Adds a new simplification task
  116839. * @param task defines a task to add
  116840. */
  116841. addTask(task: ISimplificationTask): void;
  116842. /**
  116843. * Execute next task
  116844. */
  116845. executeNext(): void;
  116846. /**
  116847. * Execute a simplification task
  116848. * @param task defines the task to run
  116849. */
  116850. runSimplification(task: ISimplificationTask): void;
  116851. private getSimplifier;
  116852. }
  116853. /**
  116854. * The implemented types of simplification
  116855. * At the moment only Quadratic Error Decimation is implemented
  116856. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116857. */
  116858. export enum SimplificationType {
  116859. /** Quadratic error decimation */
  116860. QUADRATIC = 0
  116861. }
  116862. }
  116863. declare module BABYLON {
  116864. interface Scene {
  116865. /** @hidden (Backing field) */
  116866. _simplificationQueue: SimplificationQueue;
  116867. /**
  116868. * Gets or sets the simplification queue attached to the scene
  116869. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116870. */
  116871. simplificationQueue: SimplificationQueue;
  116872. }
  116873. interface Mesh {
  116874. /**
  116875. * Simplify the mesh according to the given array of settings.
  116876. * Function will return immediately and will simplify async
  116877. * @param settings a collection of simplification settings
  116878. * @param parallelProcessing should all levels calculate parallel or one after the other
  116879. * @param simplificationType the type of simplification to run
  116880. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  116881. * @returns the current mesh
  116882. */
  116883. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  116884. }
  116885. /**
  116886. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  116887. * created in a scene
  116888. */
  116889. export class SimplicationQueueSceneComponent implements ISceneComponent {
  116890. /**
  116891. * The component name helpfull to identify the component in the list of scene components.
  116892. */
  116893. readonly name: string;
  116894. /**
  116895. * The scene the component belongs to.
  116896. */
  116897. scene: Scene;
  116898. /**
  116899. * Creates a new instance of the component for the given scene
  116900. * @param scene Defines the scene to register the component in
  116901. */
  116902. constructor(scene: Scene);
  116903. /**
  116904. * Registers the component in a given scene
  116905. */
  116906. register(): void;
  116907. /**
  116908. * Rebuilds the elements related to this component in case of
  116909. * context lost for instance.
  116910. */
  116911. rebuild(): void;
  116912. /**
  116913. * Disposes the component and the associated ressources
  116914. */
  116915. dispose(): void;
  116916. private _beforeCameraUpdate;
  116917. }
  116918. }
  116919. declare module BABYLON {
  116920. /**
  116921. * Class used to enable access to IndexedDB
  116922. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116923. */
  116924. export class Database implements IOfflineProvider {
  116925. private _callbackManifestChecked;
  116926. private _currentSceneUrl;
  116927. private _db;
  116928. private _enableSceneOffline;
  116929. private _enableTexturesOffline;
  116930. private _manifestVersionFound;
  116931. private _mustUpdateRessources;
  116932. private _hasReachedQuota;
  116933. private _isSupported;
  116934. private _idbFactory;
  116935. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  116936. private static IsUASupportingBlobStorage;
  116937. /**
  116938. * Gets a boolean indicating if Database storate is enabled (off by default)
  116939. */
  116940. static IDBStorageEnabled: boolean;
  116941. /**
  116942. * Gets a boolean indicating if scene must be saved in the database
  116943. */
  116944. readonly enableSceneOffline: boolean;
  116945. /**
  116946. * Gets a boolean indicating if textures must be saved in the database
  116947. */
  116948. readonly enableTexturesOffline: boolean;
  116949. /**
  116950. * Creates a new Database
  116951. * @param urlToScene defines the url to load the scene
  116952. * @param callbackManifestChecked defines the callback to use when manifest is checked
  116953. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  116954. */
  116955. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  116956. private static _ParseURL;
  116957. private static _ReturnFullUrlLocation;
  116958. private _checkManifestFile;
  116959. /**
  116960. * Open the database and make it available
  116961. * @param successCallback defines the callback to call on success
  116962. * @param errorCallback defines the callback to call on error
  116963. */
  116964. open(successCallback: () => void, errorCallback: () => void): void;
  116965. /**
  116966. * Loads an image from the database
  116967. * @param url defines the url to load from
  116968. * @param image defines the target DOM image
  116969. */
  116970. loadImage(url: string, image: HTMLImageElement): void;
  116971. private _loadImageFromDBAsync;
  116972. private _saveImageIntoDBAsync;
  116973. private _checkVersionFromDB;
  116974. private _loadVersionFromDBAsync;
  116975. private _saveVersionIntoDBAsync;
  116976. /**
  116977. * Loads a file from database
  116978. * @param url defines the URL to load from
  116979. * @param sceneLoaded defines a callback to call on success
  116980. * @param progressCallBack defines a callback to call when progress changed
  116981. * @param errorCallback defines a callback to call on error
  116982. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  116983. */
  116984. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  116985. private _loadFileAsync;
  116986. private _saveFileAsync;
  116987. /**
  116988. * Validates if xhr data is correct
  116989. * @param xhr defines the request to validate
  116990. * @param dataType defines the expected data type
  116991. * @returns true if data is correct
  116992. */
  116993. private static _ValidateXHRData;
  116994. }
  116995. }
  116996. declare module BABYLON {
  116997. /** @hidden */
  116998. export var gpuUpdateParticlesPixelShader: {
  116999. name: string;
  117000. shader: string;
  117001. };
  117002. }
  117003. declare module BABYLON {
  117004. /** @hidden */
  117005. export var gpuUpdateParticlesVertexShader: {
  117006. name: string;
  117007. shader: string;
  117008. };
  117009. }
  117010. declare module BABYLON {
  117011. /** @hidden */
  117012. export var clipPlaneFragmentDeclaration2: {
  117013. name: string;
  117014. shader: string;
  117015. };
  117016. }
  117017. declare module BABYLON {
  117018. /** @hidden */
  117019. export var gpuRenderParticlesPixelShader: {
  117020. name: string;
  117021. shader: string;
  117022. };
  117023. }
  117024. declare module BABYLON {
  117025. /** @hidden */
  117026. export var clipPlaneVertexDeclaration2: {
  117027. name: string;
  117028. shader: string;
  117029. };
  117030. }
  117031. declare module BABYLON {
  117032. /** @hidden */
  117033. export var gpuRenderParticlesVertexShader: {
  117034. name: string;
  117035. shader: string;
  117036. };
  117037. }
  117038. declare module BABYLON {
  117039. /**
  117040. * This represents a GPU particle system in Babylon
  117041. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  117042. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  117043. */
  117044. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  117045. /**
  117046. * The layer mask we are rendering the particles through.
  117047. */
  117048. layerMask: number;
  117049. private _capacity;
  117050. private _activeCount;
  117051. private _currentActiveCount;
  117052. private _accumulatedCount;
  117053. private _renderEffect;
  117054. private _updateEffect;
  117055. private _buffer0;
  117056. private _buffer1;
  117057. private _spriteBuffer;
  117058. private _updateVAO;
  117059. private _renderVAO;
  117060. private _targetIndex;
  117061. private _sourceBuffer;
  117062. private _targetBuffer;
  117063. private _engine;
  117064. private _currentRenderId;
  117065. private _started;
  117066. private _stopped;
  117067. private _timeDelta;
  117068. private _randomTexture;
  117069. private _randomTexture2;
  117070. private _attributesStrideSize;
  117071. private _updateEffectOptions;
  117072. private _randomTextureSize;
  117073. private _actualFrame;
  117074. private readonly _rawTextureWidth;
  117075. /**
  117076. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  117077. */
  117078. static readonly IsSupported: boolean;
  117079. /**
  117080. * An event triggered when the system is disposed.
  117081. */
  117082. onDisposeObservable: Observable<GPUParticleSystem>;
  117083. /**
  117084. * Gets the maximum number of particles active at the same time.
  117085. * @returns The max number of active particles.
  117086. */
  117087. getCapacity(): number;
  117088. /**
  117089. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  117090. * to override the particles.
  117091. */
  117092. forceDepthWrite: boolean;
  117093. /**
  117094. * Gets or set the number of active particles
  117095. */
  117096. activeParticleCount: number;
  117097. private _preWarmDone;
  117098. /**
  117099. * Is this system ready to be used/rendered
  117100. * @return true if the system is ready
  117101. */
  117102. isReady(): boolean;
  117103. /**
  117104. * Gets if the system has been started. (Note: this will still be true after stop is called)
  117105. * @returns True if it has been started, otherwise false.
  117106. */
  117107. isStarted(): boolean;
  117108. /**
  117109. * Starts the particle system and begins to emit
  117110. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  117111. */
  117112. start(delay?: number): void;
  117113. /**
  117114. * Stops the particle system.
  117115. */
  117116. stop(): void;
  117117. /**
  117118. * Remove all active particles
  117119. */
  117120. reset(): void;
  117121. /**
  117122. * Returns the string "GPUParticleSystem"
  117123. * @returns a string containing the class name
  117124. */
  117125. getClassName(): string;
  117126. private _colorGradientsTexture;
  117127. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  117128. /**
  117129. * Adds a new color gradient
  117130. * @param gradient defines the gradient to use (between 0 and 1)
  117131. * @param color1 defines the color to affect to the specified gradient
  117132. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  117133. * @returns the current particle system
  117134. */
  117135. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  117136. /**
  117137. * Remove a specific color gradient
  117138. * @param gradient defines the gradient to remove
  117139. * @returns the current particle system
  117140. */
  117141. removeColorGradient(gradient: number): GPUParticleSystem;
  117142. private _angularSpeedGradientsTexture;
  117143. private _sizeGradientsTexture;
  117144. private _velocityGradientsTexture;
  117145. private _limitVelocityGradientsTexture;
  117146. private _dragGradientsTexture;
  117147. private _addFactorGradient;
  117148. /**
  117149. * Adds a new size gradient
  117150. * @param gradient defines the gradient to use (between 0 and 1)
  117151. * @param factor defines the size factor to affect to the specified gradient
  117152. * @returns the current particle system
  117153. */
  117154. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  117155. /**
  117156. * Remove a specific size gradient
  117157. * @param gradient defines the gradient to remove
  117158. * @returns the current particle system
  117159. */
  117160. removeSizeGradient(gradient: number): GPUParticleSystem;
  117161. /**
  117162. * Adds a new angular speed gradient
  117163. * @param gradient defines the gradient to use (between 0 and 1)
  117164. * @param factor defines the angular speed to affect to the specified gradient
  117165. * @returns the current particle system
  117166. */
  117167. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  117168. /**
  117169. * Remove a specific angular speed gradient
  117170. * @param gradient defines the gradient to remove
  117171. * @returns the current particle system
  117172. */
  117173. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  117174. /**
  117175. * Adds a new velocity gradient
  117176. * @param gradient defines the gradient to use (between 0 and 1)
  117177. * @param factor defines the velocity to affect to the specified gradient
  117178. * @returns the current particle system
  117179. */
  117180. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  117181. /**
  117182. * Remove a specific velocity gradient
  117183. * @param gradient defines the gradient to remove
  117184. * @returns the current particle system
  117185. */
  117186. removeVelocityGradient(gradient: number): GPUParticleSystem;
  117187. /**
  117188. * Adds a new limit velocity gradient
  117189. * @param gradient defines the gradient to use (between 0 and 1)
  117190. * @param factor defines the limit velocity value to affect to the specified gradient
  117191. * @returns the current particle system
  117192. */
  117193. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  117194. /**
  117195. * Remove a specific limit velocity gradient
  117196. * @param gradient defines the gradient to remove
  117197. * @returns the current particle system
  117198. */
  117199. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  117200. /**
  117201. * Adds a new drag gradient
  117202. * @param gradient defines the gradient to use (between 0 and 1)
  117203. * @param factor defines the drag value to affect to the specified gradient
  117204. * @returns the current particle system
  117205. */
  117206. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  117207. /**
  117208. * Remove a specific drag gradient
  117209. * @param gradient defines the gradient to remove
  117210. * @returns the current particle system
  117211. */
  117212. removeDragGradient(gradient: number): GPUParticleSystem;
  117213. /**
  117214. * Not supported by GPUParticleSystem
  117215. * @param gradient defines the gradient to use (between 0 and 1)
  117216. * @param factor defines the emit rate value to affect to the specified gradient
  117217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117218. * @returns the current particle system
  117219. */
  117220. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117221. /**
  117222. * Not supported by GPUParticleSystem
  117223. * @param gradient defines the gradient to remove
  117224. * @returns the current particle system
  117225. */
  117226. removeEmitRateGradient(gradient: number): IParticleSystem;
  117227. /**
  117228. * Not supported by GPUParticleSystem
  117229. * @param gradient defines the gradient to use (between 0 and 1)
  117230. * @param factor defines the start size value to affect to the specified gradient
  117231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117232. * @returns the current particle system
  117233. */
  117234. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117235. /**
  117236. * Not supported by GPUParticleSystem
  117237. * @param gradient defines the gradient to remove
  117238. * @returns the current particle system
  117239. */
  117240. removeStartSizeGradient(gradient: number): IParticleSystem;
  117241. /**
  117242. * Not supported by GPUParticleSystem
  117243. * @param gradient defines the gradient to use (between 0 and 1)
  117244. * @param min defines the color remap minimal range
  117245. * @param max defines the color remap maximal range
  117246. * @returns the current particle system
  117247. */
  117248. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117249. /**
  117250. * Not supported by GPUParticleSystem
  117251. * @param gradient defines the gradient to remove
  117252. * @returns the current particle system
  117253. */
  117254. removeColorRemapGradient(): IParticleSystem;
  117255. /**
  117256. * Not supported by GPUParticleSystem
  117257. * @param gradient defines the gradient to use (between 0 and 1)
  117258. * @param min defines the alpha remap minimal range
  117259. * @param max defines the alpha remap maximal range
  117260. * @returns the current particle system
  117261. */
  117262. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117263. /**
  117264. * Not supported by GPUParticleSystem
  117265. * @param gradient defines the gradient to remove
  117266. * @returns the current particle system
  117267. */
  117268. removeAlphaRemapGradient(): IParticleSystem;
  117269. /**
  117270. * Not supported by GPUParticleSystem
  117271. * @param gradient defines the gradient to use (between 0 and 1)
  117272. * @param color defines the color to affect to the specified gradient
  117273. * @returns the current particle system
  117274. */
  117275. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  117276. /**
  117277. * Not supported by GPUParticleSystem
  117278. * @param gradient defines the gradient to remove
  117279. * @returns the current particle system
  117280. */
  117281. removeRampGradient(): IParticleSystem;
  117282. /**
  117283. * Not supported by GPUParticleSystem
  117284. * @returns the list of ramp gradients
  117285. */
  117286. getRampGradients(): Nullable<Array<Color3Gradient>>;
  117287. /**
  117288. * Not supported by GPUParticleSystem
  117289. * Gets or sets a boolean indicating that ramp gradients must be used
  117290. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  117291. */
  117292. useRampGradients: boolean;
  117293. /**
  117294. * Not supported by GPUParticleSystem
  117295. * @param gradient defines the gradient to use (between 0 and 1)
  117296. * @param factor defines the life time factor to affect to the specified gradient
  117297. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117298. * @returns the current particle system
  117299. */
  117300. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117301. /**
  117302. * Not supported by GPUParticleSystem
  117303. * @param gradient defines the gradient to remove
  117304. * @returns the current particle system
  117305. */
  117306. removeLifeTimeGradient(gradient: number): IParticleSystem;
  117307. /**
  117308. * Instantiates a GPU particle system.
  117309. * 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.
  117310. * @param name The name of the particle system
  117311. * @param options The options used to create the system
  117312. * @param scene The scene the particle system belongs to
  117313. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  117314. */
  117315. constructor(name: string, options: Partial<{
  117316. capacity: number;
  117317. randomTextureSize: number;
  117318. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  117319. protected _reset(): void;
  117320. private _createUpdateVAO;
  117321. private _createRenderVAO;
  117322. private _initialize;
  117323. /** @hidden */
  117324. _recreateUpdateEffect(): void;
  117325. /** @hidden */
  117326. _recreateRenderEffect(): void;
  117327. /**
  117328. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  117329. * @param preWarm defines if we are in the pre-warmimg phase
  117330. */
  117331. animate(preWarm?: boolean): void;
  117332. private _createFactorGradientTexture;
  117333. private _createSizeGradientTexture;
  117334. private _createAngularSpeedGradientTexture;
  117335. private _createVelocityGradientTexture;
  117336. private _createLimitVelocityGradientTexture;
  117337. private _createDragGradientTexture;
  117338. private _createColorGradientTexture;
  117339. /**
  117340. * Renders the particle system in its current state
  117341. * @param preWarm defines if the system should only update the particles but not render them
  117342. * @returns the current number of particles
  117343. */
  117344. render(preWarm?: boolean): number;
  117345. /**
  117346. * Rebuilds the particle system
  117347. */
  117348. rebuild(): void;
  117349. private _releaseBuffers;
  117350. private _releaseVAOs;
  117351. /**
  117352. * Disposes the particle system and free the associated resources
  117353. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  117354. */
  117355. dispose(disposeTexture?: boolean): void;
  117356. /**
  117357. * Clones the particle system.
  117358. * @param name The name of the cloned object
  117359. * @param newEmitter The new emitter to use
  117360. * @returns the cloned particle system
  117361. */
  117362. clone(name: string, newEmitter: any): GPUParticleSystem;
  117363. /**
  117364. * Serializes the particle system to a JSON object.
  117365. * @returns the JSON object
  117366. */
  117367. serialize(): any;
  117368. /**
  117369. * Parses a JSON object to create a GPU particle system.
  117370. * @param parsedParticleSystem The JSON object to parse
  117371. * @param scene The scene to create the particle system in
  117372. * @param rootUrl The root url to use to load external dependencies like texture
  117373. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  117374. * @returns the parsed GPU particle system
  117375. */
  117376. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  117377. }
  117378. }
  117379. declare module BABYLON {
  117380. /**
  117381. * Represents a set of particle systems working together to create a specific effect
  117382. */
  117383. export class ParticleSystemSet implements IDisposable {
  117384. private _emitterCreationOptions;
  117385. private _emitterNode;
  117386. /**
  117387. * Gets the particle system list
  117388. */
  117389. systems: IParticleSystem[];
  117390. /**
  117391. * Gets the emitter node used with this set
  117392. */
  117393. readonly emitterNode: Nullable<TransformNode>;
  117394. /**
  117395. * Creates a new emitter mesh as a sphere
  117396. * @param options defines the options used to create the sphere
  117397. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  117398. * @param scene defines the hosting scene
  117399. */
  117400. setEmitterAsSphere(options: {
  117401. diameter: number;
  117402. segments: number;
  117403. color: Color3;
  117404. }, renderingGroupId: number, scene: Scene): void;
  117405. /**
  117406. * Starts all particle systems of the set
  117407. * @param emitter defines an optional mesh to use as emitter for the particle systems
  117408. */
  117409. start(emitter?: AbstractMesh): void;
  117410. /**
  117411. * Release all associated resources
  117412. */
  117413. dispose(): void;
  117414. /**
  117415. * Serialize the set into a JSON compatible object
  117416. * @returns a JSON compatible representation of the set
  117417. */
  117418. serialize(): any;
  117419. /**
  117420. * Parse a new ParticleSystemSet from a serialized source
  117421. * @param data defines a JSON compatible representation of the set
  117422. * @param scene defines the hosting scene
  117423. * @param gpu defines if we want GPU particles or CPU particles
  117424. * @returns a new ParticleSystemSet
  117425. */
  117426. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  117427. }
  117428. }
  117429. declare module BABYLON {
  117430. /**
  117431. * This class is made for on one-liner static method to help creating particle system set.
  117432. */
  117433. export class ParticleHelper {
  117434. /**
  117435. * Gets or sets base Assets URL
  117436. */
  117437. static BaseAssetsUrl: string;
  117438. /**
  117439. * Create a default particle system that you can tweak
  117440. * @param emitter defines the emitter to use
  117441. * @param capacity defines the system capacity (default is 500 particles)
  117442. * @param scene defines the hosting scene
  117443. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  117444. * @returns the new Particle system
  117445. */
  117446. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  117447. /**
  117448. * This is the main static method (one-liner) of this helper to create different particle systems
  117449. * @param type This string represents the type to the particle system to create
  117450. * @param scene The scene where the particle system should live
  117451. * @param gpu If the system will use gpu
  117452. * @returns the ParticleSystemSet created
  117453. */
  117454. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  117455. /**
  117456. * Static function used to export a particle system to a ParticleSystemSet variable.
  117457. * Please note that the emitter shape is not exported
  117458. * @param systems defines the particle systems to export
  117459. * @returns the created particle system set
  117460. */
  117461. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  117462. }
  117463. }
  117464. declare module BABYLON {
  117465. interface Engine {
  117466. /**
  117467. * Create an effect to use with particle systems.
  117468. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  117469. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  117470. * @param uniformsNames defines a list of attribute names
  117471. * @param samplers defines an array of string used to represent textures
  117472. * @param defines defines the string containing the defines to use to compile the shaders
  117473. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  117474. * @param onCompiled defines a function to call when the effect creation is successful
  117475. * @param onError defines a function to call when the effect creation has failed
  117476. * @returns the new Effect
  117477. */
  117478. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  117479. }
  117480. interface Mesh {
  117481. /**
  117482. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  117483. * @returns an array of IParticleSystem
  117484. */
  117485. getEmittedParticleSystems(): IParticleSystem[];
  117486. /**
  117487. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  117488. * @returns an array of IParticleSystem
  117489. */
  117490. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  117491. }
  117492. /**
  117493. * @hidden
  117494. */
  117495. export var _IDoNeedToBeInTheBuild: number;
  117496. }
  117497. declare module BABYLON {
  117498. interface Scene {
  117499. /** @hidden (Backing field) */
  117500. _physicsEngine: Nullable<IPhysicsEngine>;
  117501. /**
  117502. * Gets the current physics engine
  117503. * @returns a IPhysicsEngine or null if none attached
  117504. */
  117505. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  117506. /**
  117507. * Enables physics to the current scene
  117508. * @param gravity defines the scene's gravity for the physics engine
  117509. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  117510. * @return a boolean indicating if the physics engine was initialized
  117511. */
  117512. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  117513. /**
  117514. * Disables and disposes the physics engine associated with the scene
  117515. */
  117516. disablePhysicsEngine(): void;
  117517. /**
  117518. * Gets a boolean indicating if there is an active physics engine
  117519. * @returns a boolean indicating if there is an active physics engine
  117520. */
  117521. isPhysicsEnabled(): boolean;
  117522. /**
  117523. * Deletes a physics compound impostor
  117524. * @param compound defines the compound to delete
  117525. */
  117526. deleteCompoundImpostor(compound: any): void;
  117527. /**
  117528. * An event triggered when physic simulation is about to be run
  117529. */
  117530. onBeforePhysicsObservable: Observable<Scene>;
  117531. /**
  117532. * An event triggered when physic simulation has been done
  117533. */
  117534. onAfterPhysicsObservable: Observable<Scene>;
  117535. }
  117536. interface AbstractMesh {
  117537. /** @hidden */
  117538. _physicsImpostor: Nullable<PhysicsImpostor>;
  117539. /**
  117540. * Gets or sets impostor used for physic simulation
  117541. * @see http://doc.babylonjs.com/features/physics_engine
  117542. */
  117543. physicsImpostor: Nullable<PhysicsImpostor>;
  117544. /**
  117545. * Gets the current physics impostor
  117546. * @see http://doc.babylonjs.com/features/physics_engine
  117547. * @returns a physics impostor or null
  117548. */
  117549. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  117550. /** Apply a physic impulse to the mesh
  117551. * @param force defines the force to apply
  117552. * @param contactPoint defines where to apply the force
  117553. * @returns the current mesh
  117554. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117555. */
  117556. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  117557. /**
  117558. * Creates a physic joint between two meshes
  117559. * @param otherMesh defines the other mesh to use
  117560. * @param pivot1 defines the pivot to use on this mesh
  117561. * @param pivot2 defines the pivot to use on the other mesh
  117562. * @param options defines additional options (can be plugin dependent)
  117563. * @returns the current mesh
  117564. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  117565. */
  117566. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  117567. /** @hidden */
  117568. _disposePhysicsObserver: Nullable<Observer<Node>>;
  117569. }
  117570. /**
  117571. * Defines the physics engine scene component responsible to manage a physics engine
  117572. */
  117573. export class PhysicsEngineSceneComponent implements ISceneComponent {
  117574. /**
  117575. * The component name helpful to identify the component in the list of scene components.
  117576. */
  117577. readonly name: string;
  117578. /**
  117579. * The scene the component belongs to.
  117580. */
  117581. scene: Scene;
  117582. /**
  117583. * Creates a new instance of the component for the given scene
  117584. * @param scene Defines the scene to register the component in
  117585. */
  117586. constructor(scene: Scene);
  117587. /**
  117588. * Registers the component in a given scene
  117589. */
  117590. register(): void;
  117591. /**
  117592. * Rebuilds the elements related to this component in case of
  117593. * context lost for instance.
  117594. */
  117595. rebuild(): void;
  117596. /**
  117597. * Disposes the component and the associated ressources
  117598. */
  117599. dispose(): void;
  117600. }
  117601. }
  117602. declare module BABYLON {
  117603. /**
  117604. * A helper for physics simulations
  117605. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117606. */
  117607. export class PhysicsHelper {
  117608. private _scene;
  117609. private _physicsEngine;
  117610. /**
  117611. * Initializes the Physics helper
  117612. * @param scene Babylon.js scene
  117613. */
  117614. constructor(scene: Scene);
  117615. /**
  117616. * Applies a radial explosion impulse
  117617. * @param origin the origin of the explosion
  117618. * @param radiusOrEventOptions the radius or the options of radial explosion
  117619. * @param strength the explosion strength
  117620. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117621. * @returns A physics radial explosion event, or null
  117622. */
  117623. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117624. /**
  117625. * Applies a radial explosion force
  117626. * @param origin the origin of the explosion
  117627. * @param radiusOrEventOptions the radius or the options of radial explosion
  117628. * @param strength the explosion strength
  117629. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117630. * @returns A physics radial explosion event, or null
  117631. */
  117632. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117633. /**
  117634. * Creates a gravitational field
  117635. * @param origin the origin of the explosion
  117636. * @param radiusOrEventOptions the radius or the options of radial explosion
  117637. * @param strength the explosion strength
  117638. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117639. * @returns A physics gravitational field event, or null
  117640. */
  117641. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  117642. /**
  117643. * Creates a physics updraft event
  117644. * @param origin the origin of the updraft
  117645. * @param radiusOrEventOptions the radius or the options of the updraft
  117646. * @param strength the strength of the updraft
  117647. * @param height the height of the updraft
  117648. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  117649. * @returns A physics updraft event, or null
  117650. */
  117651. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  117652. /**
  117653. * Creates a physics vortex event
  117654. * @param origin the of the vortex
  117655. * @param radiusOrEventOptions the radius or the options of the vortex
  117656. * @param strength the strength of the vortex
  117657. * @param height the height of the vortex
  117658. * @returns a Physics vortex event, or null
  117659. * A physics vortex event or null
  117660. */
  117661. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  117662. }
  117663. /**
  117664. * Represents a physics radial explosion event
  117665. */
  117666. class PhysicsRadialExplosionEvent {
  117667. private _scene;
  117668. private _options;
  117669. private _sphere;
  117670. private _dataFetched;
  117671. /**
  117672. * Initializes a radial explosioin event
  117673. * @param _scene BabylonJS scene
  117674. * @param _options The options for the vortex event
  117675. */
  117676. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  117677. /**
  117678. * Returns the data related to the radial explosion event (sphere).
  117679. * @returns The radial explosion event data
  117680. */
  117681. getData(): PhysicsRadialExplosionEventData;
  117682. /**
  117683. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  117684. * @param impostor A physics imposter
  117685. * @param origin the origin of the explosion
  117686. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  117687. */
  117688. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  117689. /**
  117690. * Triggers affecterd impostors callbacks
  117691. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  117692. */
  117693. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  117694. /**
  117695. * Disposes the sphere.
  117696. * @param force Specifies if the sphere should be disposed by force
  117697. */
  117698. dispose(force?: boolean): void;
  117699. /*** Helpers ***/
  117700. private _prepareSphere;
  117701. private _intersectsWithSphere;
  117702. }
  117703. /**
  117704. * Represents a gravitational field event
  117705. */
  117706. class PhysicsGravitationalFieldEvent {
  117707. private _physicsHelper;
  117708. private _scene;
  117709. private _origin;
  117710. private _options;
  117711. private _tickCallback;
  117712. private _sphere;
  117713. private _dataFetched;
  117714. /**
  117715. * Initializes the physics gravitational field event
  117716. * @param _physicsHelper A physics helper
  117717. * @param _scene BabylonJS scene
  117718. * @param _origin The origin position of the gravitational field event
  117719. * @param _options The options for the vortex event
  117720. */
  117721. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  117722. /**
  117723. * Returns the data related to the gravitational field event (sphere).
  117724. * @returns A gravitational field event
  117725. */
  117726. getData(): PhysicsGravitationalFieldEventData;
  117727. /**
  117728. * Enables the gravitational field.
  117729. */
  117730. enable(): void;
  117731. /**
  117732. * Disables the gravitational field.
  117733. */
  117734. disable(): void;
  117735. /**
  117736. * Disposes the sphere.
  117737. * @param force The force to dispose from the gravitational field event
  117738. */
  117739. dispose(force?: boolean): void;
  117740. private _tick;
  117741. }
  117742. /**
  117743. * Represents a physics updraft event
  117744. */
  117745. class PhysicsUpdraftEvent {
  117746. private _scene;
  117747. private _origin;
  117748. private _options;
  117749. private _physicsEngine;
  117750. private _originTop;
  117751. private _originDirection;
  117752. private _tickCallback;
  117753. private _cylinder;
  117754. private _cylinderPosition;
  117755. private _dataFetched;
  117756. /**
  117757. * Initializes the physics updraft event
  117758. * @param _scene BabylonJS scene
  117759. * @param _origin The origin position of the updraft
  117760. * @param _options The options for the updraft event
  117761. */
  117762. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  117763. /**
  117764. * Returns the data related to the updraft event (cylinder).
  117765. * @returns A physics updraft event
  117766. */
  117767. getData(): PhysicsUpdraftEventData;
  117768. /**
  117769. * Enables the updraft.
  117770. */
  117771. enable(): void;
  117772. /**
  117773. * Disables the updraft.
  117774. */
  117775. disable(): void;
  117776. /**
  117777. * Disposes the cylinder.
  117778. * @param force Specifies if the updraft should be disposed by force
  117779. */
  117780. dispose(force?: boolean): void;
  117781. private getImpostorHitData;
  117782. private _tick;
  117783. /*** Helpers ***/
  117784. private _prepareCylinder;
  117785. private _intersectsWithCylinder;
  117786. }
  117787. /**
  117788. * Represents a physics vortex event
  117789. */
  117790. class PhysicsVortexEvent {
  117791. private _scene;
  117792. private _origin;
  117793. private _options;
  117794. private _physicsEngine;
  117795. private _originTop;
  117796. private _tickCallback;
  117797. private _cylinder;
  117798. private _cylinderPosition;
  117799. private _dataFetched;
  117800. /**
  117801. * Initializes the physics vortex event
  117802. * @param _scene The BabylonJS scene
  117803. * @param _origin The origin position of the vortex
  117804. * @param _options The options for the vortex event
  117805. */
  117806. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  117807. /**
  117808. * Returns the data related to the vortex event (cylinder).
  117809. * @returns The physics vortex event data
  117810. */
  117811. getData(): PhysicsVortexEventData;
  117812. /**
  117813. * Enables the vortex.
  117814. */
  117815. enable(): void;
  117816. /**
  117817. * Disables the cortex.
  117818. */
  117819. disable(): void;
  117820. /**
  117821. * Disposes the sphere.
  117822. * @param force
  117823. */
  117824. dispose(force?: boolean): void;
  117825. private getImpostorHitData;
  117826. private _tick;
  117827. /*** Helpers ***/
  117828. private _prepareCylinder;
  117829. private _intersectsWithCylinder;
  117830. }
  117831. /**
  117832. * Options fot the radial explosion event
  117833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117834. */
  117835. export class PhysicsRadialExplosionEventOptions {
  117836. /**
  117837. * The radius of the sphere for the radial explosion.
  117838. */
  117839. radius: number;
  117840. /**
  117841. * The strenth of the explosion.
  117842. */
  117843. strength: number;
  117844. /**
  117845. * The strenght of the force in correspondence to the distance of the affected object
  117846. */
  117847. falloff: PhysicsRadialImpulseFalloff;
  117848. /**
  117849. * Sphere options for the radial explosion.
  117850. */
  117851. sphere: {
  117852. segments: number;
  117853. diameter: number;
  117854. };
  117855. /**
  117856. * Sphere options for the radial explosion.
  117857. */
  117858. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  117859. }
  117860. /**
  117861. * Options fot the updraft event
  117862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117863. */
  117864. export class PhysicsUpdraftEventOptions {
  117865. /**
  117866. * The radius of the cylinder for the vortex
  117867. */
  117868. radius: number;
  117869. /**
  117870. * The strenth of the updraft.
  117871. */
  117872. strength: number;
  117873. /**
  117874. * The height of the cylinder for the updraft.
  117875. */
  117876. height: number;
  117877. /**
  117878. * The mode for the the updraft.
  117879. */
  117880. updraftMode: PhysicsUpdraftMode;
  117881. }
  117882. /**
  117883. * Options fot the vortex event
  117884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117885. */
  117886. export class PhysicsVortexEventOptions {
  117887. /**
  117888. * The radius of the cylinder for the vortex
  117889. */
  117890. radius: number;
  117891. /**
  117892. * The strenth of the vortex.
  117893. */
  117894. strength: number;
  117895. /**
  117896. * The height of the cylinder for the vortex.
  117897. */
  117898. height: number;
  117899. /**
  117900. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117901. */
  117902. centripetalForceThreshold: number;
  117903. /**
  117904. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117905. */
  117906. centripetalForceMultiplier: number;
  117907. /**
  117908. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117909. */
  117910. centrifugalForceMultiplier: number;
  117911. /**
  117912. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117913. */
  117914. updraftForceMultiplier: number;
  117915. }
  117916. /**
  117917. * The strenght of the force in correspondence to the distance of the affected object
  117918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117919. */
  117920. export enum PhysicsRadialImpulseFalloff {
  117921. /** Defines that impulse is constant in strength across it's whole radius */
  117922. Constant = 0,
  117923. /** Defines that impulse gets weaker if it's further from the origin */
  117924. Linear = 1
  117925. }
  117926. /**
  117927. * The strength of the force in correspondence to the distance of the affected object
  117928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117929. */
  117930. export enum PhysicsUpdraftMode {
  117931. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117932. Center = 0,
  117933. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117934. Perpendicular = 1
  117935. }
  117936. /**
  117937. * Interface for a physics hit data
  117938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117939. */
  117940. export interface PhysicsHitData {
  117941. /**
  117942. * The force applied at the contact point
  117943. */
  117944. force: Vector3;
  117945. /**
  117946. * The contact point
  117947. */
  117948. contactPoint: Vector3;
  117949. /**
  117950. * The distance from the origin to the contact point
  117951. */
  117952. distanceFromOrigin: number;
  117953. }
  117954. /**
  117955. * Interface for radial explosion event data
  117956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117957. */
  117958. export interface PhysicsRadialExplosionEventData {
  117959. /**
  117960. * A sphere used for the radial explosion event
  117961. */
  117962. sphere: Mesh;
  117963. }
  117964. /**
  117965. * Interface for gravitational field event data
  117966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117967. */
  117968. export interface PhysicsGravitationalFieldEventData {
  117969. /**
  117970. * A sphere mesh used for the gravitational field event
  117971. */
  117972. sphere: Mesh;
  117973. }
  117974. /**
  117975. * Interface for updraft event data
  117976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117977. */
  117978. export interface PhysicsUpdraftEventData {
  117979. /**
  117980. * A cylinder used for the updraft event
  117981. */
  117982. cylinder: Mesh;
  117983. }
  117984. /**
  117985. * Interface for vortex event data
  117986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117987. */
  117988. export interface PhysicsVortexEventData {
  117989. /**
  117990. * A cylinder used for the vortex event
  117991. */
  117992. cylinder: Mesh;
  117993. }
  117994. /**
  117995. * Interface for an affected physics impostor
  117996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117997. */
  117998. export interface PhysicsAffectedImpostorWithData {
  117999. /**
  118000. * The impostor affected by the effect
  118001. */
  118002. impostor: PhysicsImpostor;
  118003. /**
  118004. * The data about the hit/horce from the explosion
  118005. */
  118006. hitData: PhysicsHitData;
  118007. }
  118008. }
  118009. declare module BABYLON {
  118010. /** @hidden */
  118011. export var blackAndWhitePixelShader: {
  118012. name: string;
  118013. shader: string;
  118014. };
  118015. }
  118016. declare module BABYLON {
  118017. /**
  118018. * Post process used to render in black and white
  118019. */
  118020. export class BlackAndWhitePostProcess extends PostProcess {
  118021. /**
  118022. * Linear about to convert he result to black and white (default: 1)
  118023. */
  118024. degree: number;
  118025. /**
  118026. * Creates a black and white post process
  118027. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  118028. * @param name The name of the effect.
  118029. * @param options The required width/height ratio to downsize to before computing the render pass.
  118030. * @param camera The camera to apply the render pass to.
  118031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118032. * @param engine The engine which the post process will be applied. (default: current engine)
  118033. * @param reusable If the post process can be reused on the same frame. (default: false)
  118034. */
  118035. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118036. }
  118037. }
  118038. declare module BABYLON {
  118039. /**
  118040. * This represents a set of one or more post processes in Babylon.
  118041. * A post process can be used to apply a shader to a texture after it is rendered.
  118042. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118043. */
  118044. export class PostProcessRenderEffect {
  118045. private _postProcesses;
  118046. private _getPostProcesses;
  118047. private _singleInstance;
  118048. private _cameras;
  118049. private _indicesForCamera;
  118050. /**
  118051. * Name of the effect
  118052. * @hidden
  118053. */
  118054. _name: string;
  118055. /**
  118056. * Instantiates a post process render effect.
  118057. * A post process can be used to apply a shader to a texture after it is rendered.
  118058. * @param engine The engine the effect is tied to
  118059. * @param name The name of the effect
  118060. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  118061. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  118062. */
  118063. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  118064. /**
  118065. * Checks if all the post processes in the effect are supported.
  118066. */
  118067. readonly isSupported: boolean;
  118068. /**
  118069. * Updates the current state of the effect
  118070. * @hidden
  118071. */
  118072. _update(): void;
  118073. /**
  118074. * Attaches the effect on cameras
  118075. * @param cameras The camera to attach to.
  118076. * @hidden
  118077. */
  118078. _attachCameras(cameras: Camera): void;
  118079. /**
  118080. * Attaches the effect on cameras
  118081. * @param cameras The camera to attach to.
  118082. * @hidden
  118083. */
  118084. _attachCameras(cameras: Camera[]): void;
  118085. /**
  118086. * Detaches the effect on cameras
  118087. * @param cameras The camera to detatch from.
  118088. * @hidden
  118089. */
  118090. _detachCameras(cameras: Camera): void;
  118091. /**
  118092. * Detatches the effect on cameras
  118093. * @param cameras The camera to detatch from.
  118094. * @hidden
  118095. */
  118096. _detachCameras(cameras: Camera[]): void;
  118097. /**
  118098. * Enables the effect on given cameras
  118099. * @param cameras The camera to enable.
  118100. * @hidden
  118101. */
  118102. _enable(cameras: Camera): void;
  118103. /**
  118104. * Enables the effect on given cameras
  118105. * @param cameras The camera to enable.
  118106. * @hidden
  118107. */
  118108. _enable(cameras: Nullable<Camera[]>): void;
  118109. /**
  118110. * Disables the effect on the given cameras
  118111. * @param cameras The camera to disable.
  118112. * @hidden
  118113. */
  118114. _disable(cameras: Camera): void;
  118115. /**
  118116. * Disables the effect on the given cameras
  118117. * @param cameras The camera to disable.
  118118. * @hidden
  118119. */
  118120. _disable(cameras: Nullable<Camera[]>): void;
  118121. /**
  118122. * Gets a list of the post processes contained in the effect.
  118123. * @param camera The camera to get the post processes on.
  118124. * @returns The list of the post processes in the effect.
  118125. */
  118126. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  118127. }
  118128. }
  118129. declare module BABYLON {
  118130. /** @hidden */
  118131. export var extractHighlightsPixelShader: {
  118132. name: string;
  118133. shader: string;
  118134. };
  118135. }
  118136. declare module BABYLON {
  118137. /**
  118138. * 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.
  118139. */
  118140. export class ExtractHighlightsPostProcess extends PostProcess {
  118141. /**
  118142. * The luminance threshold, pixels below this value will be set to black.
  118143. */
  118144. threshold: number;
  118145. /** @hidden */
  118146. _exposure: number;
  118147. /**
  118148. * Post process which has the input texture to be used when performing highlight extraction
  118149. * @hidden
  118150. */
  118151. _inputPostProcess: Nullable<PostProcess>;
  118152. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118153. }
  118154. }
  118155. declare module BABYLON {
  118156. /** @hidden */
  118157. export var bloomMergePixelShader: {
  118158. name: string;
  118159. shader: string;
  118160. };
  118161. }
  118162. declare module BABYLON {
  118163. /**
  118164. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118165. */
  118166. export class BloomMergePostProcess extends PostProcess {
  118167. /** Weight of the bloom to be added to the original input. */
  118168. weight: number;
  118169. /**
  118170. * Creates a new instance of @see BloomMergePostProcess
  118171. * @param name The name of the effect.
  118172. * @param originalFromInput Post process which's input will be used for the merge.
  118173. * @param blurred Blurred highlights post process which's output will be used.
  118174. * @param weight Weight of the bloom to be added to the original input.
  118175. * @param options The required width/height ratio to downsize to before computing the render pass.
  118176. * @param camera The camera to apply the render pass to.
  118177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118178. * @param engine The engine which the post process will be applied. (default: current engine)
  118179. * @param reusable If the post process can be reused on the same frame. (default: false)
  118180. * @param textureType Type of textures used when performing the post process. (default: 0)
  118181. * @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)
  118182. */
  118183. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  118184. /** Weight of the bloom to be added to the original input. */
  118185. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118186. }
  118187. }
  118188. declare module BABYLON {
  118189. /**
  118190. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  118191. */
  118192. export class BloomEffect extends PostProcessRenderEffect {
  118193. private bloomScale;
  118194. /**
  118195. * @hidden Internal
  118196. */
  118197. _effects: Array<PostProcess>;
  118198. /**
  118199. * @hidden Internal
  118200. */
  118201. _downscale: ExtractHighlightsPostProcess;
  118202. private _blurX;
  118203. private _blurY;
  118204. private _merge;
  118205. /**
  118206. * The luminance threshold to find bright areas of the image to bloom.
  118207. */
  118208. threshold: number;
  118209. /**
  118210. * The strength of the bloom.
  118211. */
  118212. weight: number;
  118213. /**
  118214. * Specifies the size of the bloom blur kernel, relative to the final output size
  118215. */
  118216. kernel: number;
  118217. /**
  118218. * Creates a new instance of @see BloomEffect
  118219. * @param scene The scene the effect belongs to.
  118220. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  118221. * @param bloomKernel The size of the kernel to be used when applying the blur.
  118222. * @param bloomWeight The the strength of bloom.
  118223. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118224. * @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)
  118225. */
  118226. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  118227. /**
  118228. * Disposes each of the internal effects for a given camera.
  118229. * @param camera The camera to dispose the effect on.
  118230. */
  118231. disposeEffects(camera: Camera): void;
  118232. /**
  118233. * @hidden Internal
  118234. */
  118235. _updateEffects(): void;
  118236. /**
  118237. * Internal
  118238. * @returns if all the contained post processes are ready.
  118239. * @hidden
  118240. */
  118241. _isReady(): boolean;
  118242. }
  118243. }
  118244. declare module BABYLON {
  118245. /** @hidden */
  118246. export var chromaticAberrationPixelShader: {
  118247. name: string;
  118248. shader: string;
  118249. };
  118250. }
  118251. declare module BABYLON {
  118252. /**
  118253. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  118254. */
  118255. export class ChromaticAberrationPostProcess extends PostProcess {
  118256. /**
  118257. * The amount of seperation of rgb channels (default: 30)
  118258. */
  118259. aberrationAmount: number;
  118260. /**
  118261. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  118262. */
  118263. radialIntensity: number;
  118264. /**
  118265. * 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))
  118266. */
  118267. direction: Vector2;
  118268. /**
  118269. * 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))
  118270. */
  118271. centerPosition: Vector2;
  118272. /**
  118273. * Creates a new instance ChromaticAberrationPostProcess
  118274. * @param name The name of the effect.
  118275. * @param screenWidth The width of the screen to apply the effect on.
  118276. * @param screenHeight The height of the screen to apply the effect on.
  118277. * @param options The required width/height ratio to downsize to before computing the render pass.
  118278. * @param camera The camera to apply the render pass to.
  118279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118280. * @param engine The engine which the post process will be applied. (default: current engine)
  118281. * @param reusable If the post process can be reused on the same frame. (default: false)
  118282. * @param textureType Type of textures used when performing the post process. (default: 0)
  118283. * @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)
  118284. */
  118285. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118286. }
  118287. }
  118288. declare module BABYLON {
  118289. /** @hidden */
  118290. export var circleOfConfusionPixelShader: {
  118291. name: string;
  118292. shader: string;
  118293. };
  118294. }
  118295. declare module BABYLON {
  118296. /**
  118297. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  118298. */
  118299. export class CircleOfConfusionPostProcess extends PostProcess {
  118300. /**
  118301. * 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.
  118302. */
  118303. lensSize: number;
  118304. /**
  118305. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118306. */
  118307. fStop: number;
  118308. /**
  118309. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118310. */
  118311. focusDistance: number;
  118312. /**
  118313. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  118314. */
  118315. focalLength: number;
  118316. private _depthTexture;
  118317. /**
  118318. * Creates a new instance CircleOfConfusionPostProcess
  118319. * @param name The name of the effect.
  118320. * @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.
  118321. * @param options The required width/height ratio to downsize to before computing the render pass.
  118322. * @param camera The camera to apply the render pass to.
  118323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118324. * @param engine The engine which the post process will be applied. (default: current engine)
  118325. * @param reusable If the post process can be reused on the same frame. (default: false)
  118326. * @param textureType Type of textures used when performing the post process. (default: 0)
  118327. * @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)
  118328. */
  118329. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118330. /**
  118331. * 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.
  118332. */
  118333. depthTexture: RenderTargetTexture;
  118334. }
  118335. }
  118336. declare module BABYLON {
  118337. /** @hidden */
  118338. export var colorCorrectionPixelShader: {
  118339. name: string;
  118340. shader: string;
  118341. };
  118342. }
  118343. declare module BABYLON {
  118344. /**
  118345. *
  118346. * This post-process allows the modification of rendered colors by using
  118347. * a 'look-up table' (LUT). This effect is also called Color Grading.
  118348. *
  118349. * The object needs to be provided an url to a texture containing the color
  118350. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  118351. * Use an image editing software to tweak the LUT to match your needs.
  118352. *
  118353. * For an example of a color LUT, see here:
  118354. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  118355. * For explanations on color grading, see here:
  118356. * @see http://udn.epicgames.com/Three/ColorGrading.html
  118357. *
  118358. */
  118359. export class ColorCorrectionPostProcess extends PostProcess {
  118360. private _colorTableTexture;
  118361. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118362. }
  118363. }
  118364. declare module BABYLON {
  118365. /** @hidden */
  118366. export var convolutionPixelShader: {
  118367. name: string;
  118368. shader: string;
  118369. };
  118370. }
  118371. declare module BABYLON {
  118372. /**
  118373. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  118374. * input texture to perform effects such as edge detection or sharpening
  118375. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118376. */
  118377. export class ConvolutionPostProcess extends PostProcess {
  118378. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118379. kernel: number[];
  118380. /**
  118381. * Creates a new instance ConvolutionPostProcess
  118382. * @param name The name of the effect.
  118383. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  118384. * @param options The required width/height ratio to downsize to before computing the render pass.
  118385. * @param camera The camera to apply the render pass to.
  118386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118387. * @param engine The engine which the post process will be applied. (default: current engine)
  118388. * @param reusable If the post process can be reused on the same frame. (default: false)
  118389. * @param textureType Type of textures used when performing the post process. (default: 0)
  118390. */
  118391. constructor(name: string,
  118392. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118393. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118394. /**
  118395. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118396. */
  118397. static EdgeDetect0Kernel: number[];
  118398. /**
  118399. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118400. */
  118401. static EdgeDetect1Kernel: number[];
  118402. /**
  118403. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118404. */
  118405. static EdgeDetect2Kernel: number[];
  118406. /**
  118407. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118408. */
  118409. static SharpenKernel: number[];
  118410. /**
  118411. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118412. */
  118413. static EmbossKernel: number[];
  118414. /**
  118415. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118416. */
  118417. static GaussianKernel: number[];
  118418. }
  118419. }
  118420. declare module BABYLON {
  118421. /**
  118422. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  118423. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  118424. * based on samples that have a large difference in distance than the center pixel.
  118425. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  118426. */
  118427. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  118428. direction: Vector2;
  118429. /**
  118430. * Creates a new instance CircleOfConfusionPostProcess
  118431. * @param name The name of the effect.
  118432. * @param scene The scene the effect belongs to.
  118433. * @param direction The direction the blur should be applied.
  118434. * @param kernel The size of the kernel used to blur.
  118435. * @param options The required width/height ratio to downsize to before computing the render pass.
  118436. * @param camera The camera to apply the render pass to.
  118437. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  118438. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  118439. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118440. * @param engine The engine which the post process will be applied. (default: current engine)
  118441. * @param reusable If the post process can be reused on the same frame. (default: false)
  118442. * @param textureType Type of textures used when performing the post process. (default: 0)
  118443. * @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)
  118444. */
  118445. 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);
  118446. }
  118447. }
  118448. declare module BABYLON {
  118449. /** @hidden */
  118450. export var depthOfFieldMergePixelShader: {
  118451. name: string;
  118452. shader: string;
  118453. };
  118454. }
  118455. declare module BABYLON {
  118456. /**
  118457. * Options to be set when merging outputs from the default pipeline.
  118458. */
  118459. export class DepthOfFieldMergePostProcessOptions {
  118460. /**
  118461. * The original image to merge on top of
  118462. */
  118463. originalFromInput: PostProcess;
  118464. /**
  118465. * Parameters to perform the merge of the depth of field effect
  118466. */
  118467. depthOfField?: {
  118468. circleOfConfusion: PostProcess;
  118469. blurSteps: Array<PostProcess>;
  118470. };
  118471. /**
  118472. * Parameters to perform the merge of bloom effect
  118473. */
  118474. bloom?: {
  118475. blurred: PostProcess;
  118476. weight: number;
  118477. };
  118478. }
  118479. /**
  118480. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118481. */
  118482. export class DepthOfFieldMergePostProcess extends PostProcess {
  118483. private blurSteps;
  118484. /**
  118485. * Creates a new instance of DepthOfFieldMergePostProcess
  118486. * @param name The name of the effect.
  118487. * @param originalFromInput Post process which's input will be used for the merge.
  118488. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  118489. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  118490. * @param options The required width/height ratio to downsize to before computing the render pass.
  118491. * @param camera The camera to apply the render pass to.
  118492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118493. * @param engine The engine which the post process will be applied. (default: current engine)
  118494. * @param reusable If the post process can be reused on the same frame. (default: false)
  118495. * @param textureType Type of textures used when performing the post process. (default: 0)
  118496. * @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)
  118497. */
  118498. 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);
  118499. /**
  118500. * Updates the effect with the current post process compile time values and recompiles the shader.
  118501. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118502. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118503. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118504. * @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
  118505. * @param onCompiled Called when the shader has been compiled.
  118506. * @param onError Called if there is an error when compiling a shader.
  118507. */
  118508. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  118509. }
  118510. }
  118511. declare module BABYLON {
  118512. /**
  118513. * Specifies the level of max blur that should be applied when using the depth of field effect
  118514. */
  118515. export enum DepthOfFieldEffectBlurLevel {
  118516. /**
  118517. * Subtle blur
  118518. */
  118519. Low = 0,
  118520. /**
  118521. * Medium blur
  118522. */
  118523. Medium = 1,
  118524. /**
  118525. * Large blur
  118526. */
  118527. High = 2
  118528. }
  118529. /**
  118530. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  118531. */
  118532. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  118533. private _circleOfConfusion;
  118534. /**
  118535. * @hidden Internal, blurs from high to low
  118536. */
  118537. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  118538. private _depthOfFieldBlurY;
  118539. private _dofMerge;
  118540. /**
  118541. * @hidden Internal post processes in depth of field effect
  118542. */
  118543. _effects: Array<PostProcess>;
  118544. /**
  118545. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  118546. */
  118547. focalLength: number;
  118548. /**
  118549. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118550. */
  118551. fStop: number;
  118552. /**
  118553. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118554. */
  118555. focusDistance: number;
  118556. /**
  118557. * 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.
  118558. */
  118559. lensSize: number;
  118560. /**
  118561. * Creates a new instance DepthOfFieldEffect
  118562. * @param scene The scene the effect belongs to.
  118563. * @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.
  118564. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118565. * @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)
  118566. */
  118567. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  118568. /**
  118569. * Get the current class name of the current effet
  118570. * @returns "DepthOfFieldEffect"
  118571. */
  118572. getClassName(): string;
  118573. /**
  118574. * 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.
  118575. */
  118576. depthTexture: RenderTargetTexture;
  118577. /**
  118578. * Disposes each of the internal effects for a given camera.
  118579. * @param camera The camera to dispose the effect on.
  118580. */
  118581. disposeEffects(camera: Camera): void;
  118582. /**
  118583. * @hidden Internal
  118584. */
  118585. _updateEffects(): void;
  118586. /**
  118587. * Internal
  118588. * @returns if all the contained post processes are ready.
  118589. * @hidden
  118590. */
  118591. _isReady(): boolean;
  118592. }
  118593. }
  118594. declare module BABYLON {
  118595. /** @hidden */
  118596. export var displayPassPixelShader: {
  118597. name: string;
  118598. shader: string;
  118599. };
  118600. }
  118601. declare module BABYLON {
  118602. /**
  118603. * DisplayPassPostProcess which produces an output the same as it's input
  118604. */
  118605. export class DisplayPassPostProcess extends PostProcess {
  118606. /**
  118607. * Creates the DisplayPassPostProcess
  118608. * @param name The name of the effect.
  118609. * @param options The required width/height ratio to downsize to before computing the render pass.
  118610. * @param camera The camera to apply the render pass to.
  118611. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118612. * @param engine The engine which the post process will be applied. (default: current engine)
  118613. * @param reusable If the post process can be reused on the same frame. (default: false)
  118614. */
  118615. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118616. }
  118617. }
  118618. declare module BABYLON {
  118619. /** @hidden */
  118620. export var filterPixelShader: {
  118621. name: string;
  118622. shader: string;
  118623. };
  118624. }
  118625. declare module BABYLON {
  118626. /**
  118627. * Applies a kernel filter to the image
  118628. */
  118629. export class FilterPostProcess extends PostProcess {
  118630. /** The matrix to be applied to the image */
  118631. kernelMatrix: Matrix;
  118632. /**
  118633. *
  118634. * @param name The name of the effect.
  118635. * @param kernelMatrix The matrix to be applied to the image
  118636. * @param options The required width/height ratio to downsize to before computing the render pass.
  118637. * @param camera The camera to apply the render pass to.
  118638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118639. * @param engine The engine which the post process will be applied. (default: current engine)
  118640. * @param reusable If the post process can be reused on the same frame. (default: false)
  118641. */
  118642. constructor(name: string,
  118643. /** The matrix to be applied to the image */
  118644. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118645. }
  118646. }
  118647. declare module BABYLON {
  118648. /** @hidden */
  118649. export var fxaaPixelShader: {
  118650. name: string;
  118651. shader: string;
  118652. };
  118653. }
  118654. declare module BABYLON {
  118655. /** @hidden */
  118656. export var fxaaVertexShader: {
  118657. name: string;
  118658. shader: string;
  118659. };
  118660. }
  118661. declare module BABYLON {
  118662. /**
  118663. * Fxaa post process
  118664. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  118665. */
  118666. export class FxaaPostProcess extends PostProcess {
  118667. /** @hidden */
  118668. texelWidth: number;
  118669. /** @hidden */
  118670. texelHeight: number;
  118671. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118672. private _getDefines;
  118673. }
  118674. }
  118675. declare module BABYLON {
  118676. /** @hidden */
  118677. export var grainPixelShader: {
  118678. name: string;
  118679. shader: string;
  118680. };
  118681. }
  118682. declare module BABYLON {
  118683. /**
  118684. * The GrainPostProcess adds noise to the image at mid luminance levels
  118685. */
  118686. export class GrainPostProcess extends PostProcess {
  118687. /**
  118688. * The intensity of the grain added (default: 30)
  118689. */
  118690. intensity: number;
  118691. /**
  118692. * If the grain should be randomized on every frame
  118693. */
  118694. animated: boolean;
  118695. /**
  118696. * Creates a new instance of @see GrainPostProcess
  118697. * @param name The name of the effect.
  118698. * @param options The required width/height ratio to downsize to before computing the render pass.
  118699. * @param camera The camera to apply the render pass to.
  118700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118701. * @param engine The engine which the post process will be applied. (default: current engine)
  118702. * @param reusable If the post process can be reused on the same frame. (default: false)
  118703. * @param textureType Type of textures used when performing the post process. (default: 0)
  118704. * @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)
  118705. */
  118706. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118707. }
  118708. }
  118709. declare module BABYLON {
  118710. /** @hidden */
  118711. export var highlightsPixelShader: {
  118712. name: string;
  118713. shader: string;
  118714. };
  118715. }
  118716. declare module BABYLON {
  118717. /**
  118718. * Extracts highlights from the image
  118719. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118720. */
  118721. export class HighlightsPostProcess extends PostProcess {
  118722. /**
  118723. * Extracts highlights from the image
  118724. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118725. * @param name The name of the effect.
  118726. * @param options The required width/height ratio to downsize to before computing the render pass.
  118727. * @param camera The camera to apply the render pass to.
  118728. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118729. * @param engine The engine which the post process will be applied. (default: current engine)
  118730. * @param reusable If the post process can be reused on the same frame. (default: false)
  118731. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  118732. */
  118733. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118734. }
  118735. }
  118736. declare module BABYLON {
  118737. /** @hidden */
  118738. export var mrtFragmentDeclaration: {
  118739. name: string;
  118740. shader: string;
  118741. };
  118742. }
  118743. declare module BABYLON {
  118744. /** @hidden */
  118745. export var geometryPixelShader: {
  118746. name: string;
  118747. shader: string;
  118748. };
  118749. }
  118750. declare module BABYLON {
  118751. /** @hidden */
  118752. export var geometryVertexShader: {
  118753. name: string;
  118754. shader: string;
  118755. };
  118756. }
  118757. declare module BABYLON {
  118758. /** @hidden */
  118759. interface ISavedTransformationMatrix {
  118760. world: Matrix;
  118761. viewProjection: Matrix;
  118762. }
  118763. /**
  118764. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  118765. */
  118766. export class GeometryBufferRenderer {
  118767. /**
  118768. * Constant used to retrieve the position texture index in the G-Buffer textures array
  118769. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  118770. */
  118771. static readonly POSITION_TEXTURE_TYPE: number;
  118772. /**
  118773. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  118774. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  118775. */
  118776. static readonly VELOCITY_TEXTURE_TYPE: number;
  118777. /**
  118778. * Dictionary used to store the previous transformation matrices of each rendered mesh
  118779. * in order to compute objects velocities when enableVelocity is set to "true"
  118780. * @hidden
  118781. */
  118782. _previousTransformationMatrices: {
  118783. [index: number]: ISavedTransformationMatrix;
  118784. };
  118785. /**
  118786. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  118787. * in order to compute objects velocities when enableVelocity is set to "true"
  118788. * @hidden
  118789. */
  118790. _previousBonesTransformationMatrices: {
  118791. [index: number]: Float32Array;
  118792. };
  118793. /**
  118794. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  118795. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  118796. */
  118797. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  118798. private _scene;
  118799. private _multiRenderTarget;
  118800. private _ratio;
  118801. private _enablePosition;
  118802. private _enableVelocity;
  118803. private _positionIndex;
  118804. private _velocityIndex;
  118805. protected _effect: Effect;
  118806. protected _cachedDefines: string;
  118807. /**
  118808. * Set the render list (meshes to be rendered) used in the G buffer.
  118809. */
  118810. renderList: Mesh[];
  118811. /**
  118812. * Gets wether or not G buffer are supported by the running hardware.
  118813. * This requires draw buffer supports
  118814. */
  118815. readonly isSupported: boolean;
  118816. /**
  118817. * Returns the index of the given texture type in the G-Buffer textures array
  118818. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  118819. * @returns the index of the given texture type in the G-Buffer textures array
  118820. */
  118821. getTextureIndex(textureType: number): number;
  118822. /**
  118823. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  118824. */
  118825. /**
  118826. * Sets whether or not objects positions are enabled for the G buffer.
  118827. */
  118828. enablePosition: boolean;
  118829. /**
  118830. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  118831. */
  118832. /**
  118833. * Sets wether or not objects velocities are enabled for the G buffer.
  118834. */
  118835. enableVelocity: boolean;
  118836. /**
  118837. * Gets the scene associated with the buffer.
  118838. */
  118839. readonly scene: Scene;
  118840. /**
  118841. * Gets the ratio used by the buffer during its creation.
  118842. * How big is the buffer related to the main canvas.
  118843. */
  118844. readonly ratio: number;
  118845. /** @hidden */
  118846. static _SceneComponentInitialization: (scene: Scene) => void;
  118847. /**
  118848. * Creates a new G Buffer for the scene
  118849. * @param scene The scene the buffer belongs to
  118850. * @param ratio How big is the buffer related to the main canvas.
  118851. */
  118852. constructor(scene: Scene, ratio?: number);
  118853. /**
  118854. * Checks wether everything is ready to render a submesh to the G buffer.
  118855. * @param subMesh the submesh to check readiness for
  118856. * @param useInstances is the mesh drawn using instance or not
  118857. * @returns true if ready otherwise false
  118858. */
  118859. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118860. /**
  118861. * Gets the current underlying G Buffer.
  118862. * @returns the buffer
  118863. */
  118864. getGBuffer(): MultiRenderTarget;
  118865. /**
  118866. * Gets the number of samples used to render the buffer (anti aliasing).
  118867. */
  118868. /**
  118869. * Sets the number of samples used to render the buffer (anti aliasing).
  118870. */
  118871. samples: number;
  118872. /**
  118873. * Disposes the renderer and frees up associated resources.
  118874. */
  118875. dispose(): void;
  118876. protected _createRenderTargets(): void;
  118877. private _copyBonesTransformationMatrices;
  118878. }
  118879. }
  118880. declare module BABYLON {
  118881. interface Scene {
  118882. /** @hidden (Backing field) */
  118883. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118884. /**
  118885. * Gets or Sets the current geometry buffer associated to the scene.
  118886. */
  118887. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118888. /**
  118889. * Enables a GeometryBufferRender and associates it with the scene
  118890. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  118891. * @returns the GeometryBufferRenderer
  118892. */
  118893. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  118894. /**
  118895. * Disables the GeometryBufferRender associated with the scene
  118896. */
  118897. disableGeometryBufferRenderer(): void;
  118898. }
  118899. /**
  118900. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  118901. * in several rendering techniques.
  118902. */
  118903. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  118904. /**
  118905. * The component name helpful to identify the component in the list of scene components.
  118906. */
  118907. readonly name: string;
  118908. /**
  118909. * The scene the component belongs to.
  118910. */
  118911. scene: Scene;
  118912. /**
  118913. * Creates a new instance of the component for the given scene
  118914. * @param scene Defines the scene to register the component in
  118915. */
  118916. constructor(scene: Scene);
  118917. /**
  118918. * Registers the component in a given scene
  118919. */
  118920. register(): void;
  118921. /**
  118922. * Rebuilds the elements related to this component in case of
  118923. * context lost for instance.
  118924. */
  118925. rebuild(): void;
  118926. /**
  118927. * Disposes the component and the associated ressources
  118928. */
  118929. dispose(): void;
  118930. private _gatherRenderTargets;
  118931. }
  118932. }
  118933. declare module BABYLON {
  118934. /** @hidden */
  118935. export var motionBlurPixelShader: {
  118936. name: string;
  118937. shader: string;
  118938. };
  118939. }
  118940. declare module BABYLON {
  118941. /**
  118942. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118943. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118944. * As an example, all you have to do is to create the post-process:
  118945. * var mb = new BABYLON.MotionBlurPostProcess(
  118946. * 'mb', // The name of the effect.
  118947. * scene, // The scene containing the objects to blur according to their velocity.
  118948. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118949. * camera // The camera to apply the render pass to.
  118950. * );
  118951. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118952. */
  118953. export class MotionBlurPostProcess extends PostProcess {
  118954. /**
  118955. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118956. */
  118957. motionStrength: number;
  118958. /**
  118959. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118960. */
  118961. /**
  118962. * Sets the number of iterations to be used for motion blur quality
  118963. */
  118964. motionBlurSamples: number;
  118965. private _motionBlurSamples;
  118966. private _geometryBufferRenderer;
  118967. /**
  118968. * Creates a new instance MotionBlurPostProcess
  118969. * @param name The name of the effect.
  118970. * @param scene The scene containing the objects to blur according to their velocity.
  118971. * @param options The required width/height ratio to downsize to before computing the render pass.
  118972. * @param camera The camera to apply the render pass to.
  118973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118974. * @param engine The engine which the post process will be applied. (default: current engine)
  118975. * @param reusable If the post process can be reused on the same frame. (default: false)
  118976. * @param textureType Type of textures used when performing the post process. (default: 0)
  118977. * @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)
  118978. */
  118979. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118980. /**
  118981. * Excludes the given skinned mesh from computing bones velocities.
  118982. * 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.
  118983. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  118984. */
  118985. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118986. /**
  118987. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  118988. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  118989. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  118990. */
  118991. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118992. /**
  118993. * Disposes the post process.
  118994. * @param camera The camera to dispose the post process on.
  118995. */
  118996. dispose(camera?: Camera): void;
  118997. }
  118998. }
  118999. declare module BABYLON {
  119000. /** @hidden */
  119001. export var refractionPixelShader: {
  119002. name: string;
  119003. shader: string;
  119004. };
  119005. }
  119006. declare module BABYLON {
  119007. /**
  119008. * Post process which applies a refractin texture
  119009. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119010. */
  119011. export class RefractionPostProcess extends PostProcess {
  119012. /** the base color of the refraction (used to taint the rendering) */
  119013. color: Color3;
  119014. /** simulated refraction depth */
  119015. depth: number;
  119016. /** the coefficient of the base color (0 to remove base color tainting) */
  119017. colorLevel: number;
  119018. private _refTexture;
  119019. private _ownRefractionTexture;
  119020. /**
  119021. * Gets or sets the refraction texture
  119022. * Please note that you are responsible for disposing the texture if you set it manually
  119023. */
  119024. refractionTexture: Texture;
  119025. /**
  119026. * Initializes the RefractionPostProcess
  119027. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119028. * @param name The name of the effect.
  119029. * @param refractionTextureUrl Url of the refraction texture to use
  119030. * @param color the base color of the refraction (used to taint the rendering)
  119031. * @param depth simulated refraction depth
  119032. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  119033. * @param camera The camera to apply the render pass to.
  119034. * @param options The required width/height ratio to downsize to before computing the render pass.
  119035. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119036. * @param engine The engine which the post process will be applied. (default: current engine)
  119037. * @param reusable If the post process can be reused on the same frame. (default: false)
  119038. */
  119039. constructor(name: string, refractionTextureUrl: string,
  119040. /** the base color of the refraction (used to taint the rendering) */
  119041. color: Color3,
  119042. /** simulated refraction depth */
  119043. depth: number,
  119044. /** the coefficient of the base color (0 to remove base color tainting) */
  119045. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  119046. /**
  119047. * Disposes of the post process
  119048. * @param camera Camera to dispose post process on
  119049. */
  119050. dispose(camera: Camera): void;
  119051. }
  119052. }
  119053. declare module BABYLON {
  119054. /** @hidden */
  119055. export var sharpenPixelShader: {
  119056. name: string;
  119057. shader: string;
  119058. };
  119059. }
  119060. declare module BABYLON {
  119061. /**
  119062. * The SharpenPostProcess applies a sharpen kernel to every pixel
  119063. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  119064. */
  119065. export class SharpenPostProcess extends PostProcess {
  119066. /**
  119067. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  119068. */
  119069. colorAmount: number;
  119070. /**
  119071. * How much sharpness should be applied (default: 0.3)
  119072. */
  119073. edgeAmount: number;
  119074. /**
  119075. * Creates a new instance ConvolutionPostProcess
  119076. * @param name The name of the effect.
  119077. * @param options The required width/height ratio to downsize to before computing the render pass.
  119078. * @param camera The camera to apply the render pass to.
  119079. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119080. * @param engine The engine which the post process will be applied. (default: current engine)
  119081. * @param reusable If the post process can be reused on the same frame. (default: false)
  119082. * @param textureType Type of textures used when performing the post process. (default: 0)
  119083. * @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)
  119084. */
  119085. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  119086. }
  119087. }
  119088. declare module BABYLON {
  119089. /**
  119090. * PostProcessRenderPipeline
  119091. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119092. */
  119093. export class PostProcessRenderPipeline {
  119094. private engine;
  119095. private _renderEffects;
  119096. private _renderEffectsForIsolatedPass;
  119097. /**
  119098. * List of inspectable custom properties (used by the Inspector)
  119099. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  119100. */
  119101. inspectableCustomProperties: IInspectable[];
  119102. /**
  119103. * @hidden
  119104. */
  119105. protected _cameras: Camera[];
  119106. /** @hidden */
  119107. _name: string;
  119108. /**
  119109. * Gets pipeline name
  119110. */
  119111. readonly name: string;
  119112. /**
  119113. * Initializes a PostProcessRenderPipeline
  119114. * @param engine engine to add the pipeline to
  119115. * @param name name of the pipeline
  119116. */
  119117. constructor(engine: Engine, name: string);
  119118. /**
  119119. * Gets the class name
  119120. * @returns "PostProcessRenderPipeline"
  119121. */
  119122. getClassName(): string;
  119123. /**
  119124. * If all the render effects in the pipeline are supported
  119125. */
  119126. readonly isSupported: boolean;
  119127. /**
  119128. * Adds an effect to the pipeline
  119129. * @param renderEffect the effect to add
  119130. */
  119131. addEffect(renderEffect: PostProcessRenderEffect): void;
  119132. /** @hidden */
  119133. _rebuild(): void;
  119134. /** @hidden */
  119135. _enableEffect(renderEffectName: string, cameras: Camera): void;
  119136. /** @hidden */
  119137. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  119138. /** @hidden */
  119139. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  119140. /** @hidden */
  119141. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  119142. /** @hidden */
  119143. _attachCameras(cameras: Camera, unique: boolean): void;
  119144. /** @hidden */
  119145. _attachCameras(cameras: Camera[], unique: boolean): void;
  119146. /** @hidden */
  119147. _detachCameras(cameras: Camera): void;
  119148. /** @hidden */
  119149. _detachCameras(cameras: Nullable<Camera[]>): void;
  119150. /** @hidden */
  119151. _update(): void;
  119152. /** @hidden */
  119153. _reset(): void;
  119154. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  119155. /**
  119156. * Disposes of the pipeline
  119157. */
  119158. dispose(): void;
  119159. }
  119160. }
  119161. declare module BABYLON {
  119162. /**
  119163. * PostProcessRenderPipelineManager class
  119164. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119165. */
  119166. export class PostProcessRenderPipelineManager {
  119167. private _renderPipelines;
  119168. /**
  119169. * Initializes a PostProcessRenderPipelineManager
  119170. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119171. */
  119172. constructor();
  119173. /**
  119174. * Gets the list of supported render pipelines
  119175. */
  119176. readonly supportedPipelines: PostProcessRenderPipeline[];
  119177. /**
  119178. * Adds a pipeline to the manager
  119179. * @param renderPipeline The pipeline to add
  119180. */
  119181. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  119182. /**
  119183. * Attaches a camera to the pipeline
  119184. * @param renderPipelineName The name of the pipeline to attach to
  119185. * @param cameras the camera to attach
  119186. * @param unique if the camera can be attached multiple times to the pipeline
  119187. */
  119188. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  119189. /**
  119190. * Detaches a camera from the pipeline
  119191. * @param renderPipelineName The name of the pipeline to detach from
  119192. * @param cameras the camera to detach
  119193. */
  119194. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  119195. /**
  119196. * Enables an effect by name on a pipeline
  119197. * @param renderPipelineName the name of the pipeline to enable the effect in
  119198. * @param renderEffectName the name of the effect to enable
  119199. * @param cameras the cameras that the effect should be enabled on
  119200. */
  119201. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119202. /**
  119203. * Disables an effect by name on a pipeline
  119204. * @param renderPipelineName the name of the pipeline to disable the effect in
  119205. * @param renderEffectName the name of the effect to disable
  119206. * @param cameras the cameras that the effect should be disabled on
  119207. */
  119208. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119209. /**
  119210. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  119211. */
  119212. update(): void;
  119213. /** @hidden */
  119214. _rebuild(): void;
  119215. /**
  119216. * Disposes of the manager and pipelines
  119217. */
  119218. dispose(): void;
  119219. }
  119220. }
  119221. declare module BABYLON {
  119222. interface Scene {
  119223. /** @hidden (Backing field) */
  119224. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119225. /**
  119226. * Gets the postprocess render pipeline manager
  119227. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119228. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119229. */
  119230. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119231. }
  119232. /**
  119233. * Defines the Render Pipeline scene component responsible to rendering pipelines
  119234. */
  119235. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  119236. /**
  119237. * The component name helpfull to identify the component in the list of scene components.
  119238. */
  119239. readonly name: string;
  119240. /**
  119241. * The scene the component belongs to.
  119242. */
  119243. scene: Scene;
  119244. /**
  119245. * Creates a new instance of the component for the given scene
  119246. * @param scene Defines the scene to register the component in
  119247. */
  119248. constructor(scene: Scene);
  119249. /**
  119250. * Registers the component in a given scene
  119251. */
  119252. register(): void;
  119253. /**
  119254. * Rebuilds the elements related to this component in case of
  119255. * context lost for instance.
  119256. */
  119257. rebuild(): void;
  119258. /**
  119259. * Disposes the component and the associated ressources
  119260. */
  119261. dispose(): void;
  119262. private _gatherRenderTargets;
  119263. }
  119264. }
  119265. declare module BABYLON {
  119266. /**
  119267. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  119268. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119269. */
  119270. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119271. private _scene;
  119272. private _camerasToBeAttached;
  119273. /**
  119274. * ID of the sharpen post process,
  119275. */
  119276. private readonly SharpenPostProcessId;
  119277. /**
  119278. * @ignore
  119279. * ID of the image processing post process;
  119280. */
  119281. readonly ImageProcessingPostProcessId: string;
  119282. /**
  119283. * @ignore
  119284. * ID of the Fast Approximate Anti-Aliasing post process;
  119285. */
  119286. readonly FxaaPostProcessId: string;
  119287. /**
  119288. * ID of the chromatic aberration post process,
  119289. */
  119290. private readonly ChromaticAberrationPostProcessId;
  119291. /**
  119292. * ID of the grain post process
  119293. */
  119294. private readonly GrainPostProcessId;
  119295. /**
  119296. * Sharpen post process which will apply a sharpen convolution to enhance edges
  119297. */
  119298. sharpen: SharpenPostProcess;
  119299. private _sharpenEffect;
  119300. private bloom;
  119301. /**
  119302. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  119303. */
  119304. depthOfField: DepthOfFieldEffect;
  119305. /**
  119306. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119307. */
  119308. fxaa: FxaaPostProcess;
  119309. /**
  119310. * Image post processing pass used to perform operations such as tone mapping or color grading.
  119311. */
  119312. imageProcessing: ImageProcessingPostProcess;
  119313. /**
  119314. * Chromatic aberration post process which will shift rgb colors in the image
  119315. */
  119316. chromaticAberration: ChromaticAberrationPostProcess;
  119317. private _chromaticAberrationEffect;
  119318. /**
  119319. * Grain post process which add noise to the image
  119320. */
  119321. grain: GrainPostProcess;
  119322. private _grainEffect;
  119323. /**
  119324. * Glow post process which adds a glow to emissive areas of the image
  119325. */
  119326. private _glowLayer;
  119327. /**
  119328. * Animations which can be used to tweak settings over a period of time
  119329. */
  119330. animations: Animation[];
  119331. private _imageProcessingConfigurationObserver;
  119332. private _sharpenEnabled;
  119333. private _bloomEnabled;
  119334. private _depthOfFieldEnabled;
  119335. private _depthOfFieldBlurLevel;
  119336. private _fxaaEnabled;
  119337. private _imageProcessingEnabled;
  119338. private _defaultPipelineTextureType;
  119339. private _bloomScale;
  119340. private _chromaticAberrationEnabled;
  119341. private _grainEnabled;
  119342. private _buildAllowed;
  119343. /**
  119344. * Gets active scene
  119345. */
  119346. readonly scene: Scene;
  119347. /**
  119348. * Enable or disable the sharpen process from the pipeline
  119349. */
  119350. sharpenEnabled: boolean;
  119351. private _resizeObserver;
  119352. private _hardwareScaleLevel;
  119353. private _bloomKernel;
  119354. /**
  119355. * Specifies the size of the bloom blur kernel, relative to the final output size
  119356. */
  119357. bloomKernel: number;
  119358. /**
  119359. * Specifies the weight of the bloom in the final rendering
  119360. */
  119361. private _bloomWeight;
  119362. /**
  119363. * Specifies the luma threshold for the area that will be blurred by the bloom
  119364. */
  119365. private _bloomThreshold;
  119366. private _hdr;
  119367. /**
  119368. * The strength of the bloom.
  119369. */
  119370. bloomWeight: number;
  119371. /**
  119372. * The strength of the bloom.
  119373. */
  119374. bloomThreshold: number;
  119375. /**
  119376. * The scale of the bloom, lower value will provide better performance.
  119377. */
  119378. bloomScale: number;
  119379. /**
  119380. * Enable or disable the bloom from the pipeline
  119381. */
  119382. bloomEnabled: boolean;
  119383. private _rebuildBloom;
  119384. /**
  119385. * If the depth of field is enabled.
  119386. */
  119387. depthOfFieldEnabled: boolean;
  119388. /**
  119389. * Blur level of the depth of field effect. (Higher blur will effect performance)
  119390. */
  119391. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  119392. /**
  119393. * If the anti aliasing is enabled.
  119394. */
  119395. fxaaEnabled: boolean;
  119396. private _samples;
  119397. /**
  119398. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119399. */
  119400. samples: number;
  119401. /**
  119402. * If image processing is enabled.
  119403. */
  119404. imageProcessingEnabled: boolean;
  119405. /**
  119406. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  119407. */
  119408. glowLayerEnabled: boolean;
  119409. /**
  119410. * Gets the glow layer (or null if not defined)
  119411. */
  119412. readonly glowLayer: Nullable<GlowLayer>;
  119413. /**
  119414. * Enable or disable the chromaticAberration process from the pipeline
  119415. */
  119416. chromaticAberrationEnabled: boolean;
  119417. /**
  119418. * Enable or disable the grain process from the pipeline
  119419. */
  119420. grainEnabled: boolean;
  119421. /**
  119422. * @constructor
  119423. * @param name - The rendering pipeline name (default: "")
  119424. * @param hdr - If high dynamic range textures should be used (default: true)
  119425. * @param scene - The scene linked to this pipeline (default: the last created scene)
  119426. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  119427. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  119428. */
  119429. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  119430. /**
  119431. * Get the class name
  119432. * @returns "DefaultRenderingPipeline"
  119433. */
  119434. getClassName(): string;
  119435. /**
  119436. * Force the compilation of the entire pipeline.
  119437. */
  119438. prepare(): void;
  119439. private _hasCleared;
  119440. private _prevPostProcess;
  119441. private _prevPrevPostProcess;
  119442. private _setAutoClearAndTextureSharing;
  119443. private _depthOfFieldSceneObserver;
  119444. private _buildPipeline;
  119445. private _disposePostProcesses;
  119446. /**
  119447. * Adds a camera to the pipeline
  119448. * @param camera the camera to be added
  119449. */
  119450. addCamera(camera: Camera): void;
  119451. /**
  119452. * Removes a camera from the pipeline
  119453. * @param camera the camera to remove
  119454. */
  119455. removeCamera(camera: Camera): void;
  119456. /**
  119457. * Dispose of the pipeline and stop all post processes
  119458. */
  119459. dispose(): void;
  119460. /**
  119461. * Serialize the rendering pipeline (Used when exporting)
  119462. * @returns the serialized object
  119463. */
  119464. serialize(): any;
  119465. /**
  119466. * Parse the serialized pipeline
  119467. * @param source Source pipeline.
  119468. * @param scene The scene to load the pipeline to.
  119469. * @param rootUrl The URL of the serialized pipeline.
  119470. * @returns An instantiated pipeline from the serialized object.
  119471. */
  119472. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  119473. }
  119474. }
  119475. declare module BABYLON {
  119476. /** @hidden */
  119477. export var lensHighlightsPixelShader: {
  119478. name: string;
  119479. shader: string;
  119480. };
  119481. }
  119482. declare module BABYLON {
  119483. /** @hidden */
  119484. export var depthOfFieldPixelShader: {
  119485. name: string;
  119486. shader: string;
  119487. };
  119488. }
  119489. declare module BABYLON {
  119490. /**
  119491. * BABYLON.JS Chromatic Aberration GLSL Shader
  119492. * Author: Olivier Guyot
  119493. * Separates very slightly R, G and B colors on the edges of the screen
  119494. * Inspired by Francois Tarlier & Martins Upitis
  119495. */
  119496. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  119497. /**
  119498. * @ignore
  119499. * The chromatic aberration PostProcess id in the pipeline
  119500. */
  119501. LensChromaticAberrationEffect: string;
  119502. /**
  119503. * @ignore
  119504. * The highlights enhancing PostProcess id in the pipeline
  119505. */
  119506. HighlightsEnhancingEffect: string;
  119507. /**
  119508. * @ignore
  119509. * The depth-of-field PostProcess id in the pipeline
  119510. */
  119511. LensDepthOfFieldEffect: string;
  119512. private _scene;
  119513. private _depthTexture;
  119514. private _grainTexture;
  119515. private _chromaticAberrationPostProcess;
  119516. private _highlightsPostProcess;
  119517. private _depthOfFieldPostProcess;
  119518. private _edgeBlur;
  119519. private _grainAmount;
  119520. private _chromaticAberration;
  119521. private _distortion;
  119522. private _highlightsGain;
  119523. private _highlightsThreshold;
  119524. private _dofDistance;
  119525. private _dofAperture;
  119526. private _dofDarken;
  119527. private _dofPentagon;
  119528. private _blurNoise;
  119529. /**
  119530. * @constructor
  119531. *
  119532. * Effect parameters are as follow:
  119533. * {
  119534. * chromatic_aberration: number; // from 0 to x (1 for realism)
  119535. * edge_blur: number; // from 0 to x (1 for realism)
  119536. * distortion: number; // from 0 to x (1 for realism)
  119537. * grain_amount: number; // from 0 to 1
  119538. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  119539. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  119540. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  119541. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  119542. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  119543. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  119544. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  119545. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  119546. * }
  119547. * Note: if an effect parameter is unset, effect is disabled
  119548. *
  119549. * @param name The rendering pipeline name
  119550. * @param parameters - An object containing all parameters (see above)
  119551. * @param scene The scene linked to this pipeline
  119552. * @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)
  119553. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119554. */
  119555. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  119556. /**
  119557. * Get the class name
  119558. * @returns "LensRenderingPipeline"
  119559. */
  119560. getClassName(): string;
  119561. /**
  119562. * Gets associated scene
  119563. */
  119564. readonly scene: Scene;
  119565. /**
  119566. * Gets or sets the edge blur
  119567. */
  119568. edgeBlur: number;
  119569. /**
  119570. * Gets or sets the grain amount
  119571. */
  119572. grainAmount: number;
  119573. /**
  119574. * Gets or sets the chromatic aberration amount
  119575. */
  119576. chromaticAberration: number;
  119577. /**
  119578. * Gets or sets the depth of field aperture
  119579. */
  119580. dofAperture: number;
  119581. /**
  119582. * Gets or sets the edge distortion
  119583. */
  119584. edgeDistortion: number;
  119585. /**
  119586. * Gets or sets the depth of field distortion
  119587. */
  119588. dofDistortion: number;
  119589. /**
  119590. * Gets or sets the darken out of focus amount
  119591. */
  119592. darkenOutOfFocus: number;
  119593. /**
  119594. * Gets or sets a boolean indicating if blur noise is enabled
  119595. */
  119596. blurNoise: boolean;
  119597. /**
  119598. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  119599. */
  119600. pentagonBokeh: boolean;
  119601. /**
  119602. * Gets or sets the highlight grain amount
  119603. */
  119604. highlightsGain: number;
  119605. /**
  119606. * Gets or sets the highlight threshold
  119607. */
  119608. highlightsThreshold: number;
  119609. /**
  119610. * Sets the amount of blur at the edges
  119611. * @param amount blur amount
  119612. */
  119613. setEdgeBlur(amount: number): void;
  119614. /**
  119615. * Sets edge blur to 0
  119616. */
  119617. disableEdgeBlur(): void;
  119618. /**
  119619. * Sets the amout of grain
  119620. * @param amount Amount of grain
  119621. */
  119622. setGrainAmount(amount: number): void;
  119623. /**
  119624. * Set grain amount to 0
  119625. */
  119626. disableGrain(): void;
  119627. /**
  119628. * Sets the chromatic aberration amount
  119629. * @param amount amount of chromatic aberration
  119630. */
  119631. setChromaticAberration(amount: number): void;
  119632. /**
  119633. * Sets chromatic aberration amount to 0
  119634. */
  119635. disableChromaticAberration(): void;
  119636. /**
  119637. * Sets the EdgeDistortion amount
  119638. * @param amount amount of EdgeDistortion
  119639. */
  119640. setEdgeDistortion(amount: number): void;
  119641. /**
  119642. * Sets edge distortion to 0
  119643. */
  119644. disableEdgeDistortion(): void;
  119645. /**
  119646. * Sets the FocusDistance amount
  119647. * @param amount amount of FocusDistance
  119648. */
  119649. setFocusDistance(amount: number): void;
  119650. /**
  119651. * Disables depth of field
  119652. */
  119653. disableDepthOfField(): void;
  119654. /**
  119655. * Sets the Aperture amount
  119656. * @param amount amount of Aperture
  119657. */
  119658. setAperture(amount: number): void;
  119659. /**
  119660. * Sets the DarkenOutOfFocus amount
  119661. * @param amount amount of DarkenOutOfFocus
  119662. */
  119663. setDarkenOutOfFocus(amount: number): void;
  119664. private _pentagonBokehIsEnabled;
  119665. /**
  119666. * Creates a pentagon bokeh effect
  119667. */
  119668. enablePentagonBokeh(): void;
  119669. /**
  119670. * Disables the pentagon bokeh effect
  119671. */
  119672. disablePentagonBokeh(): void;
  119673. /**
  119674. * Enables noise blur
  119675. */
  119676. enableNoiseBlur(): void;
  119677. /**
  119678. * Disables noise blur
  119679. */
  119680. disableNoiseBlur(): void;
  119681. /**
  119682. * Sets the HighlightsGain amount
  119683. * @param amount amount of HighlightsGain
  119684. */
  119685. setHighlightsGain(amount: number): void;
  119686. /**
  119687. * Sets the HighlightsThreshold amount
  119688. * @param amount amount of HighlightsThreshold
  119689. */
  119690. setHighlightsThreshold(amount: number): void;
  119691. /**
  119692. * Disables highlights
  119693. */
  119694. disableHighlights(): void;
  119695. /**
  119696. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  119697. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  119698. */
  119699. dispose(disableDepthRender?: boolean): void;
  119700. private _createChromaticAberrationPostProcess;
  119701. private _createHighlightsPostProcess;
  119702. private _createDepthOfFieldPostProcess;
  119703. private _createGrainTexture;
  119704. }
  119705. }
  119706. declare module BABYLON {
  119707. /** @hidden */
  119708. export var ssao2PixelShader: {
  119709. name: string;
  119710. shader: string;
  119711. };
  119712. }
  119713. declare module BABYLON {
  119714. /** @hidden */
  119715. export var ssaoCombinePixelShader: {
  119716. name: string;
  119717. shader: string;
  119718. };
  119719. }
  119720. declare module BABYLON {
  119721. /**
  119722. * Render pipeline to produce ssao effect
  119723. */
  119724. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  119725. /**
  119726. * @ignore
  119727. * The PassPostProcess id in the pipeline that contains the original scene color
  119728. */
  119729. SSAOOriginalSceneColorEffect: string;
  119730. /**
  119731. * @ignore
  119732. * The SSAO PostProcess id in the pipeline
  119733. */
  119734. SSAORenderEffect: string;
  119735. /**
  119736. * @ignore
  119737. * The horizontal blur PostProcess id in the pipeline
  119738. */
  119739. SSAOBlurHRenderEffect: string;
  119740. /**
  119741. * @ignore
  119742. * The vertical blur PostProcess id in the pipeline
  119743. */
  119744. SSAOBlurVRenderEffect: string;
  119745. /**
  119746. * @ignore
  119747. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119748. */
  119749. SSAOCombineRenderEffect: string;
  119750. /**
  119751. * The output strength of the SSAO post-process. Default value is 1.0.
  119752. */
  119753. totalStrength: number;
  119754. /**
  119755. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  119756. */
  119757. maxZ: number;
  119758. /**
  119759. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  119760. */
  119761. minZAspect: number;
  119762. private _samples;
  119763. /**
  119764. * Number of samples used for the SSAO calculations. Default value is 8
  119765. */
  119766. samples: number;
  119767. private _textureSamples;
  119768. /**
  119769. * Number of samples to use for antialiasing
  119770. */
  119771. textureSamples: number;
  119772. /**
  119773. * Ratio object used for SSAO ratio and blur ratio
  119774. */
  119775. private _ratio;
  119776. /**
  119777. * Dynamically generated sphere sampler.
  119778. */
  119779. private _sampleSphere;
  119780. /**
  119781. * Blur filter offsets
  119782. */
  119783. private _samplerOffsets;
  119784. private _expensiveBlur;
  119785. /**
  119786. * If bilateral blur should be used
  119787. */
  119788. expensiveBlur: boolean;
  119789. /**
  119790. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  119791. */
  119792. radius: number;
  119793. /**
  119794. * The base color of the SSAO post-process
  119795. * The final result is "base + ssao" between [0, 1]
  119796. */
  119797. base: number;
  119798. /**
  119799. * Support test.
  119800. */
  119801. static readonly IsSupported: boolean;
  119802. private _scene;
  119803. private _depthTexture;
  119804. private _normalTexture;
  119805. private _randomTexture;
  119806. private _originalColorPostProcess;
  119807. private _ssaoPostProcess;
  119808. private _blurHPostProcess;
  119809. private _blurVPostProcess;
  119810. private _ssaoCombinePostProcess;
  119811. private _firstUpdate;
  119812. /**
  119813. * Gets active scene
  119814. */
  119815. readonly scene: Scene;
  119816. /**
  119817. * @constructor
  119818. * @param name The rendering pipeline name
  119819. * @param scene The scene linked to this pipeline
  119820. * @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 }
  119821. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119822. */
  119823. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119824. /**
  119825. * Get the class name
  119826. * @returns "SSAO2RenderingPipeline"
  119827. */
  119828. getClassName(): string;
  119829. /**
  119830. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119831. */
  119832. dispose(disableGeometryBufferRenderer?: boolean): void;
  119833. private _createBlurPostProcess;
  119834. /** @hidden */
  119835. _rebuild(): void;
  119836. private _bits;
  119837. private _radicalInverse_VdC;
  119838. private _hammersley;
  119839. private _hemisphereSample_uniform;
  119840. private _generateHemisphere;
  119841. private _createSSAOPostProcess;
  119842. private _createSSAOCombinePostProcess;
  119843. private _createRandomTexture;
  119844. /**
  119845. * Serialize the rendering pipeline (Used when exporting)
  119846. * @returns the serialized object
  119847. */
  119848. serialize(): any;
  119849. /**
  119850. * Parse the serialized pipeline
  119851. * @param source Source pipeline.
  119852. * @param scene The scene to load the pipeline to.
  119853. * @param rootUrl The URL of the serialized pipeline.
  119854. * @returns An instantiated pipeline from the serialized object.
  119855. */
  119856. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  119857. }
  119858. }
  119859. declare module BABYLON {
  119860. /** @hidden */
  119861. export var ssaoPixelShader: {
  119862. name: string;
  119863. shader: string;
  119864. };
  119865. }
  119866. declare module BABYLON {
  119867. /**
  119868. * Render pipeline to produce ssao effect
  119869. */
  119870. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  119871. /**
  119872. * @ignore
  119873. * The PassPostProcess id in the pipeline that contains the original scene color
  119874. */
  119875. SSAOOriginalSceneColorEffect: string;
  119876. /**
  119877. * @ignore
  119878. * The SSAO PostProcess id in the pipeline
  119879. */
  119880. SSAORenderEffect: string;
  119881. /**
  119882. * @ignore
  119883. * The horizontal blur PostProcess id in the pipeline
  119884. */
  119885. SSAOBlurHRenderEffect: string;
  119886. /**
  119887. * @ignore
  119888. * The vertical blur PostProcess id in the pipeline
  119889. */
  119890. SSAOBlurVRenderEffect: string;
  119891. /**
  119892. * @ignore
  119893. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119894. */
  119895. SSAOCombineRenderEffect: string;
  119896. /**
  119897. * The output strength of the SSAO post-process. Default value is 1.0.
  119898. */
  119899. totalStrength: number;
  119900. /**
  119901. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  119902. */
  119903. radius: number;
  119904. /**
  119905. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  119906. * Must not be equal to fallOff and superior to fallOff.
  119907. * Default value is 0.0075
  119908. */
  119909. area: number;
  119910. /**
  119911. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  119912. * Must not be equal to area and inferior to area.
  119913. * Default value is 0.000001
  119914. */
  119915. fallOff: number;
  119916. /**
  119917. * The base color of the SSAO post-process
  119918. * The final result is "base + ssao" between [0, 1]
  119919. */
  119920. base: number;
  119921. private _scene;
  119922. private _depthTexture;
  119923. private _randomTexture;
  119924. private _originalColorPostProcess;
  119925. private _ssaoPostProcess;
  119926. private _blurHPostProcess;
  119927. private _blurVPostProcess;
  119928. private _ssaoCombinePostProcess;
  119929. private _firstUpdate;
  119930. /**
  119931. * Gets active scene
  119932. */
  119933. readonly scene: Scene;
  119934. /**
  119935. * @constructor
  119936. * @param name - The rendering pipeline name
  119937. * @param scene - The scene linked to this pipeline
  119938. * @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 }
  119939. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  119940. */
  119941. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119942. /**
  119943. * Get the class name
  119944. * @returns "SSAORenderingPipeline"
  119945. */
  119946. getClassName(): string;
  119947. /**
  119948. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119949. */
  119950. dispose(disableDepthRender?: boolean): void;
  119951. private _createBlurPostProcess;
  119952. /** @hidden */
  119953. _rebuild(): void;
  119954. private _createSSAOPostProcess;
  119955. private _createSSAOCombinePostProcess;
  119956. private _createRandomTexture;
  119957. }
  119958. }
  119959. declare module BABYLON {
  119960. /** @hidden */
  119961. export var standardPixelShader: {
  119962. name: string;
  119963. shader: string;
  119964. };
  119965. }
  119966. declare module BABYLON {
  119967. /**
  119968. * Standard rendering pipeline
  119969. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119970. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  119971. */
  119972. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119973. /**
  119974. * Public members
  119975. */
  119976. /**
  119977. * Post-process which contains the original scene color before the pipeline applies all the effects
  119978. */
  119979. originalPostProcess: Nullable<PostProcess>;
  119980. /**
  119981. * Post-process used to down scale an image x4
  119982. */
  119983. downSampleX4PostProcess: Nullable<PostProcess>;
  119984. /**
  119985. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  119986. */
  119987. brightPassPostProcess: Nullable<PostProcess>;
  119988. /**
  119989. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  119990. */
  119991. blurHPostProcesses: PostProcess[];
  119992. /**
  119993. * Post-process array storing all the vertical blur post-processes used by the pipeline
  119994. */
  119995. blurVPostProcesses: PostProcess[];
  119996. /**
  119997. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  119998. */
  119999. textureAdderPostProcess: Nullable<PostProcess>;
  120000. /**
  120001. * Post-process used to create volumetric lighting effect
  120002. */
  120003. volumetricLightPostProcess: Nullable<PostProcess>;
  120004. /**
  120005. * Post-process used to smooth the previous volumetric light post-process on the X axis
  120006. */
  120007. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  120008. /**
  120009. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  120010. */
  120011. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  120012. /**
  120013. * Post-process used to merge the volumetric light effect and the real scene color
  120014. */
  120015. volumetricLightMergePostProces: Nullable<PostProcess>;
  120016. /**
  120017. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  120018. */
  120019. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  120020. /**
  120021. * Base post-process used to calculate the average luminance of the final image for HDR
  120022. */
  120023. luminancePostProcess: Nullable<PostProcess>;
  120024. /**
  120025. * Post-processes used to create down sample post-processes in order to get
  120026. * the average luminance of the final image for HDR
  120027. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  120028. */
  120029. luminanceDownSamplePostProcesses: PostProcess[];
  120030. /**
  120031. * Post-process used to create a HDR effect (light adaptation)
  120032. */
  120033. hdrPostProcess: Nullable<PostProcess>;
  120034. /**
  120035. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  120036. */
  120037. textureAdderFinalPostProcess: Nullable<PostProcess>;
  120038. /**
  120039. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  120040. */
  120041. lensFlareFinalPostProcess: Nullable<PostProcess>;
  120042. /**
  120043. * Post-process used to merge the final HDR post-process and the real scene color
  120044. */
  120045. hdrFinalPostProcess: Nullable<PostProcess>;
  120046. /**
  120047. * Post-process used to create a lens flare effect
  120048. */
  120049. lensFlarePostProcess: Nullable<PostProcess>;
  120050. /**
  120051. * Post-process that merges the result of the lens flare post-process and the real scene color
  120052. */
  120053. lensFlareComposePostProcess: Nullable<PostProcess>;
  120054. /**
  120055. * Post-process used to create a motion blur effect
  120056. */
  120057. motionBlurPostProcess: Nullable<PostProcess>;
  120058. /**
  120059. * Post-process used to create a depth of field effect
  120060. */
  120061. depthOfFieldPostProcess: Nullable<PostProcess>;
  120062. /**
  120063. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  120064. */
  120065. fxaaPostProcess: Nullable<FxaaPostProcess>;
  120066. /**
  120067. * Represents the brightness threshold in order to configure the illuminated surfaces
  120068. */
  120069. brightThreshold: number;
  120070. /**
  120071. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  120072. */
  120073. blurWidth: number;
  120074. /**
  120075. * Sets if the blur for highlighted surfaces must be only horizontal
  120076. */
  120077. horizontalBlur: boolean;
  120078. /**
  120079. * Gets the overall exposure used by the pipeline
  120080. */
  120081. /**
  120082. * Sets the overall exposure used by the pipeline
  120083. */
  120084. exposure: number;
  120085. /**
  120086. * Texture used typically to simulate "dirty" on camera lens
  120087. */
  120088. lensTexture: Nullable<Texture>;
  120089. /**
  120090. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  120091. */
  120092. volumetricLightCoefficient: number;
  120093. /**
  120094. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  120095. */
  120096. volumetricLightPower: number;
  120097. /**
  120098. * Used the set the blur intensity to smooth the volumetric lights
  120099. */
  120100. volumetricLightBlurScale: number;
  120101. /**
  120102. * Light (spot or directional) used to generate the volumetric lights rays
  120103. * The source light must have a shadow generate so the pipeline can get its
  120104. * depth map
  120105. */
  120106. sourceLight: Nullable<SpotLight | DirectionalLight>;
  120107. /**
  120108. * For eye adaptation, represents the minimum luminance the eye can see
  120109. */
  120110. hdrMinimumLuminance: number;
  120111. /**
  120112. * For eye adaptation, represents the decrease luminance speed
  120113. */
  120114. hdrDecreaseRate: number;
  120115. /**
  120116. * For eye adaptation, represents the increase luminance speed
  120117. */
  120118. hdrIncreaseRate: number;
  120119. /**
  120120. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120121. */
  120122. /**
  120123. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120124. */
  120125. hdrAutoExposure: boolean;
  120126. /**
  120127. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  120128. */
  120129. lensColorTexture: Nullable<Texture>;
  120130. /**
  120131. * The overall strengh for the lens flare effect
  120132. */
  120133. lensFlareStrength: number;
  120134. /**
  120135. * Dispersion coefficient for lens flare ghosts
  120136. */
  120137. lensFlareGhostDispersal: number;
  120138. /**
  120139. * Main lens flare halo width
  120140. */
  120141. lensFlareHaloWidth: number;
  120142. /**
  120143. * Based on the lens distortion effect, defines how much the lens flare result
  120144. * is distorted
  120145. */
  120146. lensFlareDistortionStrength: number;
  120147. /**
  120148. * Lens star texture must be used to simulate rays on the flares and is available
  120149. * in the documentation
  120150. */
  120151. lensStarTexture: Nullable<Texture>;
  120152. /**
  120153. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  120154. * flare effect by taking account of the dirt texture
  120155. */
  120156. lensFlareDirtTexture: Nullable<Texture>;
  120157. /**
  120158. * Represents the focal length for the depth of field effect
  120159. */
  120160. depthOfFieldDistance: number;
  120161. /**
  120162. * Represents the blur intensity for the blurred part of the depth of field effect
  120163. */
  120164. depthOfFieldBlurWidth: number;
  120165. /**
  120166. * Gets how much the image is blurred by the movement while using the motion blur post-process
  120167. */
  120168. /**
  120169. * Sets how much the image is blurred by the movement while using the motion blur post-process
  120170. */
  120171. motionStrength: number;
  120172. /**
  120173. * Gets wether or not the motion blur post-process is object based or screen based.
  120174. */
  120175. /**
  120176. * Sets wether or not the motion blur post-process should be object based or screen based
  120177. */
  120178. objectBasedMotionBlur: boolean;
  120179. /**
  120180. * List of animations for the pipeline (IAnimatable implementation)
  120181. */
  120182. animations: Animation[];
  120183. /**
  120184. * Private members
  120185. */
  120186. private _scene;
  120187. private _currentDepthOfFieldSource;
  120188. private _basePostProcess;
  120189. private _fixedExposure;
  120190. private _currentExposure;
  120191. private _hdrAutoExposure;
  120192. private _hdrCurrentLuminance;
  120193. private _motionStrength;
  120194. private _isObjectBasedMotionBlur;
  120195. private _floatTextureType;
  120196. private _ratio;
  120197. private _bloomEnabled;
  120198. private _depthOfFieldEnabled;
  120199. private _vlsEnabled;
  120200. private _lensFlareEnabled;
  120201. private _hdrEnabled;
  120202. private _motionBlurEnabled;
  120203. private _fxaaEnabled;
  120204. private _motionBlurSamples;
  120205. private _volumetricLightStepsCount;
  120206. private _samples;
  120207. /**
  120208. * @ignore
  120209. * Specifies if the bloom pipeline is enabled
  120210. */
  120211. BloomEnabled: boolean;
  120212. /**
  120213. * @ignore
  120214. * Specifies if the depth of field pipeline is enabed
  120215. */
  120216. DepthOfFieldEnabled: boolean;
  120217. /**
  120218. * @ignore
  120219. * Specifies if the lens flare pipeline is enabed
  120220. */
  120221. LensFlareEnabled: boolean;
  120222. /**
  120223. * @ignore
  120224. * Specifies if the HDR pipeline is enabled
  120225. */
  120226. HDREnabled: boolean;
  120227. /**
  120228. * @ignore
  120229. * Specifies if the volumetric lights scattering effect is enabled
  120230. */
  120231. VLSEnabled: boolean;
  120232. /**
  120233. * @ignore
  120234. * Specifies if the motion blur effect is enabled
  120235. */
  120236. MotionBlurEnabled: boolean;
  120237. /**
  120238. * Specifies if anti-aliasing is enabled
  120239. */
  120240. fxaaEnabled: boolean;
  120241. /**
  120242. * Specifies the number of steps used to calculate the volumetric lights
  120243. * Typically in interval [50, 200]
  120244. */
  120245. volumetricLightStepsCount: number;
  120246. /**
  120247. * Specifies the number of samples used for the motion blur effect
  120248. * Typically in interval [16, 64]
  120249. */
  120250. motionBlurSamples: number;
  120251. /**
  120252. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  120253. */
  120254. samples: number;
  120255. /**
  120256. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  120257. * @constructor
  120258. * @param name The rendering pipeline name
  120259. * @param scene The scene linked to this pipeline
  120260. * @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)
  120261. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  120262. * @param cameras The array of cameras that the rendering pipeline will be attached to
  120263. */
  120264. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  120265. private _buildPipeline;
  120266. private _createDownSampleX4PostProcess;
  120267. private _createBrightPassPostProcess;
  120268. private _createBlurPostProcesses;
  120269. private _createTextureAdderPostProcess;
  120270. private _createVolumetricLightPostProcess;
  120271. private _createLuminancePostProcesses;
  120272. private _createHdrPostProcess;
  120273. private _createLensFlarePostProcess;
  120274. private _createDepthOfFieldPostProcess;
  120275. private _createMotionBlurPostProcess;
  120276. private _getDepthTexture;
  120277. private _disposePostProcesses;
  120278. /**
  120279. * Dispose of the pipeline and stop all post processes
  120280. */
  120281. dispose(): void;
  120282. /**
  120283. * Serialize the rendering pipeline (Used when exporting)
  120284. * @returns the serialized object
  120285. */
  120286. serialize(): any;
  120287. /**
  120288. * Parse the serialized pipeline
  120289. * @param source Source pipeline.
  120290. * @param scene The scene to load the pipeline to.
  120291. * @param rootUrl The URL of the serialized pipeline.
  120292. * @returns An instantiated pipeline from the serialized object.
  120293. */
  120294. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  120295. /**
  120296. * Luminance steps
  120297. */
  120298. static LuminanceSteps: number;
  120299. }
  120300. }
  120301. declare module BABYLON {
  120302. /** @hidden */
  120303. export var tonemapPixelShader: {
  120304. name: string;
  120305. shader: string;
  120306. };
  120307. }
  120308. declare module BABYLON {
  120309. /** Defines operator used for tonemapping */
  120310. export enum TonemappingOperator {
  120311. /** Hable */
  120312. Hable = 0,
  120313. /** Reinhard */
  120314. Reinhard = 1,
  120315. /** HejiDawson */
  120316. HejiDawson = 2,
  120317. /** Photographic */
  120318. Photographic = 3
  120319. }
  120320. /**
  120321. * Defines a post process to apply tone mapping
  120322. */
  120323. export class TonemapPostProcess extends PostProcess {
  120324. private _operator;
  120325. /** Defines the required exposure adjustement */
  120326. exposureAdjustment: number;
  120327. /**
  120328. * Creates a new TonemapPostProcess
  120329. * @param name defines the name of the postprocess
  120330. * @param _operator defines the operator to use
  120331. * @param exposureAdjustment defines the required exposure adjustement
  120332. * @param camera defines the camera to use (can be null)
  120333. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  120334. * @param engine defines the hosting engine (can be ignore if camera is set)
  120335. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120336. */
  120337. constructor(name: string, _operator: TonemappingOperator,
  120338. /** Defines the required exposure adjustement */
  120339. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  120340. }
  120341. }
  120342. declare module BABYLON {
  120343. /** @hidden */
  120344. export var depthVertexShader: {
  120345. name: string;
  120346. shader: string;
  120347. };
  120348. }
  120349. declare module BABYLON {
  120350. /** @hidden */
  120351. export var volumetricLightScatteringPixelShader: {
  120352. name: string;
  120353. shader: string;
  120354. };
  120355. }
  120356. declare module BABYLON {
  120357. /** @hidden */
  120358. export var volumetricLightScatteringPassPixelShader: {
  120359. name: string;
  120360. shader: string;
  120361. };
  120362. }
  120363. declare module BABYLON {
  120364. /**
  120365. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  120366. */
  120367. export class VolumetricLightScatteringPostProcess extends PostProcess {
  120368. private _volumetricLightScatteringPass;
  120369. private _volumetricLightScatteringRTT;
  120370. private _viewPort;
  120371. private _screenCoordinates;
  120372. private _cachedDefines;
  120373. /**
  120374. * If not undefined, the mesh position is computed from the attached node position
  120375. */
  120376. attachedNode: {
  120377. position: Vector3;
  120378. };
  120379. /**
  120380. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  120381. */
  120382. customMeshPosition: Vector3;
  120383. /**
  120384. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  120385. */
  120386. useCustomMeshPosition: boolean;
  120387. /**
  120388. * If the post-process should inverse the light scattering direction
  120389. */
  120390. invert: boolean;
  120391. /**
  120392. * The internal mesh used by the post-process
  120393. */
  120394. mesh: Mesh;
  120395. /**
  120396. * @hidden
  120397. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  120398. */
  120399. useDiffuseColor: boolean;
  120400. /**
  120401. * Array containing the excluded meshes not rendered in the internal pass
  120402. */
  120403. excludedMeshes: AbstractMesh[];
  120404. /**
  120405. * Controls the overall intensity of the post-process
  120406. */
  120407. exposure: number;
  120408. /**
  120409. * Dissipates each sample's contribution in range [0, 1]
  120410. */
  120411. decay: number;
  120412. /**
  120413. * Controls the overall intensity of each sample
  120414. */
  120415. weight: number;
  120416. /**
  120417. * Controls the density of each sample
  120418. */
  120419. density: number;
  120420. /**
  120421. * @constructor
  120422. * @param name The post-process name
  120423. * @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)
  120424. * @param camera The camera that the post-process will be attached to
  120425. * @param mesh The mesh used to create the light scattering
  120426. * @param samples The post-process quality, default 100
  120427. * @param samplingModeThe post-process filtering mode
  120428. * @param engine The babylon engine
  120429. * @param reusable If the post-process is reusable
  120430. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  120431. */
  120432. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  120433. /**
  120434. * Returns the string "VolumetricLightScatteringPostProcess"
  120435. * @returns "VolumetricLightScatteringPostProcess"
  120436. */
  120437. getClassName(): string;
  120438. private _isReady;
  120439. /**
  120440. * Sets the new light position for light scattering effect
  120441. * @param position The new custom light position
  120442. */
  120443. setCustomMeshPosition(position: Vector3): void;
  120444. /**
  120445. * Returns the light position for light scattering effect
  120446. * @return Vector3 The custom light position
  120447. */
  120448. getCustomMeshPosition(): Vector3;
  120449. /**
  120450. * Disposes the internal assets and detaches the post-process from the camera
  120451. */
  120452. dispose(camera: Camera): void;
  120453. /**
  120454. * Returns the render target texture used by the post-process
  120455. * @return the render target texture used by the post-process
  120456. */
  120457. getPass(): RenderTargetTexture;
  120458. private _meshExcluded;
  120459. private _createPass;
  120460. private _updateMeshScreenCoordinates;
  120461. /**
  120462. * Creates a default mesh for the Volumeric Light Scattering post-process
  120463. * @param name The mesh name
  120464. * @param scene The scene where to create the mesh
  120465. * @return the default mesh
  120466. */
  120467. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  120468. }
  120469. }
  120470. declare module BABYLON {
  120471. interface Scene {
  120472. /** @hidden (Backing field) */
  120473. _boundingBoxRenderer: BoundingBoxRenderer;
  120474. /** @hidden (Backing field) */
  120475. _forceShowBoundingBoxes: boolean;
  120476. /**
  120477. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  120478. */
  120479. forceShowBoundingBoxes: boolean;
  120480. /**
  120481. * Gets the bounding box renderer associated with the scene
  120482. * @returns a BoundingBoxRenderer
  120483. */
  120484. getBoundingBoxRenderer(): BoundingBoxRenderer;
  120485. }
  120486. interface AbstractMesh {
  120487. /** @hidden (Backing field) */
  120488. _showBoundingBox: boolean;
  120489. /**
  120490. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  120491. */
  120492. showBoundingBox: boolean;
  120493. }
  120494. /**
  120495. * Component responsible of rendering the bounding box of the meshes in a scene.
  120496. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  120497. */
  120498. export class BoundingBoxRenderer implements ISceneComponent {
  120499. /**
  120500. * The component name helpfull to identify the component in the list of scene components.
  120501. */
  120502. readonly name: string;
  120503. /**
  120504. * The scene the component belongs to.
  120505. */
  120506. scene: Scene;
  120507. /**
  120508. * Color of the bounding box lines placed in front of an object
  120509. */
  120510. frontColor: Color3;
  120511. /**
  120512. * Color of the bounding box lines placed behind an object
  120513. */
  120514. backColor: Color3;
  120515. /**
  120516. * Defines if the renderer should show the back lines or not
  120517. */
  120518. showBackLines: boolean;
  120519. /**
  120520. * @hidden
  120521. */
  120522. renderList: SmartArray<BoundingBox>;
  120523. private _colorShader;
  120524. private _vertexBuffers;
  120525. private _indexBuffer;
  120526. private _fillIndexBuffer;
  120527. private _fillIndexData;
  120528. /**
  120529. * Instantiates a new bounding box renderer in a scene.
  120530. * @param scene the scene the renderer renders in
  120531. */
  120532. constructor(scene: Scene);
  120533. /**
  120534. * Registers the component in a given scene
  120535. */
  120536. register(): void;
  120537. private _evaluateSubMesh;
  120538. private _activeMesh;
  120539. private _prepareRessources;
  120540. private _createIndexBuffer;
  120541. /**
  120542. * Rebuilds the elements related to this component in case of
  120543. * context lost for instance.
  120544. */
  120545. rebuild(): void;
  120546. /**
  120547. * @hidden
  120548. */
  120549. reset(): void;
  120550. /**
  120551. * Render the bounding boxes of a specific rendering group
  120552. * @param renderingGroupId defines the rendering group to render
  120553. */
  120554. render(renderingGroupId: number): void;
  120555. /**
  120556. * In case of occlusion queries, we can render the occlusion bounding box through this method
  120557. * @param mesh Define the mesh to render the occlusion bounding box for
  120558. */
  120559. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  120560. /**
  120561. * Dispose and release the resources attached to this renderer.
  120562. */
  120563. dispose(): void;
  120564. }
  120565. }
  120566. declare module BABYLON {
  120567. /** @hidden */
  120568. export var depthPixelShader: {
  120569. name: string;
  120570. shader: string;
  120571. };
  120572. }
  120573. declare module BABYLON {
  120574. /**
  120575. * This represents a depth renderer in Babylon.
  120576. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  120577. */
  120578. export class DepthRenderer {
  120579. private _scene;
  120580. private _depthMap;
  120581. private _effect;
  120582. private _cachedDefines;
  120583. private _camera;
  120584. /**
  120585. * Specifiess that the depth renderer will only be used within
  120586. * the camera it is created for.
  120587. * This can help forcing its rendering during the camera processing.
  120588. */
  120589. useOnlyInActiveCamera: boolean;
  120590. /** @hidden */
  120591. static _SceneComponentInitialization: (scene: Scene) => void;
  120592. /**
  120593. * Instantiates a depth renderer
  120594. * @param scene The scene the renderer belongs to
  120595. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  120596. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  120597. */
  120598. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  120599. /**
  120600. * Creates the depth rendering effect and checks if the effect is ready.
  120601. * @param subMesh The submesh to be used to render the depth map of
  120602. * @param useInstances If multiple world instances should be used
  120603. * @returns if the depth renderer is ready to render the depth map
  120604. */
  120605. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120606. /**
  120607. * Gets the texture which the depth map will be written to.
  120608. * @returns The depth map texture
  120609. */
  120610. getDepthMap(): RenderTargetTexture;
  120611. /**
  120612. * Disposes of the depth renderer.
  120613. */
  120614. dispose(): void;
  120615. }
  120616. }
  120617. declare module BABYLON {
  120618. interface Scene {
  120619. /** @hidden (Backing field) */
  120620. _depthRenderer: {
  120621. [id: string]: DepthRenderer;
  120622. };
  120623. /**
  120624. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  120625. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  120626. * @returns the created depth renderer
  120627. */
  120628. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  120629. /**
  120630. * Disables a depth renderer for a given camera
  120631. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  120632. */
  120633. disableDepthRenderer(camera?: Nullable<Camera>): void;
  120634. }
  120635. /**
  120636. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  120637. * in several rendering techniques.
  120638. */
  120639. export class DepthRendererSceneComponent implements ISceneComponent {
  120640. /**
  120641. * The component name helpfull to identify the component in the list of scene components.
  120642. */
  120643. readonly name: string;
  120644. /**
  120645. * The scene the component belongs to.
  120646. */
  120647. scene: Scene;
  120648. /**
  120649. * Creates a new instance of the component for the given scene
  120650. * @param scene Defines the scene to register the component in
  120651. */
  120652. constructor(scene: Scene);
  120653. /**
  120654. * Registers the component in a given scene
  120655. */
  120656. register(): void;
  120657. /**
  120658. * Rebuilds the elements related to this component in case of
  120659. * context lost for instance.
  120660. */
  120661. rebuild(): void;
  120662. /**
  120663. * Disposes the component and the associated ressources
  120664. */
  120665. dispose(): void;
  120666. private _gatherRenderTargets;
  120667. private _gatherActiveCameraRenderTargets;
  120668. }
  120669. }
  120670. declare module BABYLON {
  120671. /** @hidden */
  120672. export var outlinePixelShader: {
  120673. name: string;
  120674. shader: string;
  120675. };
  120676. }
  120677. declare module BABYLON {
  120678. /** @hidden */
  120679. export var outlineVertexShader: {
  120680. name: string;
  120681. shader: string;
  120682. };
  120683. }
  120684. declare module BABYLON {
  120685. interface Scene {
  120686. /** @hidden */
  120687. _outlineRenderer: OutlineRenderer;
  120688. /**
  120689. * Gets the outline renderer associated with the scene
  120690. * @returns a OutlineRenderer
  120691. */
  120692. getOutlineRenderer(): OutlineRenderer;
  120693. }
  120694. interface AbstractMesh {
  120695. /** @hidden (Backing field) */
  120696. _renderOutline: boolean;
  120697. /**
  120698. * Gets or sets a boolean indicating if the outline must be rendered as well
  120699. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  120700. */
  120701. renderOutline: boolean;
  120702. /** @hidden (Backing field) */
  120703. _renderOverlay: boolean;
  120704. /**
  120705. * Gets or sets a boolean indicating if the overlay must be rendered as well
  120706. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  120707. */
  120708. renderOverlay: boolean;
  120709. }
  120710. /**
  120711. * This class is responsible to draw bothe outline/overlay of meshes.
  120712. * It should not be used directly but through the available method on mesh.
  120713. */
  120714. export class OutlineRenderer implements ISceneComponent {
  120715. /**
  120716. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  120717. */
  120718. private static _StencilReference;
  120719. /**
  120720. * The name of the component. Each component must have a unique name.
  120721. */
  120722. name: string;
  120723. /**
  120724. * The scene the component belongs to.
  120725. */
  120726. scene: Scene;
  120727. /**
  120728. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  120729. */
  120730. zOffset: number;
  120731. private _engine;
  120732. private _effect;
  120733. private _cachedDefines;
  120734. private _savedDepthWrite;
  120735. /**
  120736. * Instantiates a new outline renderer. (There could be only one per scene).
  120737. * @param scene Defines the scene it belongs to
  120738. */
  120739. constructor(scene: Scene);
  120740. /**
  120741. * Register the component to one instance of a scene.
  120742. */
  120743. register(): void;
  120744. /**
  120745. * Rebuilds the elements related to this component in case of
  120746. * context lost for instance.
  120747. */
  120748. rebuild(): void;
  120749. /**
  120750. * Disposes the component and the associated ressources.
  120751. */
  120752. dispose(): void;
  120753. /**
  120754. * Renders the outline in the canvas.
  120755. * @param subMesh Defines the sumesh to render
  120756. * @param batch Defines the batch of meshes in case of instances
  120757. * @param useOverlay Defines if the rendering is for the overlay or the outline
  120758. */
  120759. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  120760. /**
  120761. * Returns whether or not the outline renderer is ready for a given submesh.
  120762. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  120763. * @param subMesh Defines the submesh to check readyness for
  120764. * @param useInstances Defines wheter wee are trying to render instances or not
  120765. * @returns true if ready otherwise false
  120766. */
  120767. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120768. private _beforeRenderingMesh;
  120769. private _afterRenderingMesh;
  120770. }
  120771. }
  120772. declare module BABYLON {
  120773. /**
  120774. * Defines the list of states available for a task inside a AssetsManager
  120775. */
  120776. export enum AssetTaskState {
  120777. /**
  120778. * Initialization
  120779. */
  120780. INIT = 0,
  120781. /**
  120782. * Running
  120783. */
  120784. RUNNING = 1,
  120785. /**
  120786. * Done
  120787. */
  120788. DONE = 2,
  120789. /**
  120790. * Error
  120791. */
  120792. ERROR = 3
  120793. }
  120794. /**
  120795. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  120796. */
  120797. export abstract class AbstractAssetTask {
  120798. /**
  120799. * Task name
  120800. */ name: string;
  120801. /**
  120802. * Callback called when the task is successful
  120803. */
  120804. onSuccess: (task: any) => void;
  120805. /**
  120806. * Callback called when the task is not successful
  120807. */
  120808. onError: (task: any, message?: string, exception?: any) => void;
  120809. /**
  120810. * Creates a new AssetsManager
  120811. * @param name defines the name of the task
  120812. */
  120813. constructor(
  120814. /**
  120815. * Task name
  120816. */ name: string);
  120817. private _isCompleted;
  120818. private _taskState;
  120819. private _errorObject;
  120820. /**
  120821. * Get if the task is completed
  120822. */
  120823. readonly isCompleted: boolean;
  120824. /**
  120825. * Gets the current state of the task
  120826. */
  120827. readonly taskState: AssetTaskState;
  120828. /**
  120829. * Gets the current error object (if task is in error)
  120830. */
  120831. readonly errorObject: {
  120832. message?: string;
  120833. exception?: any;
  120834. };
  120835. /**
  120836. * Internal only
  120837. * @hidden
  120838. */
  120839. _setErrorObject(message?: string, exception?: any): void;
  120840. /**
  120841. * Execute the current task
  120842. * @param scene defines the scene where you want your assets to be loaded
  120843. * @param onSuccess is a callback called when the task is successfully executed
  120844. * @param onError is a callback called if an error occurs
  120845. */
  120846. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120847. /**
  120848. * Execute the current task
  120849. * @param scene defines the scene where you want your assets to be loaded
  120850. * @param onSuccess is a callback called when the task is successfully executed
  120851. * @param onError is a callback called if an error occurs
  120852. */
  120853. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120854. /**
  120855. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  120856. * This can be used with failed tasks that have the reason for failure fixed.
  120857. */
  120858. reset(): void;
  120859. private onErrorCallback;
  120860. private onDoneCallback;
  120861. }
  120862. /**
  120863. * Define the interface used by progress events raised during assets loading
  120864. */
  120865. export interface IAssetsProgressEvent {
  120866. /**
  120867. * Defines the number of remaining tasks to process
  120868. */
  120869. remainingCount: number;
  120870. /**
  120871. * Defines the total number of tasks
  120872. */
  120873. totalCount: number;
  120874. /**
  120875. * Defines the task that was just processed
  120876. */
  120877. task: AbstractAssetTask;
  120878. }
  120879. /**
  120880. * Class used to share progress information about assets loading
  120881. */
  120882. export class AssetsProgressEvent implements IAssetsProgressEvent {
  120883. /**
  120884. * Defines the number of remaining tasks to process
  120885. */
  120886. remainingCount: number;
  120887. /**
  120888. * Defines the total number of tasks
  120889. */
  120890. totalCount: number;
  120891. /**
  120892. * Defines the task that was just processed
  120893. */
  120894. task: AbstractAssetTask;
  120895. /**
  120896. * Creates a AssetsProgressEvent
  120897. * @param remainingCount defines the number of remaining tasks to process
  120898. * @param totalCount defines the total number of tasks
  120899. * @param task defines the task that was just processed
  120900. */
  120901. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  120902. }
  120903. /**
  120904. * Define a task used by AssetsManager to load meshes
  120905. */
  120906. export class MeshAssetTask extends AbstractAssetTask {
  120907. /**
  120908. * Defines the name of the task
  120909. */
  120910. name: string;
  120911. /**
  120912. * Defines the list of mesh's names you want to load
  120913. */
  120914. meshesNames: any;
  120915. /**
  120916. * Defines the root url to use as a base to load your meshes and associated resources
  120917. */
  120918. rootUrl: string;
  120919. /**
  120920. * Defines the filename of the scene to load from
  120921. */
  120922. sceneFilename: string;
  120923. /**
  120924. * Gets the list of loaded meshes
  120925. */
  120926. loadedMeshes: Array<AbstractMesh>;
  120927. /**
  120928. * Gets the list of loaded particle systems
  120929. */
  120930. loadedParticleSystems: Array<IParticleSystem>;
  120931. /**
  120932. * Gets the list of loaded skeletons
  120933. */
  120934. loadedSkeletons: Array<Skeleton>;
  120935. /**
  120936. * Gets the list of loaded animation groups
  120937. */
  120938. loadedAnimationGroups: Array<AnimationGroup>;
  120939. /**
  120940. * Callback called when the task is successful
  120941. */
  120942. onSuccess: (task: MeshAssetTask) => void;
  120943. /**
  120944. * Callback called when the task is successful
  120945. */
  120946. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  120947. /**
  120948. * Creates a new MeshAssetTask
  120949. * @param name defines the name of the task
  120950. * @param meshesNames defines the list of mesh's names you want to load
  120951. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  120952. * @param sceneFilename defines the filename of the scene to load from
  120953. */
  120954. constructor(
  120955. /**
  120956. * Defines the name of the task
  120957. */
  120958. name: string,
  120959. /**
  120960. * Defines the list of mesh's names you want to load
  120961. */
  120962. meshesNames: any,
  120963. /**
  120964. * Defines the root url to use as a base to load your meshes and associated resources
  120965. */
  120966. rootUrl: string,
  120967. /**
  120968. * Defines the filename of the scene to load from
  120969. */
  120970. sceneFilename: string);
  120971. /**
  120972. * Execute the current task
  120973. * @param scene defines the scene where you want your assets to be loaded
  120974. * @param onSuccess is a callback called when the task is successfully executed
  120975. * @param onError is a callback called if an error occurs
  120976. */
  120977. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120978. }
  120979. /**
  120980. * Define a task used by AssetsManager to load text content
  120981. */
  120982. export class TextFileAssetTask extends AbstractAssetTask {
  120983. /**
  120984. * Defines the name of the task
  120985. */
  120986. name: string;
  120987. /**
  120988. * Defines the location of the file to load
  120989. */
  120990. url: string;
  120991. /**
  120992. * Gets the loaded text string
  120993. */
  120994. text: string;
  120995. /**
  120996. * Callback called when the task is successful
  120997. */
  120998. onSuccess: (task: TextFileAssetTask) => void;
  120999. /**
  121000. * Callback called when the task is successful
  121001. */
  121002. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  121003. /**
  121004. * Creates a new TextFileAssetTask object
  121005. * @param name defines the name of the task
  121006. * @param url defines the location of the file to load
  121007. */
  121008. constructor(
  121009. /**
  121010. * Defines the name of the task
  121011. */
  121012. name: string,
  121013. /**
  121014. * Defines the location of the file to load
  121015. */
  121016. url: string);
  121017. /**
  121018. * Execute the current task
  121019. * @param scene defines the scene where you want your assets to be loaded
  121020. * @param onSuccess is a callback called when the task is successfully executed
  121021. * @param onError is a callback called if an error occurs
  121022. */
  121023. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121024. }
  121025. /**
  121026. * Define a task used by AssetsManager to load binary data
  121027. */
  121028. export class BinaryFileAssetTask extends AbstractAssetTask {
  121029. /**
  121030. * Defines the name of the task
  121031. */
  121032. name: string;
  121033. /**
  121034. * Defines the location of the file to load
  121035. */
  121036. url: string;
  121037. /**
  121038. * Gets the lodaded data (as an array buffer)
  121039. */
  121040. data: ArrayBuffer;
  121041. /**
  121042. * Callback called when the task is successful
  121043. */
  121044. onSuccess: (task: BinaryFileAssetTask) => void;
  121045. /**
  121046. * Callback called when the task is successful
  121047. */
  121048. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  121049. /**
  121050. * Creates a new BinaryFileAssetTask object
  121051. * @param name defines the name of the new task
  121052. * @param url defines the location of the file to load
  121053. */
  121054. constructor(
  121055. /**
  121056. * Defines the name of the task
  121057. */
  121058. name: string,
  121059. /**
  121060. * Defines the location of the file to load
  121061. */
  121062. url: string);
  121063. /**
  121064. * Execute the current task
  121065. * @param scene defines the scene where you want your assets to be loaded
  121066. * @param onSuccess is a callback called when the task is successfully executed
  121067. * @param onError is a callback called if an error occurs
  121068. */
  121069. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121070. }
  121071. /**
  121072. * Define a task used by AssetsManager to load images
  121073. */
  121074. export class ImageAssetTask extends AbstractAssetTask {
  121075. /**
  121076. * Defines the name of the task
  121077. */
  121078. name: string;
  121079. /**
  121080. * Defines the location of the image to load
  121081. */
  121082. url: string;
  121083. /**
  121084. * Gets the loaded images
  121085. */
  121086. image: HTMLImageElement;
  121087. /**
  121088. * Callback called when the task is successful
  121089. */
  121090. onSuccess: (task: ImageAssetTask) => void;
  121091. /**
  121092. * Callback called when the task is successful
  121093. */
  121094. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  121095. /**
  121096. * Creates a new ImageAssetTask
  121097. * @param name defines the name of the task
  121098. * @param url defines the location of the image to load
  121099. */
  121100. constructor(
  121101. /**
  121102. * Defines the name of the task
  121103. */
  121104. name: string,
  121105. /**
  121106. * Defines the location of the image to load
  121107. */
  121108. url: string);
  121109. /**
  121110. * Execute the current task
  121111. * @param scene defines the scene where you want your assets to be loaded
  121112. * @param onSuccess is a callback called when the task is successfully executed
  121113. * @param onError is a callback called if an error occurs
  121114. */
  121115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121116. }
  121117. /**
  121118. * Defines the interface used by texture loading tasks
  121119. */
  121120. export interface ITextureAssetTask<TEX extends BaseTexture> {
  121121. /**
  121122. * Gets the loaded texture
  121123. */
  121124. texture: TEX;
  121125. }
  121126. /**
  121127. * Define a task used by AssetsManager to load 2D textures
  121128. */
  121129. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  121130. /**
  121131. * Defines the name of the task
  121132. */
  121133. name: string;
  121134. /**
  121135. * Defines the location of the file to load
  121136. */
  121137. url: string;
  121138. /**
  121139. * Defines if mipmap should not be generated (default is false)
  121140. */
  121141. noMipmap?: boolean | undefined;
  121142. /**
  121143. * Defines if texture must be inverted on Y axis (default is false)
  121144. */
  121145. invertY?: boolean | undefined;
  121146. /**
  121147. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121148. */
  121149. samplingMode: number;
  121150. /**
  121151. * Gets the loaded texture
  121152. */
  121153. texture: Texture;
  121154. /**
  121155. * Callback called when the task is successful
  121156. */
  121157. onSuccess: (task: TextureAssetTask) => void;
  121158. /**
  121159. * Callback called when the task is successful
  121160. */
  121161. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  121162. /**
  121163. * Creates a new TextureAssetTask object
  121164. * @param name defines the name of the task
  121165. * @param url defines the location of the file to load
  121166. * @param noMipmap defines if mipmap should not be generated (default is false)
  121167. * @param invertY defines if texture must be inverted on Y axis (default is false)
  121168. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121169. */
  121170. constructor(
  121171. /**
  121172. * Defines the name of the task
  121173. */
  121174. name: string,
  121175. /**
  121176. * Defines the location of the file to load
  121177. */
  121178. url: string,
  121179. /**
  121180. * Defines if mipmap should not be generated (default is false)
  121181. */
  121182. noMipmap?: boolean | undefined,
  121183. /**
  121184. * Defines if texture must be inverted on Y axis (default is false)
  121185. */
  121186. invertY?: boolean | undefined,
  121187. /**
  121188. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121189. */
  121190. samplingMode?: number);
  121191. /**
  121192. * Execute the current task
  121193. * @param scene defines the scene where you want your assets to be loaded
  121194. * @param onSuccess is a callback called when the task is successfully executed
  121195. * @param onError is a callback called if an error occurs
  121196. */
  121197. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121198. }
  121199. /**
  121200. * Define a task used by AssetsManager to load cube textures
  121201. */
  121202. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  121203. /**
  121204. * Defines the name of the task
  121205. */
  121206. name: string;
  121207. /**
  121208. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121209. */
  121210. url: string;
  121211. /**
  121212. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121213. */
  121214. extensions?: string[] | undefined;
  121215. /**
  121216. * Defines if mipmaps should not be generated (default is false)
  121217. */
  121218. noMipmap?: boolean | undefined;
  121219. /**
  121220. * Defines the explicit list of files (undefined by default)
  121221. */
  121222. files?: string[] | undefined;
  121223. /**
  121224. * Gets the loaded texture
  121225. */
  121226. texture: CubeTexture;
  121227. /**
  121228. * Callback called when the task is successful
  121229. */
  121230. onSuccess: (task: CubeTextureAssetTask) => void;
  121231. /**
  121232. * Callback called when the task is successful
  121233. */
  121234. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  121235. /**
  121236. * Creates a new CubeTextureAssetTask
  121237. * @param name defines the name of the task
  121238. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121239. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121240. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121241. * @param files defines the explicit list of files (undefined by default)
  121242. */
  121243. constructor(
  121244. /**
  121245. * Defines the name of the task
  121246. */
  121247. name: string,
  121248. /**
  121249. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121250. */
  121251. url: string,
  121252. /**
  121253. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121254. */
  121255. extensions?: string[] | undefined,
  121256. /**
  121257. * Defines if mipmaps should not be generated (default is false)
  121258. */
  121259. noMipmap?: boolean | undefined,
  121260. /**
  121261. * Defines the explicit list of files (undefined by default)
  121262. */
  121263. files?: string[] | undefined);
  121264. /**
  121265. * Execute the current task
  121266. * @param scene defines the scene where you want your assets to be loaded
  121267. * @param onSuccess is a callback called when the task is successfully executed
  121268. * @param onError is a callback called if an error occurs
  121269. */
  121270. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121271. }
  121272. /**
  121273. * Define a task used by AssetsManager to load HDR cube textures
  121274. */
  121275. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  121276. /**
  121277. * Defines the name of the task
  121278. */
  121279. name: string;
  121280. /**
  121281. * Defines the location of the file to load
  121282. */
  121283. url: string;
  121284. /**
  121285. * Defines the desired size (the more it increases the longer the generation will be)
  121286. */
  121287. size: number;
  121288. /**
  121289. * Defines if mipmaps should not be generated (default is false)
  121290. */
  121291. noMipmap: boolean;
  121292. /**
  121293. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121294. */
  121295. generateHarmonics: boolean;
  121296. /**
  121297. * 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)
  121298. */
  121299. gammaSpace: boolean;
  121300. /**
  121301. * Internal Use Only
  121302. */
  121303. reserved: boolean;
  121304. /**
  121305. * Gets the loaded texture
  121306. */
  121307. texture: HDRCubeTexture;
  121308. /**
  121309. * Callback called when the task is successful
  121310. */
  121311. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  121312. /**
  121313. * Callback called when the task is successful
  121314. */
  121315. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  121316. /**
  121317. * Creates a new HDRCubeTextureAssetTask object
  121318. * @param name defines the name of the task
  121319. * @param url defines the location of the file to load
  121320. * @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.
  121321. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121322. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121323. * @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)
  121324. * @param reserved Internal use only
  121325. */
  121326. constructor(
  121327. /**
  121328. * Defines the name of the task
  121329. */
  121330. name: string,
  121331. /**
  121332. * Defines the location of the file to load
  121333. */
  121334. url: string,
  121335. /**
  121336. * Defines the desired size (the more it increases the longer the generation will be)
  121337. */
  121338. size: number,
  121339. /**
  121340. * Defines if mipmaps should not be generated (default is false)
  121341. */
  121342. noMipmap?: boolean,
  121343. /**
  121344. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121345. */
  121346. generateHarmonics?: boolean,
  121347. /**
  121348. * 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)
  121349. */
  121350. gammaSpace?: boolean,
  121351. /**
  121352. * Internal Use Only
  121353. */
  121354. reserved?: boolean);
  121355. /**
  121356. * Execute the current task
  121357. * @param scene defines the scene where you want your assets to be loaded
  121358. * @param onSuccess is a callback called when the task is successfully executed
  121359. * @param onError is a callback called if an error occurs
  121360. */
  121361. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121362. }
  121363. /**
  121364. * Define a task used by AssetsManager to load Equirectangular cube textures
  121365. */
  121366. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  121367. /**
  121368. * Defines the name of the task
  121369. */
  121370. name: string;
  121371. /**
  121372. * Defines the location of the file to load
  121373. */
  121374. url: string;
  121375. /**
  121376. * Defines the desired size (the more it increases the longer the generation will be)
  121377. */
  121378. size: number;
  121379. /**
  121380. * Defines if mipmaps should not be generated (default is false)
  121381. */
  121382. noMipmap: boolean;
  121383. /**
  121384. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121385. * but the standard material would require them in Gamma space) (default is true)
  121386. */
  121387. gammaSpace: boolean;
  121388. /**
  121389. * Gets the loaded texture
  121390. */
  121391. texture: EquiRectangularCubeTexture;
  121392. /**
  121393. * Callback called when the task is successful
  121394. */
  121395. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  121396. /**
  121397. * Callback called when the task is successful
  121398. */
  121399. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  121400. /**
  121401. * Creates a new EquiRectangularCubeTextureAssetTask object
  121402. * @param name defines the name of the task
  121403. * @param url defines the location of the file to load
  121404. * @param size defines the desired size (the more it increases the longer the generation will be)
  121405. * If the size is omitted this implies you are using a preprocessed cubemap.
  121406. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121407. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  121408. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  121409. * (default is true)
  121410. */
  121411. constructor(
  121412. /**
  121413. * Defines the name of the task
  121414. */
  121415. name: string,
  121416. /**
  121417. * Defines the location of the file to load
  121418. */
  121419. url: string,
  121420. /**
  121421. * Defines the desired size (the more it increases the longer the generation will be)
  121422. */
  121423. size: number,
  121424. /**
  121425. * Defines if mipmaps should not be generated (default is false)
  121426. */
  121427. noMipmap?: boolean,
  121428. /**
  121429. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121430. * but the standard material would require them in Gamma space) (default is true)
  121431. */
  121432. gammaSpace?: boolean);
  121433. /**
  121434. * Execute the current task
  121435. * @param scene defines the scene where you want your assets to be loaded
  121436. * @param onSuccess is a callback called when the task is successfully executed
  121437. * @param onError is a callback called if an error occurs
  121438. */
  121439. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121440. }
  121441. /**
  121442. * This class can be used to easily import assets into a scene
  121443. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  121444. */
  121445. export class AssetsManager {
  121446. private _scene;
  121447. private _isLoading;
  121448. protected _tasks: AbstractAssetTask[];
  121449. protected _waitingTasksCount: number;
  121450. protected _totalTasksCount: number;
  121451. /**
  121452. * Callback called when all tasks are processed
  121453. */
  121454. onFinish: (tasks: AbstractAssetTask[]) => void;
  121455. /**
  121456. * Callback called when a task is successful
  121457. */
  121458. onTaskSuccess: (task: AbstractAssetTask) => void;
  121459. /**
  121460. * Callback called when a task had an error
  121461. */
  121462. onTaskError: (task: AbstractAssetTask) => void;
  121463. /**
  121464. * Callback called when a task is done (whatever the result is)
  121465. */
  121466. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  121467. /**
  121468. * Observable called when all tasks are processed
  121469. */
  121470. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  121471. /**
  121472. * Observable called when a task had an error
  121473. */
  121474. onTaskErrorObservable: Observable<AbstractAssetTask>;
  121475. /**
  121476. * Observable called when all tasks were executed
  121477. */
  121478. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  121479. /**
  121480. * Observable called when a task is done (whatever the result is)
  121481. */
  121482. onProgressObservable: Observable<IAssetsProgressEvent>;
  121483. /**
  121484. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  121485. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121486. */
  121487. useDefaultLoadingScreen: boolean;
  121488. /**
  121489. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  121490. * when all assets have been downloaded.
  121491. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  121492. */
  121493. autoHideLoadingUI: boolean;
  121494. /**
  121495. * Creates a new AssetsManager
  121496. * @param scene defines the scene to work on
  121497. */
  121498. constructor(scene: Scene);
  121499. /**
  121500. * Add a MeshAssetTask to the list of active tasks
  121501. * @param taskName defines the name of the new task
  121502. * @param meshesNames defines the name of meshes to load
  121503. * @param rootUrl defines the root url to use to locate files
  121504. * @param sceneFilename defines the filename of the scene file
  121505. * @returns a new MeshAssetTask object
  121506. */
  121507. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  121508. /**
  121509. * Add a TextFileAssetTask to the list of active tasks
  121510. * @param taskName defines the name of the new task
  121511. * @param url defines the url of the file to load
  121512. * @returns a new TextFileAssetTask object
  121513. */
  121514. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  121515. /**
  121516. * Add a BinaryFileAssetTask to the list of active tasks
  121517. * @param taskName defines the name of the new task
  121518. * @param url defines the url of the file to load
  121519. * @returns a new BinaryFileAssetTask object
  121520. */
  121521. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  121522. /**
  121523. * Add a ImageAssetTask to the list of active tasks
  121524. * @param taskName defines the name of the new task
  121525. * @param url defines the url of the file to load
  121526. * @returns a new ImageAssetTask object
  121527. */
  121528. addImageTask(taskName: string, url: string): ImageAssetTask;
  121529. /**
  121530. * Add a TextureAssetTask to the list of active tasks
  121531. * @param taskName defines the name of the new task
  121532. * @param url defines the url of the file to load
  121533. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121534. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  121535. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121536. * @returns a new TextureAssetTask object
  121537. */
  121538. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  121539. /**
  121540. * Add a CubeTextureAssetTask to the list of active tasks
  121541. * @param taskName defines the name of the new task
  121542. * @param url defines the url of the file to load
  121543. * @param extensions defines the extension to use to load the cube map (can be null)
  121544. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121545. * @param files defines the list of files to load (can be null)
  121546. * @returns a new CubeTextureAssetTask object
  121547. */
  121548. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  121549. /**
  121550. *
  121551. * Add a HDRCubeTextureAssetTask to the list of active tasks
  121552. * @param taskName defines the name of the new task
  121553. * @param url defines the url of the file to load
  121554. * @param size defines the size you want for the cubemap (can be null)
  121555. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121556. * @param generateHarmonics defines if you want to automatically generate (true by default)
  121557. * @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)
  121558. * @param reserved Internal use only
  121559. * @returns a new HDRCubeTextureAssetTask object
  121560. */
  121561. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  121562. /**
  121563. *
  121564. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  121565. * @param taskName defines the name of the new task
  121566. * @param url defines the url of the file to load
  121567. * @param size defines the size you want for the cubemap (can be null)
  121568. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121569. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121570. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121571. * @returns a new EquiRectangularCubeTextureAssetTask object
  121572. */
  121573. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  121574. /**
  121575. * Remove a task from the assets manager.
  121576. * @param task the task to remove
  121577. */
  121578. removeTask(task: AbstractAssetTask): void;
  121579. private _decreaseWaitingTasksCount;
  121580. private _runTask;
  121581. /**
  121582. * Reset the AssetsManager and remove all tasks
  121583. * @return the current instance of the AssetsManager
  121584. */
  121585. reset(): AssetsManager;
  121586. /**
  121587. * Start the loading process
  121588. * @return the current instance of the AssetsManager
  121589. */
  121590. load(): AssetsManager;
  121591. /**
  121592. * Start the loading process as an async operation
  121593. * @return a promise returning the list of failed tasks
  121594. */
  121595. loadAsync(): Promise<void>;
  121596. }
  121597. }
  121598. declare module BABYLON {
  121599. /**
  121600. * Wrapper class for promise with external resolve and reject.
  121601. */
  121602. export class Deferred<T> {
  121603. /**
  121604. * The promise associated with this deferred object.
  121605. */
  121606. readonly promise: Promise<T>;
  121607. private _resolve;
  121608. private _reject;
  121609. /**
  121610. * The resolve method of the promise associated with this deferred object.
  121611. */
  121612. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  121613. /**
  121614. * The reject method of the promise associated with this deferred object.
  121615. */
  121616. readonly reject: (reason?: any) => void;
  121617. /**
  121618. * Constructor for this deferred object.
  121619. */
  121620. constructor();
  121621. }
  121622. }
  121623. declare module BABYLON {
  121624. /**
  121625. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  121626. */
  121627. export class MeshExploder {
  121628. private _centerMesh;
  121629. private _meshes;
  121630. private _meshesOrigins;
  121631. private _toCenterVectors;
  121632. private _scaledDirection;
  121633. private _newPosition;
  121634. private _centerPosition;
  121635. /**
  121636. * Explodes meshes from a center mesh.
  121637. * @param meshes The meshes to explode.
  121638. * @param centerMesh The mesh to be center of explosion.
  121639. */
  121640. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  121641. private _setCenterMesh;
  121642. /**
  121643. * Get class name
  121644. * @returns "MeshExploder"
  121645. */
  121646. getClassName(): string;
  121647. /**
  121648. * "Exploded meshes"
  121649. * @returns Array of meshes with the centerMesh at index 0.
  121650. */
  121651. getMeshes(): Array<Mesh>;
  121652. /**
  121653. * Explodes meshes giving a specific direction
  121654. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  121655. */
  121656. explode(direction?: number): void;
  121657. }
  121658. }
  121659. declare module BABYLON {
  121660. /**
  121661. * Class used to help managing file picking and drag'n'drop
  121662. */
  121663. export class FilesInput {
  121664. /**
  121665. * List of files ready to be loaded
  121666. */
  121667. static readonly FilesToLoad: {
  121668. [key: string]: File;
  121669. };
  121670. /**
  121671. * Callback called when a file is processed
  121672. */
  121673. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  121674. private _engine;
  121675. private _currentScene;
  121676. private _sceneLoadedCallback;
  121677. private _progressCallback;
  121678. private _additionalRenderLoopLogicCallback;
  121679. private _textureLoadingCallback;
  121680. private _startingProcessingFilesCallback;
  121681. private _onReloadCallback;
  121682. private _errorCallback;
  121683. private _elementToMonitor;
  121684. private _sceneFileToLoad;
  121685. private _filesToLoad;
  121686. /**
  121687. * Creates a new FilesInput
  121688. * @param engine defines the rendering engine
  121689. * @param scene defines the hosting scene
  121690. * @param sceneLoadedCallback callback called when scene is loaded
  121691. * @param progressCallback callback called to track progress
  121692. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  121693. * @param textureLoadingCallback callback called when a texture is loading
  121694. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  121695. * @param onReloadCallback callback called when a reload is requested
  121696. * @param errorCallback callback call if an error occurs
  121697. */
  121698. 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);
  121699. private _dragEnterHandler;
  121700. private _dragOverHandler;
  121701. private _dropHandler;
  121702. /**
  121703. * Calls this function to listen to drag'n'drop events on a specific DOM element
  121704. * @param elementToMonitor defines the DOM element to track
  121705. */
  121706. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  121707. /**
  121708. * Release all associated resources
  121709. */
  121710. dispose(): void;
  121711. private renderFunction;
  121712. private drag;
  121713. private drop;
  121714. private _traverseFolder;
  121715. private _processFiles;
  121716. /**
  121717. * Load files from a drop event
  121718. * @param event defines the drop event to use as source
  121719. */
  121720. loadFiles(event: any): void;
  121721. private _processReload;
  121722. /**
  121723. * Reload the current scene from the loaded files
  121724. */
  121725. reload(): void;
  121726. }
  121727. }
  121728. declare module BABYLON {
  121729. /**
  121730. * Defines the root class used to create scene optimization to use with SceneOptimizer
  121731. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121732. */
  121733. export class SceneOptimization {
  121734. /**
  121735. * Defines the priority of this optimization (0 by default which means first in the list)
  121736. */
  121737. priority: number;
  121738. /**
  121739. * Gets a string describing the action executed by the current optimization
  121740. * @returns description string
  121741. */
  121742. getDescription(): string;
  121743. /**
  121744. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121745. * @param scene defines the current scene where to apply this optimization
  121746. * @param optimizer defines the current optimizer
  121747. * @returns true if everything that can be done was applied
  121748. */
  121749. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121750. /**
  121751. * Creates the SceneOptimization object
  121752. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121753. * @param desc defines the description associated with the optimization
  121754. */
  121755. constructor(
  121756. /**
  121757. * Defines the priority of this optimization (0 by default which means first in the list)
  121758. */
  121759. priority?: number);
  121760. }
  121761. /**
  121762. * Defines an optimization used to reduce the size of render target textures
  121763. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121764. */
  121765. export class TextureOptimization extends SceneOptimization {
  121766. /**
  121767. * Defines the priority of this optimization (0 by default which means first in the list)
  121768. */
  121769. priority: number;
  121770. /**
  121771. * 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
  121772. */
  121773. maximumSize: number;
  121774. /**
  121775. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121776. */
  121777. step: number;
  121778. /**
  121779. * Gets a string describing the action executed by the current optimization
  121780. * @returns description string
  121781. */
  121782. getDescription(): string;
  121783. /**
  121784. * Creates the TextureOptimization object
  121785. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121786. * @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
  121787. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121788. */
  121789. constructor(
  121790. /**
  121791. * Defines the priority of this optimization (0 by default which means first in the list)
  121792. */
  121793. priority?: number,
  121794. /**
  121795. * 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
  121796. */
  121797. maximumSize?: number,
  121798. /**
  121799. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121800. */
  121801. step?: number);
  121802. /**
  121803. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121804. * @param scene defines the current scene where to apply this optimization
  121805. * @param optimizer defines the current optimizer
  121806. * @returns true if everything that can be done was applied
  121807. */
  121808. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121809. }
  121810. /**
  121811. * Defines an optimization used to increase or decrease the rendering resolution
  121812. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121813. */
  121814. export class HardwareScalingOptimization extends SceneOptimization {
  121815. /**
  121816. * Defines the priority of this optimization (0 by default which means first in the list)
  121817. */
  121818. priority: number;
  121819. /**
  121820. * Defines the maximum scale to use (2 by default)
  121821. */
  121822. maximumScale: number;
  121823. /**
  121824. * Defines the step to use between two passes (0.5 by default)
  121825. */
  121826. step: number;
  121827. private _currentScale;
  121828. private _directionOffset;
  121829. /**
  121830. * Gets a string describing the action executed by the current optimization
  121831. * @return description string
  121832. */
  121833. getDescription(): string;
  121834. /**
  121835. * Creates the HardwareScalingOptimization object
  121836. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121837. * @param maximumScale defines the maximum scale to use (2 by default)
  121838. * @param step defines the step to use between two passes (0.5 by default)
  121839. */
  121840. constructor(
  121841. /**
  121842. * Defines the priority of this optimization (0 by default which means first in the list)
  121843. */
  121844. priority?: number,
  121845. /**
  121846. * Defines the maximum scale to use (2 by default)
  121847. */
  121848. maximumScale?: number,
  121849. /**
  121850. * Defines the step to use between two passes (0.5 by default)
  121851. */
  121852. step?: number);
  121853. /**
  121854. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121855. * @param scene defines the current scene where to apply this optimization
  121856. * @param optimizer defines the current optimizer
  121857. * @returns true if everything that can be done was applied
  121858. */
  121859. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121860. }
  121861. /**
  121862. * Defines an optimization used to remove shadows
  121863. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121864. */
  121865. export class ShadowsOptimization extends SceneOptimization {
  121866. /**
  121867. * Gets a string describing the action executed by the current optimization
  121868. * @return description string
  121869. */
  121870. getDescription(): string;
  121871. /**
  121872. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121873. * @param scene defines the current scene where to apply this optimization
  121874. * @param optimizer defines the current optimizer
  121875. * @returns true if everything that can be done was applied
  121876. */
  121877. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121878. }
  121879. /**
  121880. * Defines an optimization used to turn post-processes off
  121881. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121882. */
  121883. export class PostProcessesOptimization extends SceneOptimization {
  121884. /**
  121885. * Gets a string describing the action executed by the current optimization
  121886. * @return description string
  121887. */
  121888. getDescription(): string;
  121889. /**
  121890. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121891. * @param scene defines the current scene where to apply this optimization
  121892. * @param optimizer defines the current optimizer
  121893. * @returns true if everything that can be done was applied
  121894. */
  121895. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121896. }
  121897. /**
  121898. * Defines an optimization used to turn lens flares off
  121899. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121900. */
  121901. export class LensFlaresOptimization extends SceneOptimization {
  121902. /**
  121903. * Gets a string describing the action executed by the current optimization
  121904. * @return description string
  121905. */
  121906. getDescription(): string;
  121907. /**
  121908. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121909. * @param scene defines the current scene where to apply this optimization
  121910. * @param optimizer defines the current optimizer
  121911. * @returns true if everything that can be done was applied
  121912. */
  121913. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121914. }
  121915. /**
  121916. * Defines an optimization based on user defined callback.
  121917. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121918. */
  121919. export class CustomOptimization extends SceneOptimization {
  121920. /**
  121921. * Callback called to apply the custom optimization.
  121922. */
  121923. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  121924. /**
  121925. * Callback called to get custom description
  121926. */
  121927. onGetDescription: () => string;
  121928. /**
  121929. * Gets a string describing the action executed by the current optimization
  121930. * @returns description string
  121931. */
  121932. getDescription(): string;
  121933. /**
  121934. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121935. * @param scene defines the current scene where to apply this optimization
  121936. * @param optimizer defines the current optimizer
  121937. * @returns true if everything that can be done was applied
  121938. */
  121939. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121940. }
  121941. /**
  121942. * Defines an optimization used to turn particles off
  121943. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121944. */
  121945. export class ParticlesOptimization extends SceneOptimization {
  121946. /**
  121947. * Gets a string describing the action executed by the current optimization
  121948. * @return description string
  121949. */
  121950. getDescription(): string;
  121951. /**
  121952. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121953. * @param scene defines the current scene where to apply this optimization
  121954. * @param optimizer defines the current optimizer
  121955. * @returns true if everything that can be done was applied
  121956. */
  121957. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121958. }
  121959. /**
  121960. * Defines an optimization used to turn render targets off
  121961. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121962. */
  121963. export class RenderTargetsOptimization extends SceneOptimization {
  121964. /**
  121965. * Gets a string describing the action executed by the current optimization
  121966. * @return description string
  121967. */
  121968. getDescription(): string;
  121969. /**
  121970. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121971. * @param scene defines the current scene where to apply this optimization
  121972. * @param optimizer defines the current optimizer
  121973. * @returns true if everything that can be done was applied
  121974. */
  121975. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121976. }
  121977. /**
  121978. * Defines an optimization used to merge meshes with compatible materials
  121979. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121980. */
  121981. export class MergeMeshesOptimization extends SceneOptimization {
  121982. private static _UpdateSelectionTree;
  121983. /**
  121984. * Gets or sets a boolean which defines if optimization octree has to be updated
  121985. */
  121986. /**
  121987. * Gets or sets a boolean which defines if optimization octree has to be updated
  121988. */
  121989. static UpdateSelectionTree: boolean;
  121990. /**
  121991. * Gets a string describing the action executed by the current optimization
  121992. * @return description string
  121993. */
  121994. getDescription(): string;
  121995. private _canBeMerged;
  121996. /**
  121997. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121998. * @param scene defines the current scene where to apply this optimization
  121999. * @param optimizer defines the current optimizer
  122000. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  122001. * @returns true if everything that can be done was applied
  122002. */
  122003. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  122004. }
  122005. /**
  122006. * Defines a list of options used by SceneOptimizer
  122007. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122008. */
  122009. export class SceneOptimizerOptions {
  122010. /**
  122011. * Defines the target frame rate to reach (60 by default)
  122012. */
  122013. targetFrameRate: number;
  122014. /**
  122015. * Defines the interval between two checkes (2000ms by default)
  122016. */
  122017. trackerDuration: number;
  122018. /**
  122019. * Gets the list of optimizations to apply
  122020. */
  122021. optimizations: SceneOptimization[];
  122022. /**
  122023. * Creates a new list of options used by SceneOptimizer
  122024. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  122025. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  122026. */
  122027. constructor(
  122028. /**
  122029. * Defines the target frame rate to reach (60 by default)
  122030. */
  122031. targetFrameRate?: number,
  122032. /**
  122033. * Defines the interval between two checkes (2000ms by default)
  122034. */
  122035. trackerDuration?: number);
  122036. /**
  122037. * Add a new optimization
  122038. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  122039. * @returns the current SceneOptimizerOptions
  122040. */
  122041. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  122042. /**
  122043. * Add a new custom optimization
  122044. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  122045. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  122046. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  122047. * @returns the current SceneOptimizerOptions
  122048. */
  122049. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  122050. /**
  122051. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  122052. * @param targetFrameRate defines the target frame rate (60 by default)
  122053. * @returns a SceneOptimizerOptions object
  122054. */
  122055. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  122056. /**
  122057. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  122058. * @param targetFrameRate defines the target frame rate (60 by default)
  122059. * @returns a SceneOptimizerOptions object
  122060. */
  122061. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  122062. /**
  122063. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  122064. * @param targetFrameRate defines the target frame rate (60 by default)
  122065. * @returns a SceneOptimizerOptions object
  122066. */
  122067. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  122068. }
  122069. /**
  122070. * Class used to run optimizations in order to reach a target frame rate
  122071. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122072. */
  122073. export class SceneOptimizer implements IDisposable {
  122074. private _isRunning;
  122075. private _options;
  122076. private _scene;
  122077. private _currentPriorityLevel;
  122078. private _targetFrameRate;
  122079. private _trackerDuration;
  122080. private _currentFrameRate;
  122081. private _sceneDisposeObserver;
  122082. private _improvementMode;
  122083. /**
  122084. * Defines an observable called when the optimizer reaches the target frame rate
  122085. */
  122086. onSuccessObservable: Observable<SceneOptimizer>;
  122087. /**
  122088. * Defines an observable called when the optimizer enables an optimization
  122089. */
  122090. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  122091. /**
  122092. * Defines an observable called when the optimizer is not able to reach the target frame rate
  122093. */
  122094. onFailureObservable: Observable<SceneOptimizer>;
  122095. /**
  122096. * Gets a boolean indicating if the optimizer is in improvement mode
  122097. */
  122098. readonly isInImprovementMode: boolean;
  122099. /**
  122100. * Gets the current priority level (0 at start)
  122101. */
  122102. readonly currentPriorityLevel: number;
  122103. /**
  122104. * Gets the current frame rate checked by the SceneOptimizer
  122105. */
  122106. readonly currentFrameRate: number;
  122107. /**
  122108. * Gets or sets the current target frame rate (60 by default)
  122109. */
  122110. /**
  122111. * Gets or sets the current target frame rate (60 by default)
  122112. */
  122113. targetFrameRate: number;
  122114. /**
  122115. * Gets or sets the current interval between two checks (every 2000ms by default)
  122116. */
  122117. /**
  122118. * Gets or sets the current interval between two checks (every 2000ms by default)
  122119. */
  122120. trackerDuration: number;
  122121. /**
  122122. * Gets the list of active optimizations
  122123. */
  122124. readonly optimizations: SceneOptimization[];
  122125. /**
  122126. * Creates a new SceneOptimizer
  122127. * @param scene defines the scene to work on
  122128. * @param options defines the options to use with the SceneOptimizer
  122129. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  122130. * @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)
  122131. */
  122132. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  122133. /**
  122134. * Stops the current optimizer
  122135. */
  122136. stop(): void;
  122137. /**
  122138. * Reset the optimizer to initial step (current priority level = 0)
  122139. */
  122140. reset(): void;
  122141. /**
  122142. * Start the optimizer. By default it will try to reach a specific framerate
  122143. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  122144. */
  122145. start(): void;
  122146. private _checkCurrentState;
  122147. /**
  122148. * Release all resources
  122149. */
  122150. dispose(): void;
  122151. /**
  122152. * Helper function to create a SceneOptimizer with one single line of code
  122153. * @param scene defines the scene to work on
  122154. * @param options defines the options to use with the SceneOptimizer
  122155. * @param onSuccess defines a callback to call on success
  122156. * @param onFailure defines a callback to call on failure
  122157. * @returns the new SceneOptimizer object
  122158. */
  122159. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  122160. }
  122161. }
  122162. declare module BABYLON {
  122163. /**
  122164. * Class used to serialize a scene into a string
  122165. */
  122166. export class SceneSerializer {
  122167. /**
  122168. * Clear cache used by a previous serialization
  122169. */
  122170. static ClearCache(): void;
  122171. /**
  122172. * Serialize a scene into a JSON compatible object
  122173. * @param scene defines the scene to serialize
  122174. * @returns a JSON compatible object
  122175. */
  122176. static Serialize(scene: Scene): any;
  122177. /**
  122178. * Serialize a mesh into a JSON compatible object
  122179. * @param toSerialize defines the mesh to serialize
  122180. * @param withParents defines if parents must be serialized as well
  122181. * @param withChildren defines if children must be serialized as well
  122182. * @returns a JSON compatible object
  122183. */
  122184. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  122185. }
  122186. }
  122187. declare module BABYLON {
  122188. /**
  122189. * Class used to host texture specific utilities
  122190. */
  122191. export class TextureTools {
  122192. /**
  122193. * Uses the GPU to create a copy texture rescaled at a given size
  122194. * @param texture Texture to copy from
  122195. * @param width defines the desired width
  122196. * @param height defines the desired height
  122197. * @param useBilinearMode defines if bilinear mode has to be used
  122198. * @return the generated texture
  122199. */
  122200. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  122201. }
  122202. }
  122203. declare module BABYLON {
  122204. /**
  122205. * This represents the different options available for the video capture.
  122206. */
  122207. export interface VideoRecorderOptions {
  122208. /** Defines the mime type of the video. */
  122209. mimeType: string;
  122210. /** Defines the FPS the video should be recorded at. */
  122211. fps: number;
  122212. /** Defines the chunk size for the recording data. */
  122213. recordChunckSize: number;
  122214. /** The audio tracks to attach to the recording. */
  122215. audioTracks?: MediaStreamTrack[];
  122216. }
  122217. /**
  122218. * This can help with recording videos from BabylonJS.
  122219. * This is based on the available WebRTC functionalities of the browser.
  122220. *
  122221. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  122222. */
  122223. export class VideoRecorder {
  122224. private static readonly _defaultOptions;
  122225. /**
  122226. * Returns whether or not the VideoRecorder is available in your browser.
  122227. * @param engine Defines the Babylon Engine.
  122228. * @returns true if supported otherwise false.
  122229. */
  122230. static IsSupported(engine: Engine): boolean;
  122231. private readonly _options;
  122232. private _canvas;
  122233. private _mediaRecorder;
  122234. private _recordedChunks;
  122235. private _fileName;
  122236. private _resolve;
  122237. private _reject;
  122238. /**
  122239. * True when a recording is already in progress.
  122240. */
  122241. readonly isRecording: boolean;
  122242. /**
  122243. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  122244. * @param engine Defines the BabylonJS Engine you wish to record.
  122245. * @param options Defines options that can be used to customize the capture.
  122246. */
  122247. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  122248. /**
  122249. * Stops the current recording before the default capture timeout passed in the startRecording function.
  122250. */
  122251. stopRecording(): void;
  122252. /**
  122253. * Starts recording the canvas for a max duration specified in parameters.
  122254. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  122255. * If null no automatic download will start and you can rely on the promise to get the data back.
  122256. * @param maxDuration Defines the maximum recording time in seconds.
  122257. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  122258. * @return A promise callback at the end of the recording with the video data in Blob.
  122259. */
  122260. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  122261. /**
  122262. * Releases internal resources used during the recording.
  122263. */
  122264. dispose(): void;
  122265. private _handleDataAvailable;
  122266. private _handleError;
  122267. private _handleStop;
  122268. }
  122269. }
  122270. declare module BABYLON {
  122271. /**
  122272. * Class containing a set of static utilities functions for screenshots
  122273. */
  122274. export class ScreenshotTools {
  122275. /**
  122276. * Captures a screenshot of the current rendering
  122277. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122278. * @param engine defines the rendering engine
  122279. * @param camera defines the source camera
  122280. * @param size This parameter can be set to a single number or to an object with the
  122281. * following (optional) properties: precision, width, height. If a single number is passed,
  122282. * it will be used for both width and height. If an object is passed, the screenshot size
  122283. * will be derived from the parameters. The precision property is a multiplier allowing
  122284. * rendering at a higher or lower resolution
  122285. * @param successCallback defines the callback receives a single parameter which contains the
  122286. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122287. * src parameter of an <img> to display it
  122288. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122289. * Check your browser for supported MIME types
  122290. */
  122291. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  122292. /**
  122293. * Generates an image screenshot from the specified camera.
  122294. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122295. * @param engine The engine to use for rendering
  122296. * @param camera The camera to use for rendering
  122297. * @param size This parameter can be set to a single number or to an object with the
  122298. * following (optional) properties: precision, width, height. If a single number is passed,
  122299. * it will be used for both width and height. If an object is passed, the screenshot size
  122300. * will be derived from the parameters. The precision property is a multiplier allowing
  122301. * rendering at a higher or lower resolution
  122302. * @param successCallback The callback receives a single parameter which contains the
  122303. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122304. * src parameter of an <img> to display it
  122305. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122306. * Check your browser for supported MIME types
  122307. * @param samples Texture samples (default: 1)
  122308. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122309. * @param fileName A name for for the downloaded file.
  122310. */
  122311. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122312. }
  122313. }
  122314. declare module BABYLON {
  122315. /**
  122316. * A cursor which tracks a point on a path
  122317. */
  122318. export class PathCursor {
  122319. private path;
  122320. /**
  122321. * Stores path cursor callbacks for when an onchange event is triggered
  122322. */
  122323. private _onchange;
  122324. /**
  122325. * The value of the path cursor
  122326. */
  122327. value: number;
  122328. /**
  122329. * The animation array of the path cursor
  122330. */
  122331. animations: Animation[];
  122332. /**
  122333. * Initializes the path cursor
  122334. * @param path The path to track
  122335. */
  122336. constructor(path: Path2);
  122337. /**
  122338. * Gets the cursor point on the path
  122339. * @returns A point on the path cursor at the cursor location
  122340. */
  122341. getPoint(): Vector3;
  122342. /**
  122343. * Moves the cursor ahead by the step amount
  122344. * @param step The amount to move the cursor forward
  122345. * @returns This path cursor
  122346. */
  122347. moveAhead(step?: number): PathCursor;
  122348. /**
  122349. * Moves the cursor behind by the step amount
  122350. * @param step The amount to move the cursor back
  122351. * @returns This path cursor
  122352. */
  122353. moveBack(step?: number): PathCursor;
  122354. /**
  122355. * Moves the cursor by the step amount
  122356. * If the step amount is greater than one, an exception is thrown
  122357. * @param step The amount to move the cursor
  122358. * @returns This path cursor
  122359. */
  122360. move(step: number): PathCursor;
  122361. /**
  122362. * Ensures that the value is limited between zero and one
  122363. * @returns This path cursor
  122364. */
  122365. private ensureLimits;
  122366. /**
  122367. * Runs onchange callbacks on change (used by the animation engine)
  122368. * @returns This path cursor
  122369. */
  122370. private raiseOnChange;
  122371. /**
  122372. * Executes a function on change
  122373. * @param f A path cursor onchange callback
  122374. * @returns This path cursor
  122375. */
  122376. onchange(f: (cursor: PathCursor) => void): PathCursor;
  122377. }
  122378. }
  122379. declare module BABYLON {
  122380. /** @hidden */
  122381. export var blurPixelShader: {
  122382. name: string;
  122383. shader: string;
  122384. };
  122385. }
  122386. declare module BABYLON {
  122387. /** @hidden */
  122388. export var pointCloudVertexDeclaration: {
  122389. name: string;
  122390. shader: string;
  122391. };
  122392. }
  122393. // Mixins
  122394. interface Window {
  122395. mozIndexedDB: IDBFactory;
  122396. webkitIndexedDB: IDBFactory;
  122397. msIndexedDB: IDBFactory;
  122398. webkitURL: typeof URL;
  122399. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  122400. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  122401. WebGLRenderingContext: WebGLRenderingContext;
  122402. MSGesture: MSGesture;
  122403. CANNON: any;
  122404. AudioContext: AudioContext;
  122405. webkitAudioContext: AudioContext;
  122406. PointerEvent: any;
  122407. Math: Math;
  122408. Uint8Array: Uint8ArrayConstructor;
  122409. Float32Array: Float32ArrayConstructor;
  122410. mozURL: typeof URL;
  122411. msURL: typeof URL;
  122412. VRFrameData: any; // WebVR, from specs 1.1
  122413. DracoDecoderModule: any;
  122414. setImmediate(handler: (...args: any[]) => void): number;
  122415. }
  122416. interface HTMLCanvasElement {
  122417. requestPointerLock(): void;
  122418. msRequestPointerLock?(): void;
  122419. mozRequestPointerLock?(): void;
  122420. webkitRequestPointerLock?(): void;
  122421. /** Track wether a record is in progress */
  122422. isRecording: boolean;
  122423. /** Capture Stream method defined by some browsers */
  122424. captureStream(fps?: number): MediaStream;
  122425. }
  122426. interface CanvasRenderingContext2D {
  122427. msImageSmoothingEnabled: boolean;
  122428. }
  122429. interface MouseEvent {
  122430. mozMovementX: number;
  122431. mozMovementY: number;
  122432. webkitMovementX: number;
  122433. webkitMovementY: number;
  122434. msMovementX: number;
  122435. msMovementY: number;
  122436. }
  122437. interface Navigator {
  122438. mozGetVRDevices: (any: any) => any;
  122439. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122440. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122441. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122442. webkitGetGamepads(): Gamepad[];
  122443. msGetGamepads(): Gamepad[];
  122444. webkitGamepads(): Gamepad[];
  122445. }
  122446. interface HTMLVideoElement {
  122447. mozSrcObject: any;
  122448. }
  122449. interface Math {
  122450. fround(x: number): number;
  122451. imul(a: number, b: number): number;
  122452. }
  122453. interface WebGLRenderingContext {
  122454. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  122455. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  122456. vertexAttribDivisor(index: number, divisor: number): void;
  122457. createVertexArray(): any;
  122458. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  122459. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  122460. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  122461. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  122462. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  122463. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  122464. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  122465. // Queries
  122466. createQuery(): WebGLQuery;
  122467. deleteQuery(query: WebGLQuery): void;
  122468. beginQuery(target: number, query: WebGLQuery): void;
  122469. endQuery(target: number): void;
  122470. getQueryParameter(query: WebGLQuery, pname: number): any;
  122471. getQuery(target: number, pname: number): any;
  122472. MAX_SAMPLES: number;
  122473. RGBA8: number;
  122474. READ_FRAMEBUFFER: number;
  122475. DRAW_FRAMEBUFFER: number;
  122476. UNIFORM_BUFFER: number;
  122477. HALF_FLOAT_OES: number;
  122478. RGBA16F: number;
  122479. RGBA32F: number;
  122480. R32F: number;
  122481. RG32F: number;
  122482. RGB32F: number;
  122483. R16F: number;
  122484. RG16F: number;
  122485. RGB16F: number;
  122486. RED: number;
  122487. RG: number;
  122488. R8: number;
  122489. RG8: number;
  122490. UNSIGNED_INT_24_8: number;
  122491. DEPTH24_STENCIL8: number;
  122492. /* Multiple Render Targets */
  122493. drawBuffers(buffers: number[]): void;
  122494. readBuffer(src: number): void;
  122495. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  122496. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  122497. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  122498. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  122499. // Occlusion Query
  122500. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  122501. ANY_SAMPLES_PASSED: number;
  122502. QUERY_RESULT_AVAILABLE: number;
  122503. QUERY_RESULT: number;
  122504. }
  122505. interface WebGLProgram {
  122506. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  122507. }
  122508. interface EXT_disjoint_timer_query {
  122509. QUERY_COUNTER_BITS_EXT: number;
  122510. TIME_ELAPSED_EXT: number;
  122511. TIMESTAMP_EXT: number;
  122512. GPU_DISJOINT_EXT: number;
  122513. QUERY_RESULT_EXT: number;
  122514. QUERY_RESULT_AVAILABLE_EXT: number;
  122515. queryCounterEXT(query: WebGLQuery, target: number): void;
  122516. createQueryEXT(): WebGLQuery;
  122517. beginQueryEXT(target: number, query: WebGLQuery): void;
  122518. endQueryEXT(target: number): void;
  122519. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  122520. deleteQueryEXT(query: WebGLQuery): void;
  122521. }
  122522. interface WebGLUniformLocation {
  122523. _currentState: any;
  122524. }
  122525. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  122526. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  122527. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  122528. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122529. interface WebGLRenderingContext {
  122530. readonly RASTERIZER_DISCARD: number;
  122531. readonly DEPTH_COMPONENT24: number;
  122532. readonly TEXTURE_3D: number;
  122533. readonly TEXTURE_2D_ARRAY: number;
  122534. readonly TEXTURE_COMPARE_FUNC: number;
  122535. readonly TEXTURE_COMPARE_MODE: number;
  122536. readonly COMPARE_REF_TO_TEXTURE: number;
  122537. readonly TEXTURE_WRAP_R: number;
  122538. readonly HALF_FLOAT: number;
  122539. readonly RGB8: number;
  122540. readonly RED_INTEGER: number;
  122541. readonly RG_INTEGER: number;
  122542. readonly RGB_INTEGER: number;
  122543. readonly RGBA_INTEGER: number;
  122544. readonly R8_SNORM: number;
  122545. readonly RG8_SNORM: number;
  122546. readonly RGB8_SNORM: number;
  122547. readonly RGBA8_SNORM: number;
  122548. readonly R8I: number;
  122549. readonly RG8I: number;
  122550. readonly RGB8I: number;
  122551. readonly RGBA8I: number;
  122552. readonly R8UI: number;
  122553. readonly RG8UI: number;
  122554. readonly RGB8UI: number;
  122555. readonly RGBA8UI: number;
  122556. readonly R16I: number;
  122557. readonly RG16I: number;
  122558. readonly RGB16I: number;
  122559. readonly RGBA16I: number;
  122560. readonly R16UI: number;
  122561. readonly RG16UI: number;
  122562. readonly RGB16UI: number;
  122563. readonly RGBA16UI: number;
  122564. readonly R32I: number;
  122565. readonly RG32I: number;
  122566. readonly RGB32I: number;
  122567. readonly RGBA32I: number;
  122568. readonly R32UI: number;
  122569. readonly RG32UI: number;
  122570. readonly RGB32UI: number;
  122571. readonly RGBA32UI: number;
  122572. readonly RGB10_A2UI: number;
  122573. readonly R11F_G11F_B10F: number;
  122574. readonly RGB9_E5: number;
  122575. readonly RGB10_A2: number;
  122576. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  122577. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  122578. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  122579. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122580. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  122581. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  122582. 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;
  122583. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  122584. readonly TRANSFORM_FEEDBACK: number;
  122585. readonly INTERLEAVED_ATTRIBS: number;
  122586. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  122587. createTransformFeedback(): WebGLTransformFeedback;
  122588. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  122589. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  122590. beginTransformFeedback(primitiveMode: number): void;
  122591. endTransformFeedback(): void;
  122592. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  122593. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122594. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122595. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122596. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  122597. }
  122598. interface ImageBitmap {
  122599. readonly width: number;
  122600. readonly height: number;
  122601. close(): void;
  122602. }
  122603. interface WebGLQuery extends WebGLObject {
  122604. }
  122605. declare var WebGLQuery: {
  122606. prototype: WebGLQuery;
  122607. new(): WebGLQuery;
  122608. };
  122609. interface WebGLSampler extends WebGLObject {
  122610. }
  122611. declare var WebGLSampler: {
  122612. prototype: WebGLSampler;
  122613. new(): WebGLSampler;
  122614. };
  122615. interface WebGLSync extends WebGLObject {
  122616. }
  122617. declare var WebGLSync: {
  122618. prototype: WebGLSync;
  122619. new(): WebGLSync;
  122620. };
  122621. interface WebGLTransformFeedback extends WebGLObject {
  122622. }
  122623. declare var WebGLTransformFeedback: {
  122624. prototype: WebGLTransformFeedback;
  122625. new(): WebGLTransformFeedback;
  122626. };
  122627. interface WebGLVertexArrayObject extends WebGLObject {
  122628. }
  122629. declare var WebGLVertexArrayObject: {
  122630. prototype: WebGLVertexArrayObject;
  122631. new(): WebGLVertexArrayObject;
  122632. };
  122633. // Type definitions for WebVR API
  122634. // Project: https://w3c.github.io/webvr/
  122635. // Definitions by: six a <https://github.com/lostfictions>
  122636. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122637. interface VRDisplay extends EventTarget {
  122638. /**
  122639. * Dictionary of capabilities describing the VRDisplay.
  122640. */
  122641. readonly capabilities: VRDisplayCapabilities;
  122642. /**
  122643. * z-depth defining the far plane of the eye view frustum
  122644. * enables mapping of values in the render target depth
  122645. * attachment to scene coordinates. Initially set to 10000.0.
  122646. */
  122647. depthFar: number;
  122648. /**
  122649. * z-depth defining the near plane of the eye view frustum
  122650. * enables mapping of values in the render target depth
  122651. * attachment to scene coordinates. Initially set to 0.01.
  122652. */
  122653. depthNear: number;
  122654. /**
  122655. * An identifier for this distinct VRDisplay. Used as an
  122656. * association point in the Gamepad API.
  122657. */
  122658. readonly displayId: number;
  122659. /**
  122660. * A display name, a user-readable name identifying it.
  122661. */
  122662. readonly displayName: string;
  122663. readonly isConnected: boolean;
  122664. readonly isPresenting: boolean;
  122665. /**
  122666. * If this VRDisplay supports room-scale experiences, the optional
  122667. * stage attribute contains details on the room-scale parameters.
  122668. */
  122669. readonly stageParameters: VRStageParameters | null;
  122670. /**
  122671. * Passing the value returned by `requestAnimationFrame` to
  122672. * `cancelAnimationFrame` will unregister the callback.
  122673. * @param handle Define the hanle of the request to cancel
  122674. */
  122675. cancelAnimationFrame(handle: number): void;
  122676. /**
  122677. * Stops presenting to the VRDisplay.
  122678. * @returns a promise to know when it stopped
  122679. */
  122680. exitPresent(): Promise<void>;
  122681. /**
  122682. * Return the current VREyeParameters for the given eye.
  122683. * @param whichEye Define the eye we want the parameter for
  122684. * @returns the eye parameters
  122685. */
  122686. getEyeParameters(whichEye: string): VREyeParameters;
  122687. /**
  122688. * Populates the passed VRFrameData with the information required to render
  122689. * the current frame.
  122690. * @param frameData Define the data structure to populate
  122691. * @returns true if ok otherwise false
  122692. */
  122693. getFrameData(frameData: VRFrameData): boolean;
  122694. /**
  122695. * Get the layers currently being presented.
  122696. * @returns the list of VR layers
  122697. */
  122698. getLayers(): VRLayer[];
  122699. /**
  122700. * Return a VRPose containing the future predicted pose of the VRDisplay
  122701. * when the current frame will be presented. The value returned will not
  122702. * change until JavaScript has returned control to the browser.
  122703. *
  122704. * The VRPose will contain the position, orientation, velocity,
  122705. * and acceleration of each of these properties.
  122706. * @returns the pose object
  122707. */
  122708. getPose(): VRPose;
  122709. /**
  122710. * Return the current instantaneous pose of the VRDisplay, with no
  122711. * prediction applied.
  122712. * @returns the current instantaneous pose
  122713. */
  122714. getImmediatePose(): VRPose;
  122715. /**
  122716. * The callback passed to `requestAnimationFrame` will be called
  122717. * any time a new frame should be rendered. When the VRDisplay is
  122718. * presenting the callback will be called at the native refresh
  122719. * rate of the HMD. When not presenting this function acts
  122720. * identically to how window.requestAnimationFrame acts. Content should
  122721. * make no assumptions of frame rate or vsync behavior as the HMD runs
  122722. * asynchronously from other displays and at differing refresh rates.
  122723. * @param callback Define the eaction to run next frame
  122724. * @returns the request handle it
  122725. */
  122726. requestAnimationFrame(callback: FrameRequestCallback): number;
  122727. /**
  122728. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  122729. * Repeat calls while already presenting will update the VRLayers being displayed.
  122730. * @param layers Define the list of layer to present
  122731. * @returns a promise to know when the request has been fulfilled
  122732. */
  122733. requestPresent(layers: VRLayer[]): Promise<void>;
  122734. /**
  122735. * Reset the pose for this display, treating its current position and
  122736. * orientation as the "origin/zero" values. VRPose.position,
  122737. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  122738. * updated when calling resetPose(). This should be called in only
  122739. * sitting-space experiences.
  122740. */
  122741. resetPose(): void;
  122742. /**
  122743. * The VRLayer provided to the VRDisplay will be captured and presented
  122744. * in the HMD. Calling this function has the same effect on the source
  122745. * canvas as any other operation that uses its source image, and canvases
  122746. * created without preserveDrawingBuffer set to true will be cleared.
  122747. * @param pose Define the pose to submit
  122748. */
  122749. submitFrame(pose?: VRPose): void;
  122750. }
  122751. declare var VRDisplay: {
  122752. prototype: VRDisplay;
  122753. new(): VRDisplay;
  122754. };
  122755. interface VRLayer {
  122756. leftBounds?: number[] | Float32Array | null;
  122757. rightBounds?: number[] | Float32Array | null;
  122758. source?: HTMLCanvasElement | null;
  122759. }
  122760. interface VRDisplayCapabilities {
  122761. readonly canPresent: boolean;
  122762. readonly hasExternalDisplay: boolean;
  122763. readonly hasOrientation: boolean;
  122764. readonly hasPosition: boolean;
  122765. readonly maxLayers: number;
  122766. }
  122767. interface VREyeParameters {
  122768. /** @deprecated */
  122769. readonly fieldOfView: VRFieldOfView;
  122770. readonly offset: Float32Array;
  122771. readonly renderHeight: number;
  122772. readonly renderWidth: number;
  122773. }
  122774. interface VRFieldOfView {
  122775. readonly downDegrees: number;
  122776. readonly leftDegrees: number;
  122777. readonly rightDegrees: number;
  122778. readonly upDegrees: number;
  122779. }
  122780. interface VRFrameData {
  122781. readonly leftProjectionMatrix: Float32Array;
  122782. readonly leftViewMatrix: Float32Array;
  122783. readonly pose: VRPose;
  122784. readonly rightProjectionMatrix: Float32Array;
  122785. readonly rightViewMatrix: Float32Array;
  122786. readonly timestamp: number;
  122787. }
  122788. interface VRPose {
  122789. readonly angularAcceleration: Float32Array | null;
  122790. readonly angularVelocity: Float32Array | null;
  122791. readonly linearAcceleration: Float32Array | null;
  122792. readonly linearVelocity: Float32Array | null;
  122793. readonly orientation: Float32Array | null;
  122794. readonly position: Float32Array | null;
  122795. readonly timestamp: number;
  122796. }
  122797. interface VRStageParameters {
  122798. sittingToStandingTransform?: Float32Array;
  122799. sizeX?: number;
  122800. sizeY?: number;
  122801. }
  122802. interface Navigator {
  122803. getVRDisplays(): Promise<VRDisplay[]>;
  122804. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  122805. }
  122806. interface Window {
  122807. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  122808. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  122809. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  122810. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122811. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122812. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  122813. }
  122814. interface Gamepad {
  122815. readonly displayId: number;
  122816. }
  122817. interface XRDevice {
  122818. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  122819. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  122820. }
  122821. interface XRSession {
  122822. getInputSources(): Array<any>;
  122823. baseLayer: XRWebGLLayer;
  122824. requestFrameOfReference(type: string): Promise<void>;
  122825. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  122826. end(): Promise<void>;
  122827. requestAnimationFrame: Function;
  122828. addEventListener: Function;
  122829. }
  122830. interface XRSessionCreationOptions {
  122831. outputContext?: WebGLRenderingContext | null;
  122832. immersive?: boolean;
  122833. environmentIntegration?: boolean;
  122834. }
  122835. interface XRLayer {
  122836. getViewport: Function;
  122837. framebufferWidth: number;
  122838. framebufferHeight: number;
  122839. }
  122840. interface XRView {
  122841. projectionMatrix: Float32Array;
  122842. }
  122843. interface XRFrame {
  122844. getDevicePose: Function;
  122845. getInputPose: Function;
  122846. views: Array<XRView>;
  122847. baseLayer: XRLayer;
  122848. }
  122849. interface XRFrameOfReference {
  122850. }
  122851. interface XRWebGLLayer extends XRLayer {
  122852. framebuffer: WebGLFramebuffer;
  122853. }
  122854. declare var XRWebGLLayer: {
  122855. prototype: XRWebGLLayer;
  122856. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  122857. };